fix: deactivate stale in-progress deployments before creating new ones#131
Merged
0x46616c6b merged 1 commit intomainfrom Apr 23, 2026
Merged
fix: deactivate stale in-progress deployments before creating new ones#1310x46616c6b merged 1 commit intomainfrom
0x46616c6b merged 1 commit intomainfrom
Conversation
When the Kustomization is updated in quick succession, GitHub Deployments can become orphaned — stuck in `in_progress` forever because the deployment-id annotation in the GitOps repo gets overwritten by the subsequent run and the flux-deployment-reporter only sees the latest ID. This adds a `deactivate_stale_deployments` function that runs before each new deployment creation. It queries existing deployments for the target environment and marks any with status `in_progress`, `queued`, or `pending` as `inactive`. The cleanup is best-effort and idempotent. Co-Authored-By: Claude <claude@anthropic.com>
Closed
9 tasks
ricoberger
approved these changes
Apr 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Type of Change
Description
When the Kustomization is updated in quick succession (e.g. two pushes to
mainwithin seconds), GitHub Deployments can become orphaned — stuck inin_progressforever. This happens because thedeploy.staffbase.com/deployment-idannotation in the GitOps repo gets overwritten by the subsequent run, and theflux-deployment-reporteronly sees the latest ID.This adds a
deactivate_stale_deployments()function that runs before each new deployment creation. It queries existing deployments for the target environment via the GitHub API and marks any with statusin_progress,queued, orpendingasinactive("Superseded by newer deployment").The cleanup is best-effort (failures don't block new deployments) and idempotent (concurrent runs deactivating the same deployment is harmless).
Note: GitHub's built-in
auto_inactiveparameter only affects deployments that previously reachedsuccessstate and does not help with orphanedin_progressdeployments.Checklist
The changes and the PR were generated by Claude.