Repository navigation
fix(aws/ec2): refuse a re-drive when several RIs carry the idempotency token - #733
Conversation
…y token findRIByIdempotencyToken returned the first tagged active or payment-pending RI, so a second RI carrying the same token (a retry whose tag lookup missed the earlier RI, so it bought and tagged another) was silently ignored and a prior double-buy stayed hidden. The lookup now fails closed when more than one RI with an ID carries the token: no adoption, no purchase, and an error that wraps ErrRefusedBeforePurchase, names the count and the masked token and says a human must reconcile. A single match still adopts, zero matches still buys, and entries without an ID are ignored. Closes #724 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
What
A re-driven EC2 purchase adopts the RI tagged with its idempotency token.
findRIByIdempotencyTokenreturned the first match, so if two active or payment-pending RIs carried the same token (a retry whose tag lookup missed the earlier RI, so it bought and tagged a second one) the re-drive reported the first and nothing told anyone a second commitment existed.It now fails closed when more than one RI with an ID carries the token: no adoption, no purchase, and an error that wraps
common.ErrRefusedBeforePurchase, names the count and the masked token, and says the commitment state is ambiguous and needs a human to reconcile. A single match still adopts, zero matches still buys, entries without an ID are ignored, retired RIs stay excluded by the state filter.Decisions
ErrRefusedBeforePurchase, notErrOutcomeUnknown: this call sent no purchase request. The platform never reads the former, so the error surfaces as an ordinary failed recommendation with the "needs a human" text in History and no automatic retry loop.DescribeReservedInstancesdoes not paginate, so a second RI cannot hide on another page. The reconcile path already returns Unknown with ambiguous candidates for two matches.Verification
go test -race ./services/ec2/(providers/aws),golangci-lint --new-from-rev=origin/main0 issues.Closes #724
🤖 Generated with Claude Code
Summary by CodeRabbit