Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/).

### Notices

- **Azure Redis purchases must go through managedredis (`ServiceMemoryDB`).**
The Azure recommendations adapter still labels Redis recommendations
`ServiceCache`, and the cache client now refuses every purchase (#538), so
route Azure Redis purchases to the managedredis client. The refusal wraps
`common.ErrRefusedBeforePurchase` (nothing was sent), not an upfront-approval
failure, so approving and retrying does not help.
- **Federation IaC bundles downloaded before 2026-04-22 need to be
re-downloaded** to get zero-touch registration. Older bundles silently
skip auto-registration unless manually edited (Terraform `registration.tf`
Expand Down Expand Up @@ -179,6 +185,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/).
### Changed

- **BREAKING `azure`:** Azure Redis recommendations now come only from managedredis and are labelled `memorydb` (`ServiceMemoryDB`), both from Consumption and from Advisor rows. The cache client's `GetRecommendations` returns none, so `GetRecommendationsForService(ServiceCache)` is empty for Azure, and consumers that stored Azure Redis plans or settings under `cache` must also match `memorydb`. Azure Redis recommendations keep `CacheDetails` `Engine` and `NodeType` but no longer report `Shards` (0, unknown) (#692).
- **`azure`:** the cache service no longer purchases Azure Redis reservations;
managedredis (`ServiceMemoryDB`) is the only service that buys `RedisCache`,
so one Redis recommendation cannot be bought once through each service.
`cache.PurchaseCommitment` now refuses before any API call with an error
wrapping `common.ErrRefusedBeforePurchase`. Consumers that buy an Azure
`ServiceCache` recommendation must route it to managedredis (#538).
- `ListTargetOfferings` now walks up to 50 pages (about 5000 offerings)
instead of 10, and returns an error wrapping the new
`ec2.ErrTargetOfferingsTruncated` (with no list) when that bound is hit,
Expand Down
6 changes: 3 additions & 3 deletions providers/azure/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ require (
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armsubscriptions v1.3.0
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/search/armsearch v1.4.0
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/sql/armsql v1.2.0
github.com/LeanerCloud/cloud-commitments-go/pkg v0.0.0-20261026141505-6c5673cd5518
github.com/LeanerCloud/cloud-commitments-go/pkg v0.0.0-20261104063122-3efa339480ac
github.com/stretchr/testify v1.12.1
golang.org/x/sync v0.24.0
)

require (
github.com/Azure/azure-sdk-for-go/sdk/internal v1.13.0 // indirect
github.com/AzureAD/microsoft-authentication-library-for-go v1.10.1 // indirect
github.com/aws/aws-sdk-go-v2 v1.41.5 // indirect
github.com/aws/smithy-go v1.24.2 // indirect
github.com/aws/aws-sdk-go-v2 v1.47.4 // indirect
github.com/aws/smithy-go v1.28.6 // indirect
github.com/golang-jwt/jwt/v5 v5.3.1 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/kylelemons/godebug v1.1.0 // indirect
Expand Down
12 changes: 6 additions & 6 deletions providers/azure/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ github.com/AzureAD/microsoft-authentication-extensions-for-go/cache v0.1.1 h1:WJ
github.com/AzureAD/microsoft-authentication-extensions-for-go/cache v0.1.1/go.mod h1:tCcJZ0uHAmvjsVYzEFivsRTN00oz5BEsRgQHu5JZ9WE=
github.com/AzureAD/microsoft-authentication-library-for-go v1.10.1 h1:0O6j18nQDoIff6/mtosT5LNU2WehEwp+LqfX6699oqY=
github.com/AzureAD/microsoft-authentication-library-for-go v1.10.1/go.mod h1:xdYAf5bjkOpsd3auA8riiJW4vneBubt9caavL7626jQ=
github.com/LeanerCloud/cloud-commitments-go/pkg v0.0.0-20261026141505-6c5673cd5518 h1:2wyUUf+lBH+Qo3ULGiHOhn9drt+WyqLoR8fV/3q21a0=
github.com/LeanerCloud/cloud-commitments-go/pkg v0.0.0-20261026141505-6c5673cd5518/go.mod h1:rEJErEsL40Np/ttf0RDoNNC2XQsN1GmWyFf34y0JLD8=
github.com/aws/aws-sdk-go-v2 v1.41.5 h1:dj5kopbwUsVUVFgO4Fi5BIT3t4WyqIDjGKCangnV/yY=
github.com/aws/aws-sdk-go-v2 v1.41.5/go.mod h1:mwsPRE8ceUUpiTgF7QmQIJ7lgsKUPQOUl3o72QBrE1o=
github.com/aws/smithy-go v1.24.2 h1:FzA3bu/nt/vDvmnkg+R8Xl46gmzEDam6mZ1hzmwXFng=
github.com/aws/smithy-go v1.24.2/go.mod h1:YE2RhdIuDbA5E5bTdciG9KrW3+TiEONeUWCqxX9i1Fc=
github.com/LeanerCloud/cloud-commitments-go/pkg v0.0.0-20261104063122-3efa339480ac h1:EvEUCt1uH5oBtPcJJPt1mX6XYQWAKtL9QBSo9CfeaOw=
github.com/LeanerCloud/cloud-commitments-go/pkg v0.0.0-20261104063122-3efa339480ac/go.mod h1:pseCFRgm1rzBKomktjw6E0ayxmVE7XfHHiOmew4ka+g=
github.com/aws/aws-sdk-go-v2 v1.47.4 h1:bTvk6UdSSSvaQsfLVj1JRDEEqj/PDRwGf1KanaRzau0=
github.com/aws/aws-sdk-go-v2 v1.47.4/go.mod h1:XkrjAZvr705Nytv6PkPUhoSB2W9+vVHBp5oAWpkh8Ak=
github.com/aws/smithy-go v1.28.6 h1:Pj+/sUviNYjow8ELRtNwKHZ9ECeF+7pATX3+shjLIrw=
github.com/aws/smithy-go v1.28.6/go.mod h1:YE2RhdIuDbA5E5bTdciG9KrW3+TiEONeUWCqxX9i1Fc=
github.com/golang-jwt/jwt/v5 v5.3.1 h1:kYf81DTWFe7t+1VvL7eS+jKFVWaUnK9cB1qbwn63YCY=
github.com/golang-jwt/jwt/v5 v5.3.1/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
Expand Down
80 changes: 6 additions & 74 deletions providers/azure/services/cache/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/Azure/azure-sdk-for-go/sdk/azcore"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/redis/armredis/v3"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/reservations/armreservations"

"github.com/LeanerCloud/cloud-commitments-go/pkg/common"
"github.com/LeanerCloud/cloud-commitments-go/providers/azure/internal/httpclient"
Expand Down Expand Up @@ -201,79 +200,12 @@ func (c *Client) convertRedisReservation(detail *armconsumption.ReservationDetai
return commitment
}

// PurchaseCommitment purchases Redis Cache reserved capacity using the two-step
// calculatePrice->purchase flow required by Azure's Reservations API (issue #677).
func (c *Client) PurchaseCommitment(ctx context.Context, rec common.Recommendation, opts common.PurchaseOptions) (common.PurchaseResult, error) {
result := common.PurchaseResult{
Recommendation: rec,
DryRun: false,
Success: false,
Timestamp: time.Now(),
}

// Source is required so the resulting reservation is attributable to CUDly
// in the portal via the purchase-automation tag. The dedupe key for
// idempotent re-drives is now opts.IdempotencyToken (issue #721, applied
// in reservations.DoIdempotentPurchaseTwoStep); source remains mandatory
// for attribution.
if opts.Source == "" {
result.Error = fmt.Errorf("purchase source is required for Azure reservation purchases")
return result, result.Error
}
if strings.TrimSpace(rec.ResourceType) == "" {
result.Error = fmt.Errorf("resource type is required")
return result, result.Error
}
if rec.Count <= 0 {
result.Error = fmt.Errorf("quantity must be greater than zero, got %d", rec.Count)
return result, result.Error
}

termYears, termErr := reservations.ParseTermYears(rec.Term)
if termErr != nil {
result.Error = termErr
return result, result.Error
}
if _, termEnumErr := reservations.ReservationTermForYears(termYears); termEnumErr != nil {
result.Error = termEnumErr
return result, result.Error
}
billingPlan, billingPlanErr := reservations.BillingPlanForPaymentOption(rec.PaymentOption)
if billingPlanErr != nil {
result.Error = billingPlanErr
return result, result.Error
}

bodyBytes, err := reservations.BuildPurchaseBody(reservations.PurchaseParams{
ReservedResourceType: string(armreservations.ReservedResourceTypeRedisCache),
DisplayName: func(r common.Recommendation) string {
return reservations.BuildDisplayName(reservations.DisplayNameFields{
Service: "redis",
Region: c.region,
ResourceType: r.ResourceType,
Count: r.Count,
Term: r.Term,
Payment: r.PaymentOption,
Now: time.Now(),
})
},
}, rec, opts, c.region, c.subscriptionID, billingPlan)
if err != nil {
result.Error = fmt.Errorf("failed to marshal request: %w", err)
return result, result.Error
}

reservationOrderID, existing, err := reservations.Submit(ctx, c.cred, c.httpClient, bodyBytes, opts, rec.CommitmentCurrency)
if err != nil {
result.Error = err
return result, result.Error
}

result.Success = true
result.ExistingCommitment = existing
result.CommitmentID = reservationOrderID
result.Cost = reservations.UpfrontCostForBillingPlan(billingPlan)
return result, nil
// PurchaseCommitment refuses: managedredis (ServiceMemoryDB) is the only Azure service that
// buys RedisCache reservations (#538), so one Redis recommendation cannot be bought twice.
func (c *Client) PurchaseCommitment(_ context.Context, rec common.Recommendation, _ common.PurchaseOptions) (common.PurchaseResult, error) {
err := fmt.Errorf("%w: Azure Redis reservations are purchased through the %s service, not %s",
common.ErrRefusedBeforePurchase, common.ServiceMemoryDB, common.ServiceCache)
return common.PurchaseResult{Recommendation: rec, Timestamp: time.Now(), Error: err}, err
}

// ValidateOffering validates that a Redis Cache SKU exists.
Expand Down
Loading
Loading