Skip to content

chore(deps): bump cloud-commitments-go pins to 9dae64b and adapt archera key - #805

Merged
cristim merged 1 commit into
mainfrom
chore/791-bump-go-pins
Oct 12, 2026
Merged

cristim merged 1 commit into
mainfrom
chore/791-bump-go-pins

Conversation

@cristim

@cristim cristim commented Oct 12, 2026 •

Copy link
Copy Markdown
Member

Bumps pkg and providers/aws|azure|gcp to cloud-commitments-go main 9dae64b216d4 (all four at v0.0.0-20261012130811-9dae64b216d4), plus the one adaptation the new API needs.

Refs #791. Left open on purpose: #792 (AZ-scoped EC2 recs: purchase guard, idempotency key, recommendations natural key, cross-account AZ gaps) is the immediate follow-up. Going ahead first is safe because a zonal rec without an AZ now fails closed instead of buying in an arbitrary AZ.

What reaches the platform

Tests

  • TestClient_KeyWithTrailingNewlineIsTrimmed (fails without the trim).
  • internal/purchase/zonal_az_test.go: AZ reaches the service client; real ec2.Client over a stub API refuses an AZ-less zonal row with "re-fetch" and makes no offering lookup or purchase call (does not compile on the old pin).
  • Scheduler: converted zonal rec keeps availability_zone in the stored blob. API: 502 with the "re-fetch" message (fixture error).

Verification (macOS, fixture/mock-based, not real-account)

GOWORK=off go build/vet, go test ./..., make tidy-check, make lint all pass. No live cloud calls, purchases or deploys.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Zonal EC2 purchases now retain the recommended Availability Zone. If a zonal recommendation is missing its Availability Zone, the purchase stops before proceeding and prompts you to re-fetch the recommendation.
    • Zonal recommendation refusals caused by a missing Availability Zone now return a 502 error with a re-fetch instruction.
    • API keys with surrounding whitespace, including a trailing newline, are now accepted when connecting to Archera.

…era key

Bumps pkg and providers/aws|azure|gcp to 9dae64b216d4. The Archera key is now an
insurance.Secret and is trimmed, since the library rejects non-printable key
bytes such as a trailing newline. Adds tests for the zonal EC2 AZ path (kept AZ
reaches the service client; AZ-less stale row fails closed) and the key trim.

Refs #791

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@cristim cristim added urgency/this-sprint Within the current sprint effort/l Weeks type/chore Maintenance / non-user-visible priority/p1 Next up; this sprint severity/high Significant harm impact/all-users Affects every user triaged Item has been triaged labels Oct 12, 2026
@coderabbitai

coderabbitai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: LeanerCloud/cloud-commitments-platform/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: 63c10d69-e918-4bfb-b9be-dffc449eb591

📥 Commits

Reviewing files that changed from the base of the PR and between 0a76043 and 59ee199.


⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum

📒 Files selected for processing (6)
  • go.mod
  • internal/api/purchase_pricing_test.go
  • internal/archera/provider.go
  • internal/archera/provider_test.go
  • internal/purchase/zonal_az_test.go
  • internal/scheduler/recommendation_identity_test.go

Included review availability: This review used your included allowance. 0 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 1 review per hour.



📝 Walkthrough
📝 Walkthrough

Walkthrough

The pull request aligns four cloud-commitments-go module versions, trims whitespace from resolved Archera API keys, and adds tests for zonal EC2 recommendation serialization, purchase handling, and refusal error mapping.

Changes

Module version update

Layer / File(s) Summary
Align cloud-commitments-go versions
go.mod
The pkg and AWS, Azure, and GCP provider modules now use version v0.0.0-20261012130811-9dae64b216d4.

Archera API key handling

Layer / File(s) Summary
Trim the resolved key before client creation
internal/archera/provider.go, internal/archera/provider_test.go
Provider.Client trims whitespace from the resolved key before building the client. A test checks client construction and comparison with a key ending in a newline.

Zonal EC2 recommendation and purchase coverage

Layer / File(s) Summary
Check availability-zone serialization
internal/scheduler/recommendation_identity_test.go
A test checks that a converted zonal EC2 recommendation includes its availability zone in serialized details.
Check zonal purchase handling
internal/purchase/zonal_az_test.go
Tests check that purchase handling passes a recorded availability zone to PurchaseCommitment and rejects a zonal record without a zone before offering lookup or purchase.
Check zonal refusal error mapping
internal/api/purchase_pricing_test.go
A test checks that a zonal-scope refusal without an availability zone maps to status 502 and includes a re-fetch instruction.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Other


Merge Risk: ⚪ Minimal · up to 59ee1

This PR aligns the cloud-commitments-go pins, trims whitespace from the resolved Archera key, and adds focused zonal recommendation and purchase coverage. The inspected paths show availability zones are preserved and stale records fail closed; no concrete merge-blocking regression is established.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 54.55% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 5 files. (1 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly summarizes the main changes: updating cloud-commitments-go dependency pins and adapting the Archera API key handling.

Full details: Docstring Coverage

Explanation

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


  • Fix all pre-merge checks with AI
✨ 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

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

@cristim

cristim commented Oct 12, 2026

Copy link
Copy Markdown
Member Author

Gate review (Opus), head 59ee199, finding F1 (PR body accuracy, non-blocking for code):
The body says go#320 (FixedPrice fix) "changes the EC2 cost recorded after purchase (UpfrontCost in purchase history)". In the aws delta bcc0dfc..9dae64b, PurchaseCommitment's cost math is unchanged: math.Round(FixedPrice*100)*Count/100 was only extracted into fixedPriceCents (go providers/aws/services/ec2/client.go hunk @@ -180). The real go#320 changes are in GetOfferingDetails for all six AWS RI services, which the platform never calls. Suggest: "go#320: no effect on the platform (purchase-result cost math unchanged; GetOfferingDetails unused)".

@cristim

cristim commented Oct 12, 2026

Copy link
Copy Markdown
Member Author

Gate verdict (independent adversarial review, Opus): PASS at 59ee199

Pins. All four modules at v0.0.0-20261012130811-9dae64b216d4 = go main HEAD (#339). Providers' own go.mod require pkg 30bf383; MVS resolves to 9dae64b (GOWORK=off go list -m all). No replace/exclude. go mod download of all four + go mod verify: sums match go.sum. Base 0a76043 = origin/main (not behind).

Library delta reviewed (old pins 73d3366/bcc0dfc/e24345c/2c18f30, all ancestors of 9dae64b): EC2 zonal-without-AZ and regional-with-AZ refused before any lookup ("re-fetch"); CE parser sets scope zonal iff trimmed AZ non-empty and stores the trimmed AZ, so the contradiction branch is unreachable from collected recs. Platform persists the full blob (scheduler marshalRecDetails -> MarshalServiceDetails; execution.go decode -> recommendation.Details), availability_zone json tag present. Detail-parse failures (new invalid-average check d9ead42) go into IncompleteRecommendationsError, tolerated by tolerateIncompleteSweep with eviction withheld. RDS: exact match across all pages, ambiguity error, Oracle/SQL Server refused. EC2 purchase cost math unchanged (refactor only). Azure SP billingScopeID() yields the same /subscriptions/<id> string; inventory changes are only in GetExistingCommitments. grep: platform never calls GetExistingCommitments, recfilter, GetOfferingDetails, GetRICoverageMap; common.ErrOutcomeUnknown unused. Suppression claim holds (saveTerminalExecution releases only on beforeSubmissionError).

Archera trim. Library rejects every byte < 0x21 or > 0x7e, so inner whitespace can never be a valid key; the trimmed value is the only Secret built (single site), and the library error names a byte position, never the key.

Fails-before / mutants (fresh git archive copies; library mutants via local replace to a 9dae64b clone; M0 baseline with the replace passes):

  • M1 revert TrimSpace: trailing-newline test FAILS ("archera API key could not be resolved"). M10 TrimLeft(" "): FAILS.
  • M2 lib refusal removed (old-pin behaviour): stale-row test FAILS ("no offerings found ... does not contain re-fetch"; lookups 1).
  • M3 lib AZ not serialised (old blob shape): zonal passthrough test FAILS (expected us-east-1b, actual ""), scheduler blob test FAILS.
  • M4 decoded details not attached: both purchase tests FAIL. M5 scheduler persists no blob: FAILS. M6 502->500: FAILS. M7 message drops cause: FAILS. M8 refusal text without "re-fetch": FAILS. M9 zonal-no-AZ downgraded to regional: FAILS (lookup made).

Local verification (macOS, go1.26.9, GOWORK=off, exact head via git archive): go build ./..., go vet ./..., go test ./... exit 0; make tidy-check pass; go test -tags integration (testcontainers Postgres) for internal/purchase, scheduler, api, server, archera: all ok. Lint via CI (Lint Code pass). CI all green, mergeStateStatus CLEAN, labels mirror #791. Evidence is fixture/mock-based (stub EC2 API, env resolver, httptest); no real-account purchase or Archera call, labelled honestly in the body.

Findings. F1 (body said go#320 changes post-purchase EC2 cost; it does not): body corrected. No code findings.

Owner note. #791's comment and #792 say the bump is blocked on #792. Independent check: the bump does not regress any #792 item vs the old pin (old code bought zonal RIs in an arbitrary AZ; now it buys in the rec's AZ or fails closed). #792 items 1 (detail guard ignores AZ) and 4 (per-account AZ names) remain open and are the immediate follow-up.

@cristim
cristim merged commit 6dc774b into main Oct 12, 2026
25 checks passed
cristim added a commit that referenced this pull request Oct 12, 2026
…mpotency key and rec ID (#807)

* fix(purchase): make zonal EC2 AZ part of the guard, identity key, idempotency key and rec ID

Zonal EC2 recs now keep their availability zone (#805) but three purchase
paths ignored it:
- computeDetailMismatch refuses a re-matched rec whose AZ differs from, or
  is unknown against, a known origin AZ.
- recIdentityKey adds the AZ so the stored-rec index and pricing resolve
  the requested zone instead of an arbitrary one.
- the 2-minute submit idempotency key reads the AZ from the rec Details
  (also present on rows written before this change), so two submits that
  differ only by AZ no longer collapse into one execution. A candidate whose
  key cannot be derived is skipped with an error log.

The scheduler stamps the new RecommendationRecord.AvailabilityZone and
appends it to the rec ID only for zonal recs (regional IDs unchanged). AZ
names are per account, so zonal EC2 recs that Cost Explorer computed for a
member account other than the collecting one are dropped with a warning.

Refs #792

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* test(scheduler): cover zonal EC2 foreign-account drop at the collection path

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* style(scheduler): name partitionForeignZonalEC2 results

---------

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/l Weeks impact/all-users Affects every user priority/p1 Next up; this sprint severity/high Significant harm triaged Item has been triaged type/chore Maintenance / non-user-visible urgency/this-sprint Within the current sprint

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant