Skip to content

fix: close RolloutGate creation race window that allows prod to bypass staging ordering#1

Open
LittleChimera wants to merge 1 commit into
release-0.1from
fix/gate-creation-race-condition
Open

fix: close RolloutGate creation race window that allows prod to bypass staging ordering#1
LittleChimera wants to merge 1 commit into
release-0.1from
fix/gate-creation-race-condition

Conversation

@LittleChimera
Copy link
Copy Markdown
Contributor

Summary

  • Root cause: When a prod Environment and its Rollout are created simultaneously, the rollout controller can deploy freely during the window between Rollout creation and RolloutGate creation. The gate was being created after syncDeploymentHistory + buildRelationshipGraph — both GitHub API calls — introducing a multi-second delay.
  • Secondary cause: Even after gate creation, AllowedVersions=nil is treated by the rollout controller as "no restriction" rather than "block all", so the gate didn't protect anything until updateAllowedVersionsFromRelationships ran a second time.

Observed incident: kuberik-demo prod deployed main-1779290372-b797408 at 15:19:48 but the prod gate wasn't created until 15:19:50, allowing prod to bypass the staging-before-prod ordering requirement.

Changes

  1. Move createOrUpdateRolloutGate to before GitHub API calls in Reconcile. The gate now exists immediately on first reconcile, before any slow external calls.
  2. Initialize AllowedVersions = [] (not nil) when relationship is configured. nil means "no restriction" in the rollout controller. An empty slice means "block all versions" — the safe default while the gate is being set up.

Test plan

  • Deploy a new environment with relationship: { type: After } alongside its Rollout; verify no deployment happens before the gate's allowedVersions is populated by the upstream environment's bake success
  • Verify existing environments with no relationship are unaffected (gate still created with allowedVersions=nil)
  • Re-run kuberik-demo; staging should always bake before prod deploys the same version

🤖 Generated with Claude Code

…ace window

When an Environment with a relationship is created at the same time as its
Rollout, the rollout controller can deploy freely during the window between
Rollout creation and RolloutGate creation by the environment controller.
The gate was created after syncDeploymentHistory and buildRelationshipGraph
(both GitHub API calls), introducing a multi-second delay.

Move createOrUpdateRolloutGate to the top of Reconcile, before any GitHub
API calls. Also initialize AllowedVersions to [] (not nil) when a relationship
is configured — nil is treated as "no restriction" by the rollout controller,
so a freshly created gate would not block until updateAllowedVersionsFromRelationships
ran a second time.

Observed: kuberik-demo prod deployed main-1779290372-b797408 at 15:19:48 but
the prod gate was not created until 15:19:50, allowing prod to bypass the
staging-before-prod ordering requirement.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant