-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
feat(preprod): Reduce status check API calls #107886
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
base: master
Are you sure you want to change the base?
Conversation
Without rules configured, both calls compute NEUTRAL status, so the skip logic deduplicates the second call. Configure rules so the first call posts IN_PROGRESS and the second posts SUCCESS (different statuses).
…enum Adds StatusCheckPostPolicy enum (TRY_TO_DEDUPLICATE, ALWAYS_POST) to control dedup behavior instead of checking caller == "rerun_endpoint". Defaults to TRY_TO_DEDUPLICATE so existing callers need no changes.
| ).values_list("id", "extras") | ||
| ) | ||
| if _should_skip_status_check( | ||
| all_artifacts, extras_by_artifact_id, size_metrics_map, status |
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'm confused why we have all_artifacts already but still need to do another query for extras_by_artifact_id
| return False | ||
|
|
||
|
|
||
| def _write_posted_status_claim(preprod_artifact: PreprodArtifact, posted_status: str) -> None: |
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.
Don't we already have another method that updates the posted_status_checks field? Shouldn't that be consolidated together? Otherwise it's a bit confusing we have multiple ways to update that.
| artifact.save(update_fields=["extras"]) | ||
|
|
||
|
|
||
| def _clear_posted_status_claim(preprod_artifact: PreprodArtifact) -> None: |
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.
It might be fine to keep this duplication but perhaps _clear_posted_status_claim and _write_posted_status_claim can be combined?
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 think some of the message formatting needs to be updated to work with this properly. For example, now that we will no longer render separate in-progress/success statuses per app, we should probably have a single generic "Your apps are being analyzed" type of messaging.
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.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
| include_approve_action=bool(triggered_rules), | ||
| ) | ||
| except Exception as e: | ||
| _clear_posted_status_claim(preprod_artifact) |
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.
Claim cleared unconditionally regardless of post policy
Low Severity
_clear_posted_status_claim is called unconditionally on API failure, but _write_posted_status_claim is only called inside the TRY_TO_DEDUPLICATE block. When post_policy is ALWAYS_POST (rerun endpoint), no claim was written, yet the clear still runs — removing a valid posted_status set by a previous successful run. This performs an unnecessary DB transaction and briefly leaves extras in an inconsistent state between the clear and the subsequent _update_posted_status_check call, during which concurrent sibling tasks could read stale dedup state.


Summary
Key changes
_should_skip_status_check: pure function deciding skip/post based on sibling extras_write_posted_status_claim/_clear_posted_status_claim: claim management in extrascreate_preprod_status_check_taskwith two-phase approach_update_posted_status_checknow persistsposted_statuson successTest plan