fix: keep canary serving until roll completes to avoid downtime (#4745)#4948
Draft
kylemclaren wants to merge 1 commit into
Draft
fix: keep canary serving until roll completes to avoid downtime (#4745)#4948kylemclaren wants to merge 1 commit into
kylemclaren wants to merge 1 commit into
Conversation
The canary strategy destroyed its canary machine before rolling the real machines (deployCanaryMachines ran, and destroyed the canary in a deferred closure, strictly before updateExistingMachines). The canary was also a non-serving smoke-test machine (DNS SkipRegistration), so it never preserved availability. For single-machine apps (n=1) this left a window with no serving instance while the one real machine was updated in place, causing downtime. Restructure the canary phase to preserve availability: - deployCanaryMachines now returns the canary LeasableMachines instead of destroying them, and registers them in DNS so they serve traffic. - deployMachinesApp destroys the canaries only after updateExistingMachines completes (via defer), so n+1 healthy serving instances exist throughout the roll. Canaries are also cleaned up if canary creation or the roll fails. Adds TestDeployCanaryKeepsInstanceDuringRoll, which reproduces the n=1 case and asserts the canary is destroyed after the existing machine is rolled. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #4745.
The
canarydeploy strategy created a throwaway canary machine, health-checked it, then destroyed it before rolling the real machines. For single-machine apps this left a window with zero serving instances → downtime.The canary is now registered in DNS (so it serves traffic) and is destroyed only after the rolling update completes, keeping n+1 healthy instances throughout the roll.
Testing: added
TestDeployCanaryKeepsInstanceDuringRoll, which records launch/destroy ordering and asserts the canary is destroyed after the real machine is rolled — it fails onmaster(canary destroyed first) and passes with the fix.go test ./internal/command/deploy/...is green.✅ Live-verified against a real org (single-machine app, HTTP-probed during deploy; cleaned up afterward):
--strategy canarydeploy, live probing saw a multi-second zero-serving window (a 6scode=000timeout in one run; 4.5s slow-200 stalls in another) as the canary was destroyed before the real machine rolled.🤖 Generated with Claude Code