Skip to content

fcvm-coordinator-release: name the failed step and error code; never fail a release over a lock it no longer holds - #695

Merged
ejc3 merged 1 commit into
mainfrom
coordinator-release-failure-step
Oct 26, 2026
Merged

ejc3 merged 1 commit into
mainfrom
coordinator-release-failure-step

Conversation

@ejc3

@ejc3 ejc3 commented Oct 26, 2026 •

Copy link
Copy Markdown
Owner

The release function's failure result now says which step failed and the AWS error code, and a release whose rollout and pointer write completed no longer reports "failed" because of a lock it no longer holds.

Context: today's failed staging deploys

The fcvm staging deploy failed on its first attempt in fcvm runs 40261310012, 40265725881 and 40274465086 with {"status": "failed", "errorType": "RuntimeError"}, and a re-run returned "unchanged" with the new digest. That line is printed by fcvm's fleet/coord/publish.py, and its RuntimeError there was command failed: aws: CloudWatch metrics show each invocation still running when the CLI exited (309 s against 269 s, 272 s against 261 s, 320 s against about 272 s), then 2 throttles in the minute the CLI exited. The CLI's call ends about 260 s in, its own retries are throttled by reserved_concurrent_executions = 1, and it gives up while the release finishes. That client side is handled in ejc3/fcvm#1334. The function's logs (#696) would confirm that those invocations printed "deployed".

This PR is the function's half: the result names the failure, and the lock-handling defects below, found by reading the code, are fixed. They are not the cause of today's failures as far as the metrics show.

Failure result

{"status": "failed", "errorType": "ClientError", "step": "unlock", "code": "ConditionalCheckFailedException"}
  • step: credentials, input, lock, inspect, register, update, rollout, pointer, rollback or unlock. A rollback that succeeds reports the step that failed; an unlock that succeeds after a failure keeps the original step.
  • code: a botocore ClientError code, or for the release's own checks (Refused, a RuntimeError) one of service-unavailable, service-changed, rollout-failed, not-idle, pointer-mismatch. Present only when it is a plain token of at most 64 characters. Other exceptions (a botocore timeout, TimeoutError) carry only errorType and step.
  • Messages and SDK payloads are still never returned.

Lock defects

  • Unlock after a completed release. The finally DeleteItem is conditional on the release's Info token. If its first attempt deleted the lock and the reply was lost (read_timeout 15, botocore retries), the retry fails ConditionalCheckFailedException, the exception replaces the return, and a deployed release reports failed. The same happens when the lock was force-released, or force-released and taken, during the release. Now a refused delete leaves the lock alone, logs {"step": "unlock", "code": "ConditionalCheckFailedException", "lock": "absent" | "held by another owner"}, and the release's own result stands. A lock held by someone else is never deleted. Any other unlock error still fails with step "unlock", since the lock may still be held.
  • Lock write retried after it landed. The same retry hole on the conditional PutItem returned "busy" and left the release's own lock in the table, which blocks Terraform until a force-unlock. Both writes now pass ReturnValuesOnConditionCheckFailure=ALL_OLD; a refused put whose returned Info equals this release's token (a fresh uuid) owns the lock and proceeds. This uses no new IAM action: the parameter is part of PutItem and DeleteItem, and the policy sets no dynamodb:ReturnValues condition. If that is wrong, every release now reports "step": "lock", "code": "AccessDeniedException" instead of deploying, and nothing changes in ECS.
  • STS outside the handler's try. An assume_role error escaped as an unhandled function error, with its message in the Lambda error payload. It now returns the failure result with step "credentials".

Tests

$ python3 -S -B scripts/test-fcvm-coordinator-release.py
Ran 21 tests in 0.006s
OK

Against the previous release.py, 14 of the 21 fail: the lock tests (test_a_retried_unlock_whose_first_attempt_landed_reports_deployed, test_a_retried_lock_write_whose_first_attempt_landed_owns_the_lock, test_a_lock_taken_over_during_the_release_is_left_alone_and_the_release_reports_deployed) and every HandlerTests case. The fake DynamoDB returns the old item only when the request asks for ALL_OLD. test_the_lock_delete_checks_the_unique_owner is replaced by the take-over test: the lock is still never deleted, and the release now reports deployed instead of raising.

Apply

Lambda code only (fcvm-coordinator-release/release.py) plus a sentence in AGENTS.md. A targeted apply of aws_lambda_function.fcvm_coordinator_release is enough.

Summary by CodeRabbit

  • Bug Fixes
    • Release failures now report the failed step and available error codes, without exposing detailed error messages or SDK payloads.
    • Releases retain their deployment result if another process takes ownership of the lock during rollout.
    • Retried lock operations now handle cases where the original request succeeded but its response was lost.
    • Lock-release failures are reported when the lock is still held, while absent or differently owned locks no longer overwrite the release result.

…fail a release over a lock it no longer holds

The failure result now carries the step that raised (credentials, input, lock, inspect,
register, update, rollout, pointer, rollback, unlock) and, for a botocore ClientError or a
failed release check, its code. Codes are fixed tokens (AWS error codes, or the new
Refused checks: service-unavailable, service-changed, rollout-failed, not-idle,
pointer-mismatch). Messages and SDK payloads are still never returned.

Lock handling, from the code:
- The unlock's conditional DeleteItem is not idempotent under the SDK's retry. If the
  first attempt deleted the lock and its reply was lost, the retry failed
  ConditionalCheckFailedException and a release whose rollout and pointer write had
  completed returned "failed". The same happened when the lock was force-released (and
  possibly taken) while the release ran. Both now leave the lock alone, log
  {"step": "unlock", ...} and keep the release's own result.
- The lock's conditional PutItem had the same retry hole: a retry of a write that landed
  returned "busy" and left the release's own lock behind, blocking Terraform until a
  force-unlock. Both writes now ask for ReturnValuesOnConditionCheckFailure=ALL_OLD and
  compare the returned Info with the release's token.
- assume_role ran outside the handler's try, so an STS error escaped as an unhandled
  function error with its message. It now returns the failure result with step
  "credentials".
- A rollback that succeeds reports the step that failed, not "rollback"; an unlock that
  succeeds after a failure keeps the original step.

Tested: python3 -S -B scripts/test-fcvm-coordinator-release.py (21 tests, OK). Against
the previous release.py, 14 of them fail.
@coderabbitai

coderabbitai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ee7c5f55-84de-44d7-b443-2027fffb5209
Commits

Reviewing files that changed from the base of the PR and between 14dc560 and f626a76.

Files selected for processing: 3
  • AGENTS.md
  • fcvm-coordinator-release/release.py
  • scripts/test-fcvm-coordinator-release.py

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Walkthrough

The coordinator now tracks release steps, returns structured failure details, and handles lock retries and ownership changes. Deployment failures retain their original step across rollback. Tests cover lock behavior and handler results.

Changes: Coordinator release

Layer / File(s) Summary
Failure codes and progress tracking
fcvm-coordinator-release/release.py
Adds coded refusal errors and helpers for validated error codes. Initializes progress tracking for release steps.
Deployment and lock lifecycle
fcvm-coordinator-release/release.py, scripts/test-fcvm-coordinator-release.py
Tracks deployment steps, limits lock deletion to the release owner, and handles conditional-write retries and lock takeovers. Rollback preserves the original failure step. Tests cover lock retries and unlock failures.
Handler results and validation
fcvm-coordinator-release/release.py, scripts/test-fcvm-coordinator-release.py, AGENTS.md
The handler returns the failure step and a validated error code when available, including for credential failures. Tests cover handler failures and rollback results. The guidance describes failure fields and lock behavior.

Priority: Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

Merge Risk: Minimal · up to f626a

The coordinator release changes are ready to merge after normal checks; no unresolved issue is established.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 15.79% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 38 functions across 2 files. (1 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and specifically summarizes the main changes: reporting the failed step and error code, and avoiding release failure when the release no longer owns the lock.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 15.79% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 38 functions across 2 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-26T06:14:38.323845Z f626a76 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@ejc3

ejc3 commented Oct 26, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@ejc3

ejc3 commented Oct 26, 2026

Copy link
Copy Markdown
Owner Author

@greptileai review

@coderabbitai

coderabbitai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@ejc3
ejc3 merged commit a0b4939 into main Oct 26, 2026
3 checks passed
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