fix(gcp): protect minted key cleanup across interrupts - #2120
Merged
Merged
Conversation
Start signal handling after the final wizard choice and retain it through minting, upload, and cleanup. Remove stdout writes that can block cleanup. Exercise the real coordinator in subprocesses with fixture APIs, saturated stdout, SIGINT, SIGTERM, and interruption during minting or at the prompt.
Contributor
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configurationConfiguration used: Repository: LeanerCloud/cloud-commitments-cli/.coderabbit.yaml Review profile: CHILL Plan: Essentials Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
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
GCP setup now protects wizard-minted keys from SIGINT and SIGTERM from the final create choice through upload and cleanup. Prompts retain default interrupt behavior. Output occurs after cleanup, so stdout backpressure cannot strand the plaintext key.
This fixes the remaining interruption gap from #1947 and #2112. The other hardening items in #2117 remain separate.
Closes #2119.
Root cause and fix
The coordinator registered signal handling after Step 5 returned. Step 5 had already minted and written the key and could block while printing its temporary path. Another message could block after remote deletion but before local removal.
The coordinator now starts one signal context after the final input choice, before minting, and retains it through the existing uploader cleanup. A nil-safe deferred closure stops signal handling on failure. Successful cleanup restores default signal behavior before final output. Both blocking pre-cleanup messages are removed. Operator-supplied files retain their existing behavior.
Regression proof
Subprocess tests invoke the actual
runConfigureGCPcoordinator and real SDK clients against local fixture endpoints. They cover SIGINT and SIGTERM with stdout full, cancellation during the IAM request, and default SIGINT termination at the final prompt. Assertions check local file and directory removal and the remote delete request.The tests fail against the original coordinator because plaintext survives both signals. Separate probes also fail when restoring only late signal activation, Step 5 output, or remote-cleanup output. The latter two leave the plaintext file present after the bounded subprocess timeout.
Verification
With Go 1.26.6 and
GOWORK=off:-race: pass.go test -race -short ./cmd/... -count=1: pass, 443.190s.go mod tidy -diff: pass; tidy output empty.These author checks cover tree
f7b2822efae9f06add8ecae99229cb1fc075a5fe, identical at fully tested commit2dc4d8eand follow-up candidate42dcc9e5. Independent gpt-6-astra review approved final SHA42dcc9e5e2cb6fc737ab7a1ec3791040825ddd09with no actionable findings and independently passed the focused race tests in 8.234s. Tests use fixture credentials and local APIs; no live cloud operation was performed.