-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
feat(snapshots): Run snapshot comparisons when uploads received out-of-order #112474
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| from __future__ import annotations | ||
|
|
||
| from sentry.preprod.models import PreprodArtifact, PreprodBuildConfiguration | ||
| from sentry.preprod.snapshots.models import PreprodSnapshotComparison | ||
|
|
||
|
|
||
| def find_base_snapshot_artifact( | ||
|
|
@@ -26,3 +27,35 @@ def find_base_snapshot_artifact( | |
| .order_by("-date_added") | ||
| .first() | ||
| ) | ||
|
|
||
|
|
||
| def find_head_snapshot_artifacts_awaiting_base( | ||
| organization_id: int, | ||
| base_sha: str, | ||
| base_repo_name: str, | ||
| project_id: int, | ||
| app_id: str | None, | ||
| build_configuration: PreprodBuildConfiguration | None, | ||
| ) -> list[PreprodArtifact]: | ||
| """Find head snapshot artifacts that were uploaded before their base was available. | ||
|
|
||
| When a base artifact is uploaded, its commit_comparison.head_sha is the SHA that waiting | ||
| head artifacts have as their commit_comparison.base_sha. This finds those heads so | ||
| comparisons can be triggered retroactively. | ||
| """ | ||
| return list( | ||
| PreprodArtifact.objects.filter( | ||
| commit_comparison__organization_id=organization_id, | ||
| commit_comparison__base_sha=base_sha, | ||
| commit_comparison__base_repo_name=base_repo_name, | ||
| project_id=project_id, | ||
| preprodsnapshotmetrics__isnull=False, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shouldn't we also exclude builds that have size metrics in this query too?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In practice I don't think there will ever be a case where snapshotmetrics and size metrics are both set |
||
| app_id=app_id, | ||
| build_configuration=build_configuration, | ||
| ) | ||
| .exclude( | ||
| preprodsnapshotmetrics__snapshot_comparisons_head_metrics__state=PreprodSnapshotComparison.State.SUCCESS, | ||
| ) | ||
| .select_related("preprodsnapshotmetrics") | ||
| .order_by("-date_added") | ||
| ) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: shall we extract this into a helper method since it's a copy pasta of code from line 606?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally don't think it cleans things up much and just adds more indeterminism to track down a shared helper, so I'm fine lightly duplicating to avoid redirection