Repository navigation
fix(config): canonicalise every AWS service alias in purchase suppressions - #1421
Conversation
…sions Rec rows persisted before slug normalisation still carry the legacy AWS slugs rds, elasticache, opensearch and redshift (see mapServiceSlug in internal/purchase/execution.go). A retried legacy execution writes a suppression under the legacy slug, current recs use relational-db, cache, search and data-warehouse, so the suppression missed the rec and allowed a double buy. Same shape as #1412 (ec2). memorydb has no canonical slug and non-AWS providers pass through unchanged. Closes #1420 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Canonicalization and suppression matching internal/config/types.go, internal/config/suppressions_build_test.go, internal/scheduler/scheduler_suppressions_test.go, internal/purchase/execution.go |
CanonicalSuppressionService maps ec2, rds, elasticache, opensearch, and redshift to canonical service slugs for AWS. Tests check idempotence, merged RDS suppression counts, matching in both directions, and distinct MemoryDB and Azure services. A comment directs contributors to update the canonicalization map when adding legacy AWS-only aliases. |
Priority:
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix · Severity of issue fixed: Medium
Possibly related issues
- fix(config): purchase suppressions miss recs stored under the other EC2 service slug #1412: This PR retains EC2 alias canonicalization and its suppression matching behavior.
Possibly related PRs
- LeanerCloud/cloud-commitments-platform#1419: This PR extends the
CanonicalSuppressionServiceadded in PR#1419.
Suggested labels: impact/internal, priority/p3, severity/low, urgency/this-quarter, effort/xs
Suggested reviewers: iamjsd
Merge Risk: 
Minimal · up to 6bfbc
-
No concrete merge-blocking risk was found in the reviewed change.
Pre-merge checks: 
5
-
Full details: Title check
-
Explanation
The title names the main change: canonicalizing AWS service aliases in purchase suppressions, in the config package. The raw summary and objectives show the PR extends CanonicalSuppressionService from ec2 only to ec2, rds, elasticache, opensearch, and redshift. The title says "every AWS service alias", which is slightly broader than the five slugs covered, but the PR objectives describe the same scope. The title is specific and matches the changeset, so it passes.
Full details: Linked Issues check
-
Explanation
Issue
#1420requires AWS alias pairs rds/relational-db, elasticache/cache, opensearch/search, and redshift/data-warehouse to canonicalise in purchase suppressions, with tests in both directions and unchanged Azure/GCP behaviour. The whole-PR diff of internal/config/types.go (merge base to head) shows the awsLegacyServiceSlugs map with ec2->compute, rds->relational-db, elasticache->cache, opensearch->search, and redshift->data-warehouse. CanonicalSuppressionService returns the input unchanged when provider is not aws. It also returns unchanged any service absent from the map, so memorydb passes through. The whole-PR diff of internal/purchase/execution.go changes only a comment that cross-references the new map, so mapServiceSlug behaviour is unchanged. The changes since the previous review (comment cross-references, test rename, and a BuildSuppressions merge test) do not alter the mapping logic. The incremental diff against the previous reviewed head was unavailable, so the test-file changes were confirmed only from the supplied summary. The previous PASS conclusion is still supported by the whole-PR code evidence. The issue's suggestion to derive the map from mapServiceSlug was an ideal, not a requirement; the explicit map with a cross-reference comment is accepted.
Full details: Out of Scope Changes check
-
Explanation
The whole-PR diff touches internal/config/types.go (suppression canonicalisation map and function), internal/purchase/execution.go (comment only), and related tests in internal/config and internal/scheduler. All code changes directly implement the
#1420alias canonicalisation and its non-AWS and memorydb passthrough behaviour. The changes since the previous review are comments, a test rename, and an added BuildSuppressions merge test for rds/relational-db, which serve the same objective. No unrelated product behaviour is present in the inspected evidence. The incremental test-file diff could not be read, so its content rests on the supplied summary.
-
Finishing Touches
-
📝 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.
|
Independent review 1 (cold, fresh context): VERDICT: APPROVE 9b6e470 Findings (no blocking issues): Attacked:
Nits 1-3 will land in a follow-up commit on this branch; that commit gets a delta review. |
…lias merge The legacy alias list lives in two places (mapServiceSlug and config.awsLegacyServiceSlugs); comments now point each at the other so a new alias is not added to only one. Rename the scheduler slug test to reflect that it covers all AWS legacy slugs, and add a BuildSuppressions case proving an rds rec and a relational-db rec merge into one canonical row (#1420). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Independent review 1, delta (same cold reviewer): VERDICT: APPROVE 6bfbc19 Delta 9b6e470..6bfbc19 (one commit, 4 files, +19/-4). No new findings.
|
|
Independent review 2 (claude-fleet, cold): APPROVE at 6bfbc19 Blocking items: none. Non-blocking items
Pair table (taken from pinned providers/aws@v0.0.0-20261020071945-92722e673741 provider.go:468-477 GetServiceClient and :434-453 GetSupportedServices) The PR adds no extra pairs. Only AWS is affected (types.go:782); Azure and GCP pass through, and tests cover that. On the canonical choice: the pinned AWS service clients emit the canonical slug for RDS, ElastiCache, OpenSearch and Redshift (for example services/rds/client.go:105 and redshift/client.go:92). EC2 still emits "ec2" (ec2/client.go:109), and #1419 already handles it. BuildSuppressions now writes the canonical slug to new rows (suppressions_build.go:35, the Service field). Legacy rows stored under either spelling still match, because aggregateSuppressions canonicalises the stored value on read (scheduler.go:1420), so no migration is needed. The #1411 empty-Details wildcard (suppressions_build.go:40-44) and the #1232 EC2 wildcard (:46-52) do not depend on the service spelling for the new pairs. The only reader is ListActiveSuppressions (store_postgres_suppressions.go:159), which reaches the scheduler only. No SQL filters on service: only execution_id deletes (store_postgres.go:909, store_postgres_suppressions.go:147). Consumer table at head
Probes (scratch export copy; each restored with cp, then cmp OK)
Commands and results
Reviewed by an independent agent with no author context (second reviewer). Review only: nothing was pushed, and the GitHub review state is unchanged. |
|
Local verification at
|
Closes #1420.
Problem: #1412 (#1419) made purchase suppressions match AWS
ec2andcomputeas the same service, but the other AWS legacy slugs were still compared literally. Rec rows persisted before slug normalisation still carryrds,elasticache,opensearchandredshift; that is whymapServiceSlugininternal/purchase/execution.gokeeps them. A retried legacy execution writes its suppression under the legacy slug. Current recs userelational-db,cache,searchanddata-warehouse, so the scheduler did not hide the rec that had just been bought, and it could be bought again.Change:
config.CanonicalSuppressionServicenow maps all five AWS legacy slugs to their canonical spelling through one map. memorydb has no canonical slug, and non-AWS providers pass through unchanged. Every existing call site already goes through this function (suppressionBucketOf,aggregateSuppressions,applySuppressionIndex), so no caller changes.Tests:
TestCanonicalSuppressionServiceis a 17-row table. It covers every legacy pair, idempotence on canonical input, memorydb passthrough, and Azure/GCP passthrough.TestApplySuppressions_EC2SlugSpellingsgains 10 rows: legacy suppression vs canonical rec and the reverse for each pair, memorydb not hiding a cache rec, and Azurerdsnot hiding arelational-dbrec.Local:
go build ./...passes.-racepasses on config, scheduler, purchase and api.-tags integrationpasses on config and scheduler (testcontainers Postgres).🤖 Generated with Claude Code
Summary by CodeRabbit
rdsandrelational-dbfor the same service are combined into one suppression, with their counts summed.