Summary
Pagination loops across the Azure and GCP provider clients are missing ctx.Err() checks between pages and have no maximum-page budget. This is the same failure shape fixed in PR #690 for the 7 AWS services -- discovered during the survey requested in #688.
All affected loops are unbounded and lack an early-exit on context cancellation. When running under a Lambda deadline these loops can eat the entire remaining budget before the SDK surfaces the cancellation error.
Affected locations
Azure -- for pager.More() { pager.NextPage(ctx) } without ctx.Err() check (smell #2)
providers/azure/services/compute/client.go:136 -- GetRecommendations
providers/azure/services/compute/client.go:171 -- GetExistingCommitments
providers/azure/services/compute/client.go:362 -- GetValidResourceTypes
providers/azure/services/cache/client.go:136 -- GetRecommendations
providers/azure/services/cache/client.go:170 -- GetExistingCommitments
providers/azure/services/cache/client.go:359 -- GetValidResourceTypes
providers/azure/services/database/client.go:138 -- GetRecommendations
providers/azure/services/database/client.go:172 -- GetExistingCommitments
providers/azure/services/cosmosdb/client.go:139 -- GetRecommendations
providers/azure/services/cosmosdb/client.go:173 -- GetExistingCommitments
providers/azure/services/cosmosdb/client.go:364 -- GetValidResourceTypes
providers/azure/services/search/client.go:136 -- GetRecommendations
providers/azure/services/search/client.go:170 -- GetExistingCommitments
providers/azure/services/search/client.go:358 -- GetValidResourceTypes
GCP -- iterator loops without ctx.Err() check (smell #2)
providers/gcp/services/computeengine/client.go:205 -- GetRecommendations iterator
providers/gcp/services/computeengine/client.go:247 -- GetExistingCommitments iterator
providers/gcp/services/computeengine/client.go:441 -- GetValidResourceTypes iterator
providers/gcp/services/cloudsql/client.go:163 -- GetRecommendations iterator
providers/gcp/services/memorystore/client.go:163 -- GetRecommendations iterator
providers/gcp/services/memorystore/client.go:203 -- GetExistingCommitments iterator
Minimum fix (small effort)
For each for pager.More() loop body, add at the top:
if err := ctx.Err(); err != nil {
return nil, fmt.Errorf("context cancelled during pagination: %w", err)
}
For each GCP for { it.Next() } loop body, same guard.
Add a const maxPages = 50 (or suitable value) page budget per loop with a warning log when hit, matching the pattern from PR #690.
Context
A separate issue covers the Azure Retail Prices API NextPageLink truncation (smell #5) in the same files -- that fix is larger and touches the HTTP-level pricing helpers.
Summary
Pagination loops across the Azure and GCP provider clients are missing
ctx.Err()checks between pages and have no maximum-page budget. This is the same failure shape fixed in PR #690 for the 7 AWS services -- discovered during the survey requested in #688.All affected loops are unbounded and lack an early-exit on context cancellation. When running under a Lambda deadline these loops can eat the entire remaining budget before the SDK surfaces the cancellation error.
Affected locations
Azure --
for pager.More() { pager.NextPage(ctx) }withoutctx.Err()check (smell #2)providers/azure/services/compute/client.go:136-- GetRecommendationsproviders/azure/services/compute/client.go:171-- GetExistingCommitmentsproviders/azure/services/compute/client.go:362-- GetValidResourceTypesproviders/azure/services/cache/client.go:136-- GetRecommendationsproviders/azure/services/cache/client.go:170-- GetExistingCommitmentsproviders/azure/services/cache/client.go:359-- GetValidResourceTypesproviders/azure/services/database/client.go:138-- GetRecommendationsproviders/azure/services/database/client.go:172-- GetExistingCommitmentsproviders/azure/services/cosmosdb/client.go:139-- GetRecommendationsproviders/azure/services/cosmosdb/client.go:173-- GetExistingCommitmentsproviders/azure/services/cosmosdb/client.go:364-- GetValidResourceTypesproviders/azure/services/search/client.go:136-- GetRecommendationsproviders/azure/services/search/client.go:170-- GetExistingCommitmentsproviders/azure/services/search/client.go:358-- GetValidResourceTypesGCP -- iterator loops without
ctx.Err()check (smell #2)providers/gcp/services/computeengine/client.go:205-- GetRecommendations iteratorproviders/gcp/services/computeengine/client.go:247-- GetExistingCommitments iteratorproviders/gcp/services/computeengine/client.go:441-- GetValidResourceTypes iteratorproviders/gcp/services/cloudsql/client.go:163-- GetRecommendations iteratorproviders/gcp/services/memorystore/client.go:163-- GetRecommendations iteratorproviders/gcp/services/memorystore/client.go:203-- GetExistingCommitments iteratorMinimum fix (small effort)
For each
for pager.More()loop body, add at the top:For each GCP
for { it.Next() }loop body, same guard.Add a
const maxPages = 50(or suitable value) page budget per loop with a warning log when hit, matching the pattern from PR #690.Context
A separate issue covers the Azure Retail Prices API
NextPageLinktruncation (smell #5) in the same files -- that fix is larger and touches the HTTP-level pricing helpers.