Skip to content

feat(preprod): Stamp an expiry on artifacts when they are created - #132002

Draft
lcian wants to merge 4 commits into
masterfrom
lcian/feat/preprod-artifact-expiry
Draft

lcian wants to merge 4 commits into
masterfrom
lcian/feat/preprod-artifact-expiry

Conversation

@lcian

@lcian lcian commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

A preprod build has no retention recorded on it, so reads use the organization's current plan and deletion uses a fixed age. Each PreprodArtifact now gets its expiry stamped when it is created, from the organization's retention at that time.

The row has two dates because one build serves two products with different retentions, such as 30 days of Size Analysis and 13 months of Build Distribution on the Team plan.

  • date_expires uses the longer retention and is when the row and its files are deleted.
  • date_size_analysis_expires is when the size analysis stops being readable.

Snapshots

A snapshot is a separate upload with its own row, so it gets only date_expires and no date_size_analysis_expires. Snapshots have a data category, SNAPSHOT_IMAGE, but no retention is configured for it yet. Until then, the Size Analysis retention stands in for it, as planned in EME-1316: 30 days on the Developer and Team plans, 13 months on Business. Snapshot images are shared between snapshots and still expire on their own in Objectstore.

Refs EME-1314

Cross-repository landing order (top to bottom)

  • sentry#132001 — Read preprod retention through one helper, capped at 396 days
  • 👉 sentry#132002 — Add the expiry columns and stamp them when an artifact is created
  • sentry#132702 — Add the index on date_expires that the cleanup reads, as a post-deployment migration
  • getsentry#23481 — Add the job that backfills the expiry of existing artifacts
  • sentry#132003 — Read the expiry from the row, and keep a build visible until it expires
  • sentry#132004 — Delete artifacts in cleanup once they are past their stamped expiry
  • ops#25816 — Explain what --days still does on the preprod artifacts cleanup cron
  • sentry-docs#20923 — Add Build Distribution to the public data retention page

@linear-code

linear-code Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

EME-1314

FS-653

@sentry

sentry Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Sentry Snapshot Testing

Name Added Removed Changed Renamed Unchanged Skipped Status
sentry-frontend
sentry-frontend
0 0 0 0 1084 0 ✅ Unchanged

⚙️ sentry-frontend Snapshot Settings

Comment thread src/sentry/preprod/models.py Resolved
Base automatically changed from lcian/feat/preprod-retention-helper to master November 26, 2026 14:39
@lcian
lcian force-pushed the lcian/feat/preprod-artifact-expiry branch from 19cf25a to 5ed74a9 Compare November 26, 2026 14:42
@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

This PR has a migration; here is the generated SQL for src/sentry/preprod/migrations/0031_add_artifact_expiry.py

for 0031_add_artifact_expiry in preprod

--
-- Add field date_expires to preprodartifact
--
ALTER TABLE "sentry_preprodartifact" ADD COLUMN "date_expires" timestamp with time zone NULL;
--
-- Add field date_size_analysis_expires to preprodartifact
--
ALTER TABLE "sentry_preprodartifact" ADD COLUMN "date_size_analysis_expires" timestamp with time zone NULL;

A snapshot is a separate upload, not a build, so it no longer takes the Size Analysis and Build Distribution retentions. It gets only a date_expires, SNAPSHOT_RETENTION_DAYS after it is created, until the SNAPSHOT_IMAGE category has a retention of its own.
Snapshots have no retention of their own yet. The Size Analysis retention matches the snapshot retention intended on every plan, so it stands in for it instead of a fixed 396 days. Snapshots still get only date_expires.
Adding the index is a post-deployment migration, so it lands separately from the columns.

This branch was successfully deployed

1 active (outdated) deployment
Preview — 47d1d7e9 Deployed Nov 26, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants