Make instance lifecycle no-ops idempotent#205
Merged
sjmiller609 merged 1 commit intomainfrom Apr 30, 2026
Merged
Conversation
|
Firetiger deploy monitoring skipped This PR didn't match the auto-monitor filter configured on your GitHub connection:
Reason: PR modifies instance lifecycle logic in packages/api/lib/instances, not the API endpoints (packages/api/cmd/api/) or Temporal workflows (packages/api/lib/temporal) specified in the filter; please opt in manually if deploy monitoring is needed. To monitor this PR anyway, reply with |
hiroTamada
approved these changes
Apr 30, 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 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.
Summary
Why
Clients currently see a 409 for benign races like restore on an already-running instance. Some clients retry 409s, which adds avoidable wake latency. These no-op OK responses make lifecycle calls idempotent where the requested outcome is already true.
Tests
go test ./lib/instances -run 'TestLifecycleNoop'\n-go test ./lib/instances\n-go test ./cmd/api/api -run 'Test(Standby|Restore|Stop|Start)Instance'\n\nNote:go test ./cmd/api/apiwas also attempted but local volume tests requiremkfs.ext4, which is not installed in this macOS environment.Note
Medium Risk
Changes instance lifecycle APIs (
StartInstance,StopInstance,RestoreInstance,StandbyInstance) to sometimes return early based on stored state, which could affect client-visible behavior and event-driven consumers if state derivation differs from prior transition logic.Overview
Makes several instance lifecycle operations idempotent no-ops when the instance is already effectively in the requested state:
RestoreInstancereturns the current instance for Running/Initializing,StopInstancereturns current for Stopped,StartInstancereturns current for Running/Initializing when no command overrides are provided, andStandbyInstancereturns current for Standby when no standby options are provided.Adds lightweight state-check helpers (
currentInstanceWithoutHydration,startRequestHasOverrides,standbyRequestHasOptions) and ensures no lifecycle events are emitted for these no-op responses. Addslifecycle_noop_test.gowith a fake hypervisor and assertions that no-op calls return success without publishing events, while override/option cases still error as before.Reviewed by Cursor Bugbot for commit bbc9ae2. Bugbot is set up for automated code reviews on this repo. Configure here.