Skip to content

fix(providers): mark reported costs as known and stop inventing Azure inventory region and state - #713

Open
cristim wants to merge 10 commits into
mainfrom
fix/74-cost-known-producers
Open

cristim wants to merge 10 commits into
mainfrom
fix/74-cost-known-producers

Conversation

@cristim

@cristim cristim commented Nov 7, 2026

Copy link
Copy Markdown
Member

Closes #74. This is PR 2. PR 1 (#689) added common.Commitment.CostKnown to pkg.

What

  • Pin: providers/aws and providers/azure now pin pkg at 8d06fde (feat(common): add Commitment.CostKnown #689).
    • The azure re-pin moves aws-sdk-go-v2 to v1.47.5 and smithy-go to v1.28.7 transitively. Both are forced by MVS from pkg's go.mod, and azure reaches them only through pkg/provider.
    • A follow-up commit tidies the azure go.sum.
  • AWS ladder: riToCommitment sets CostKnown only when the RI has a Duration. Without one, riHourlyCost can't amortize the upfront part, and the listing maps missing price pointers to 0. spToCommitment sets CostKnown: true, because the SP amount comes straight from the API, and a real 0 counts as known.
  • Azure savings plans: a reported Commitment.Amount, including 0, is marked known. A nil amount stays unknown.
  • Azure inventory: the cache, cosmosdb, database, search and synapse reservation converters stop inventing Region: c.region and State: Active. Consumption ReservationDetail carries neither field, so both are now "" (unknown). managedredis already reads real data since fix(azure): dedupe Redis recommendations against held reservations #706.
  • Docs: the stale inventory.go comment now says Cost is unknown and CostKnown stays false, so a zero must not be read as free.

Behaviour notes

  • Dedupe is unaffected for the five converters. Their StartDate is zero, so recfilter.isRecentActiveCommitment excludes them, before and after this change.
  • Each listed commitment from those converters now logs one WARNING in recfilter, for its unrecognized empty State. The plan's change to silence it was dropped: fix(azure): dedupe Redis recommendations against held reservations #706's strict inventory path relies on "" meaning an unknown provisioning state. feat(common): add Commitment.CostKnown #689's squash message, which says empty State is "counted without logging", is inaccurate. No recfilter change has landed.
  • Residual (follow-up): the ec2 listing turns nil pricing pointers into 0, so an RI with a Duration but a missing FixedPrice can't be told apart from a no-upfront RI.
  • Residual (follow-up): Commitment has no currency field, so non-USD amounts aren't flagged.

Verification

  • Tests first:
    • a zero-HourlyCommitmentUSD SP;
    • a fully-upfront RI with a Duration (known, Cost > 0) and one without a Duration (unknown);
    • an ec2 listing test pinning unknown cost;
    • savings plans with amount 0, nil amount and nil commitment;
    • a shared AssertUnknownInventory helper, reused by the 5 converter tests, run for both eastus and westeurope client regions.
  • Deletion probes: putting back the invented Region or State fails each converter test. Setting CostKnown unconditionally fails the RI and savings plan tests.
  • Rebased onto current main:
    • aws: go test -p 2 -short ./... gives 15 ok;
    • azure: 14 ok;
    • golangci-lint: 0 issues in both.
  • Reviews: two adversarial task-review passes covering the whole branch. Pass 1 found that the RI with no Duration was wrongly marked known. That's fixed, and pass 2 was clean.

🤖 Generated with Claude Code

cristim and others added 10 commits November 7, 2026 03:07
Re-pin providers/aws and providers/azure to pkg 8d06fde (#689) so
the producers can set Commitment.CostKnown. Azure also moves aws-sdk-go-v2
and smithy-go via MVS.

Refs #74

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
riToCommitment and spToCommitment compute Cost from provider data, so set
CostKnown. A zero cost is now distinguishable from unknown. EC2 listing
stays unknown, pinned by a test.

Refs #74

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
convertSavingsPlan assigns Cost from Commitment.Amount, so set CostKnown in
that branch. A reported 0 is now distinguishable from an absent amount.

Refs #74

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The consumption ReservationDetail API reports neither, so the cache inventory
converter left them to the client region and a hardcoded active. Leave them
empty (unknown). Adds a shared RequireUnknownInventory test helper.

Refs #74

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Same as the cache converter: ReservationDetail reports neither, so leave
Region and State empty instead of the client region and active.

Refs #74

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Same as the cache converter: leave Region and State empty because
ReservationDetail does not report them.

Refs #74

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Drop the stale issue #62 reference and the no-consumer-reads-Cost claim.
Cost is unknown here, CostKnown stays false, and zero is not free.

Refs #74

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
riHourlyCost skips upfront amortization without a Duration, so an RI with
missing pricing data got a partial cost yet claimed CostKnown. Gate the
marker on Duration > 0 and replace the misleading zero-cost test.

Refs #74

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tory

The helper uses assert, so it does not stop the test; name it accordingly.

Refs #74

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Drops the go.sum lines for the old pkg, aws-sdk-go-v2 and smithy-go
versions that the rebased pin no longer needs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cristim cristim added triaged Item has been triaged urgency/this-sprint Within the current sprint priority/p1 Next up; this sprint severity/high Significant harm impact/many Affects most users effort/m Days type/bug Defect labels Nov 7, 2026
@coderabbitai

coderabbitai Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 26 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 5dcf711 and 93a29ee.

Files ignored due to path filters: 2

  • providers/aws/go.sum is excluded by !**/*.sum
  • providers/azure/go.sum is excluded by !**/*.sum
Files selected for processing: 19

  • providers/aws/go.mod
  • providers/aws/ladder/commitments.go
  • providers/aws/ladder/commitments_test.go
  • providers/aws/services/ec2/client_test.go
  • providers/azure/go.mod
  • providers/azure/services/cache/client.go
  • providers/azure/services/cache/client_test.go
  • providers/azure/services/cosmosdb/client.go
  • providers/azure/services/cosmosdb/client_test.go
  • providers/azure/services/database/client.go
  • providers/azure/services/database/client_test.go
  • providers/azure/services/internal/reservations/inventory.go
  • providers/azure/services/internal/reservations/reservationstest/inventory.go
  • providers/azure/services/savingsplans/client.go
  • providers/azure/services/savingsplans/client_test.go
  • providers/azure/services/search/client.go
  • providers/azure/services/search/client_test.go
  • providers/azure/services/synapse/client.go
  • providers/azure/services/synapse/client_test.go
  • 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/m Days impact/many Affects most users priority/p1 Next up; this sprint severity/high Significant harm triaged Item has been triaged type/bug Defect urgency/this-sprint Within the current sprint

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(azure): commitments fabricate State "active" and Region from fields the SDK omits

1 participant