Skip to content

feat(commitmentopts/azure): probe Savings Plans offerings for live validation - #724

Merged
cristim merged 1 commit into
feat/multicloud-web-frontendfrom
feat/659-azure-sp-probe-live
May 27, 2026
Merged

feat(commitmentopts/azure): probe Savings Plans offerings for live validation#724
cristim merged 1 commit into
feat/multicloud-web-frontendfrom
feat/659-azure-sp-probe-live

Conversation

@cristim

@cristim cristim commented May 25, 2026

Copy link
Copy Markdown
Member

Closes #659.

Design

Azure has no catalog-listing endpoint (no Describe*Offerings equivalent), so the probe calls armbillingbenefits.RPClient.ValidatePurchase for each candidate (term, billingPlan) pair instead:

  • 6 candidates: P1Y / P3Y / P5Y × upfront (nil BillingPlan) / monthly (P1M)
  • A Valid=false response → "not offered, skip" (no error)
  • Any other API error aborts the probe and propagates (matches AWS all-or-nothing policy)
  • P5Y included up front and dropped at runtime if rejected — combos always reflect live API reality

Files

  • internal/commitmentopts/probe_azure.goAzureSPProber struct + AzureSPValidateAPI interface
  • internal/commitmentopts/probe_azure_test.go — 12 unit tests

Interface duplication note

AzureSPValidateAPI duplicates the one-method interface from providers/azure/services/savingsplans.RPValidateAPI — importing the provider package from internal/ would cause a circular dependency. A comment in the file documents this intentional duplication.

Deps

armbillingbenefits moved from // indirect to direct in go.mod (go mod tidy pre-commit hook handled).

Tests

  • internal/commitmentopts/...: 71 pass (59 pre-existing + 12 new)
  • go vet / gofmt / golangci-lint clean

Summary by CodeRabbit

  • New Features

    • Added discovery functionality for Azure Savings Plans contract terms (1, 3, and 5 years) and payment options (upfront and monthly).
  • Tests

    • Added comprehensive test coverage for Savings Plans discovery across all configuration scenarios and error conditions.

Review Change Stack

…lidation

Adds AzureSPProber to internal/commitmentopts, mirroring the AWS RI
probe pattern for Azure Savings Plans (term/payment validation).

Azure has no catalog-listing endpoint equivalent to AWS
Describe*Offerings, so the prober calls RPClient.ValidatePurchase for
each candidate (term, billingPlan) pair and retains those the API
accepts as live Combos. Candidate set: P1Y/P3Y/P5Y x upfront/monthly;
P5Y is dropped at runtime if ValidatePurchase rejects it so persisted
combos always reflect live API reality.

AzureSPValidateAPI is a one-method interface matching *armbillingbenefits.RPClient
so tests substitute a struct mock without touching the Azure RP.
DefaultAzureProbers() returns the default slice for service wiring.

Closes #659
@cristim cristim added triaged Item has been triaged priority/p3 Polish / idea / may never ship severity/low Minor harm urgency/eventually No deadline impact/few Limited audience effort/m Days type/feat New capability labels May 25, 2026
@coderabbitai

coderabbitai Bot commented May 25, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e3dd9184-34d7-4c38-8669-8d464a98b383

📥 Commits

Reviewing files that changed from the base of the PR and between 5abf40b and 24ee609.

📒 Files selected for processing (3)
  • go.mod
  • internal/commitmentopts/probe_azure.go
  • internal/commitmentopts/probe_azure_test.go

📝 Walkthrough

Walkthrough

This PR adds an Azure Savings Plans probe implementation to discover which term and billing plan combinations are accepted by Azure's Billing Benefits ValidatePurchase endpoint, alongside dependency setup and comprehensive test coverage.

Changes

Azure Savings Plans Probe

Layer / File(s) Summary
Dependency Management
go.mod
Azure SDK module armbillingbenefits is re-added at v1.0.0 as a direct require entry without the indirect marker.
Azure Savings Plans Probe Implementation
internal/commitmentopts/probe_azure.go
AzureSPProber iterates over candidate 1/3/5-year terms with all-upfront and monthly billing plan variants, constructs minimal SavingsPlanPurchaseValidateRequest payloads (placeholder subscription, USD, hourly grain, compute SKU), calls Azure's ValidatePurchase endpoint via injected AzureSPValidateAPI, interprets per-benefit Valid flags to determine accepted combos, and aborts on error. Exports Service(), ProbeAzure(), and DefaultAzureProbers() factory.
Comprehensive Test Coverage
internal/commitmentopts/probe_azure_test.go
Tests validate Service() returns savingsplans, ProbeAzure() behavior across happy paths (all/some/none valid combos, empty benefits, nil Valid flags), error handling (SDK errors, client construction failures), exact combo field values (Provider=azure, Service=savingsplans, TermYears, Payment), request term values, and billing plan logic (upfront combos omit BillingPlan, monthly combos set BillingPlan to P1M).

Sequence Diagram

sequenceDiagram
  participant Caller
  participant AzureSPProber
  participant client as AzureSPValidateAPI
  participant response as ValidatePurchase Response

  Caller->>AzureSPProber: ProbeAzure(ctx, cred)
  loop for each candidate combo (term, billingPlan)
    AzureSPProber->>AzureSPProber: probeCombo(term, billingPlan)
    AzureSPProber->>client: ValidatePurchase(SavingsPlanPurchaseValidateRequest)
    client-->>response: RPClientValidatePurchaseResponse
    AzureSPProber->>AzureSPProber: check per-benefit Valid flags
    AzureSPProber->>AzureSPProber: if any invalid, skip combo
  end
  AzureSPProber-->>Caller: []Combo with accepted combinations or error
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • LeanerCloud/CUDly#592: Implemented the Azure Savings Plans provider client and service dispatch; this PR adds the corresponding commitmentopts probe equivalent using the same Azure SDK ValidatePurchase API and armbillingbenefits module.
  • LeanerCloud/CUDly#63: Both PRs address the savingsplans service identifier; this PR's Azure prober hardcodes Service() to return savingsplans to match the frontend commitment config key.

Suggested labels

priority/p2, severity/medium, urgency/this-quarter

Poem

🐰 Azure probes flutter in, term by term so bright,
Validating plans with ValidatePurchase's might,
Upfront or monthly, each combo we test,
A prober's quest to find the very best!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 55.56% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ 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 concisely summarizes the main change: adding a probe for Azure Savings Plans offerings for live validation.
Linked Issues check ✅ Passed The PR implements all coding requirements from issue #659: a Savings Plans prober for Azure with live validation via the API, achieving parity with the existing AWS probe.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing the Azure Savings Plans probe (go.mod dependency update, prober implementation, and comprehensive tests), with no unrelated modifications.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/659-azure-sp-probe-live

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

@cristim

cristim commented May 25, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 25, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

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.

@cristim

cristim commented May 26, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 26, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

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.

@cristim

cristim commented May 26, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 26, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

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.

@cristim

cristim commented May 26, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 26, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

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.

@cristim

cristim commented May 26, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 26, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

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.

@cristim

cristim commented May 26, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 26, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

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.

@cristim

cristim commented May 26, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 26, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

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.

@cristim

cristim commented May 26, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 26, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

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.

@cristim

cristim commented May 26, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 26, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

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.

@cristim

cristim commented May 26, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 26, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

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.

@cristim

cristim commented May 26, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 26, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

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.

@cristim

cristim commented May 26, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 26, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

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.

@cristim

cristim commented May 26, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 26, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

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.

@cristim

cristim commented May 26, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 26, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

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.

@cristim

cristim commented May 26, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 26, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

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.

@cristim

cristim commented May 26, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 26, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

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.

@cristim
cristim merged commit a555151 into feat/multicloud-web-frontend May 27, 2026
5 checks passed
@cristim
cristim deleted the feat/659-azure-sp-probe-live branch June 3, 2026 21:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/m Days impact/few Limited audience priority/p3 Polish / idea / may never ship severity/low Minor harm triaged Item has been triaged type/feat New capability urgency/eventually No deadline

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant