Skip to content

fix: deactivate stale in-progress deployments before creating new ones#131

Merged
0x46616c6b merged 1 commit intomainfrom
fix/deactivate-stale-deployments
Apr 23, 2026
Merged

fix: deactivate stale in-progress deployments before creating new ones#131
0x46616c6b merged 1 commit intomainfrom
fix/deactivate-stale-deployments

Conversation

@0x46616c6b
Copy link
Copy Markdown
Contributor

Type of Change

  • Bugfix
  • Enhancement / new feature
  • Refactoring
  • Documentation

Description

When the Kustomization is updated in quick succession (e.g. two pushes to main within seconds), GitHub Deployments can become orphaned — stuck in in_progress forever. This happens because the deploy.staffbase.com/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 via the GitHub API and marks any with status in_progress, queued, or pending as inactive ("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_inactive parameter only affects deployments that previously reached success state and does not help with orphaned in_progress deployments.

Checklist

  • Write tests
  • Make sure all tests pass
  • Update documentation
  • Review the Contributing Guideline and sign CLA
  • Reference relevant issue(s) and close them after merging

The changes and the PR were generated by Claude.

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>
@0x46616c6b 0x46616c6b marked this pull request as ready for review April 22, 2026 12:34
@0x46616c6b 0x46616c6b requested review from a team as code owners April 22, 2026 12:34
@0x46616c6b 0x46616c6b added dev Pull Requests that deployed to dev and removed dev Pull Requests that deployed to dev labels Apr 22, 2026
@0x46616c6b 0x46616c6b merged commit cf4adf5 into main Apr 23, 2026
7 checks passed
@0x46616c6b 0x46616c6b deleted the fix/deactivate-stale-deployments branch April 23, 2026 06:59
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 23, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants