Skip to content

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

Draft
lcian wants to merge 2 commits into
lcian/feat/preprod-retention-helperfrom
lcian/feat/preprod-artifact-expiry
Draft

lcian wants to merge 2 commits into
lcian/feat/preprod-retention-helperfrom
lcian/feat/preprod-artifact-expiry

Conversation

@lcian

@lcian lcian commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Sentry documents that retention is set when data is ingested, but a preprod build has no retention recorded on it: reads derive it from the current plan and deletion uses a fixed age. Each PreprodArtifact now gets its expiry stamped when it is created, from the retention the organization has at that time.

Two products on one row. A build is analyzed for size and distributed from one row and one set of files, and the two retentions differ on the Team plan and on trials (30 days and 396 days). The row therefore carries two dates. date_expires uses the longest retention and is when the row and its files are deleted. date_size_analysis_expires uses the Size Analysis retention and is when the size analysis stops being readable. This keeps what both products do today: size analysis is readable for 30 days there, and the build stays installable for 13 months. On the Developer plan, which has no Build Distribution, both retentions are 30 days, so both dates are 30 days after the upload. Both periods are the product's: the retention table on EME-239 gives Size Analysis 30 days on Developer and Team and Build Distribution 13 months on Team, and EME-724 decided to keep the data for 13 months and to limit by plan what is shown. One date at the longer retention would make size analysis readable for 13 months, and one date at the shorter retention would delete builds that are still distributed. The size analysis rows and files are still deleted together with the artifact, not at the shorter date.

Snapshots have no data category yet (EME-1315), so a snapshot artifact gets the same two dates as a build. That keeps its lifetime as it is today.

Every new artifact gets both dates. An instance without a configured retention uses the default of 90 days, so a null date only means that the row was created before the columns existed. The later PRs give such a row the behavior it has today.

Nothing reads the columns yet. The column migration runs with the deploy, because the new code writes the columns. The index on date_expires is a separate post-deployment migration.

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
  • 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

Add date_expires and date_size_analysis_expires to PreprodArtifact and set them at the two places that create one, from the retention of the organization at that time. Nothing reads the columns yet.

A build is analyzed for size and distributed from the same row, and the two can have different retentions, so the row carries two dates: date_expires at the longest retention, for the row and its files, and date_size_analysis_expires at the Size Analysis retention.

The index on date_expires is in its own post-deployment migration.

Refs EME-1314
@linear-code

linear-code Bot commented Nov 20, 2026

Copy link
Copy Markdown

EME-1314

Merge the retention helper change: there is no unlimited retention any more, so an artifact always gets both dates when it is created. A null date now only means the row predates the columns.
@github-actions

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;

This branch has not been deployed

No deployments
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.

1 participant