Repository navigation
Description
Implement after the Azure deploy pause. Azure deploys are paused, and the platform keeps refusing Azure Savings Plan re-drives until this lands and is adopted, so there is no rush.
Background
LeanerCloud/cloud-commitments-platform#838 asks the owner to choose for Azure Savings Plans: (a) refuse re-drives (automatic retries of a stuck purchase) forever, or (b) add server-side dedupe upstream. This issue records the design for (b).
On main (86907ad), Client.PurchaseCommitment (providers/azure/services/savingsplans/client.go:359) derives the order alias name from the platform's retry token (common.OrderIDFromToken, :383). It then PUTs straight away with BeginCreate (:395). The code comment assumes a second PUT of the same alias returns the first order instead of buying again, but that is unproven. LeanerCloud/cloud-commitments-platform#1305 (merged) only pins today's behavior with a test, and the platform still refuses Azure SP re-drives, so the platform is safe today.
Proposal: look up the alias before buying
Only when opts.IdempotencyToken is set:
- GET the order alias by name first.
- 200 with provisioning state Succeeded: reuse it. Return that order's id with no PUT.
- 404: create it with
BeginCreate, as today. - A non-terminal provisioning state, or any other error: fail without buying, with an error that tells the caller to check the portal.
- Without a token, behave as today.
Implementation notes:
- Add
GettoSavingsPlanOrderAliasAPIandrealOrderAliasClient(armbillingbenefitsv1.0.0 hasSavingsPlanOrderAliasClient.Get). - When feat(exchange)!: PurchaseResult needs an already-existed signal for idempotent re-drives #211 lands, set its "already existed" signal on the reuse branch.
Acceptance criteria
- One mock test per branch: 200 Succeeded (assert
BeginCreateis never called), 404 (assertBeginCreateis called once), non-terminal state (noBeginCreate, error), other error (noBeginCreate, error). - No change to the token-less path.
- After this is released: a platform
go.modbump, plus a platform PR that drops the Azure SP re-drive refusal (Provider duplicate-purchase proof matrix: Azure Savings Plans has no server-side dedupe cloud-commitments-platform#838). - Proving how live Azure answers the alias GET and a repeated PUT needs a real subscription and could buy a real plan. That is for the owners to decide and do, in a sandbox, and is not part of this issue's tests.
Refs LeanerCloud/cloud-commitments-platform#838, LeanerCloud/cloud-commitments-platform#1305, #211.
Filed by IAmJSD's agent at IAmJSD's request (acting owner while the maintainers are away).
Activity