Skip to content

fix(recfilter): EC2 size flexibility and RDS Multi-AZ units in the duplicate guard - #576

Merged
cristim merged 5 commits into
mainfrom
fix/323-ec2-flex-rds-multiaz
Oct 20, 2026
Merged

cristim merged 5 commits into
mainfrom
fix/323-ec2-flex-rds-multiaz

Conversation

@cristim

@cristim cristim commented Oct 20, 2026

Copy link
Copy Markdown
Member

Closes #323

Remaining dedupe-key gaps in pkg/recfilter, by dimension:

Dimension Landed in
platform, tenancy #458 (fields), #460 (match), #465 (listing)
scope, AZ #460, #465
RDS size flexibility #564
EC2 size flexibility this PR
RDS Multi-AZ units this PR
account excluded by design (design note on #323: with RI sharing on, keying on account would let the guard buy duplicates)

What changes

  1. refactor(common): the EC2 normalization-factor table moves from pkg/exchange to common.EC2NormalizationFactor; pkg/exchange uses it, and exchange.NormalizationFactorForSize still works for providers. Metal stays absent (fix(exchange): reshape treats "metal" as a 192-unit size, producing nonexistent or oversized targets #552).
  2. fix(recfilter): regional Linux/Unix default-tenancy EC2 entries also join a family+region budget in normalized units, spent by recommendations that are exactly Linux/Unix and default tenancy. Zonal, other platforms, dedicated, metal and unknown sizes stay exact-type. Wildcard entries still suppress their exact type but never join the flex budget, and wildcard recommendations never spend it.
  3. fix(recfilter): for size-flexible RDS engines a Multi-AZ node counts as 2x units, and a Single-AZ recommendation also spends the Multi-AZ budget of its family. Single-AZ never covers Multi-AZ; exact-class engines (SQL Server, Oracle, Db2) keep their key.

Verification

Table tests for each rule; each rule has a mutation probe that makes a test fail (reverted). pkg build, vet, tests, -race on recfilter, golangci-lint and the git-secrets allowlist test pass with and without GOWORK=off; providers/aws builds, vets and passes the ec2 tests both ways.

Not required (left as follow-ups)

  • Rounding remainder in consume (a leftover budget below one rec-size node is not credited; conservative).
  • Renaming elastiCacheCover to a neutral name (cosmetic).
  • Missing RDS sizes (48xlarge, metal, tpc/mem suffixes) fall back to exact-class.

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

  • Run on-demand review

This review includes 11 billable files and costs up to $2.75.

  • Ask an admin to make reviews automatic

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Or wait 56 minutes for your next included review.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 88 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository: LeanerCloud/cloud-commitments-go/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: 382a3d52-edfa-4351-a8df-3e072a0577e9
📥 Commits

Reviewing files that changed from the base of the PR and between 1ce87bd and 7e86db9.

📒 Files selected for processing: 11
  • CHANGELOG.md
  • pkg/common/ec2_size.go
  • pkg/common/ec2_size_test.go
  • pkg/exchange/reshape.go
  • pkg/exchange/reshape_test.go
  • pkg/recfilter/dedupe.go
  • pkg/recfilter/dedupe_ec2.go
  • pkg/recfilter/dedupe_ec2_flex.go
  • pkg/recfilter/dedupe_ec2_flex_test.go
  • pkg/recfilter/dedupe_rds.go
  • pkg/recfilter/dedupe_rds_test.go
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

cristim and others added 5 commits October 20, 2026 12:50
The table lived in pkg/exchange; the duplicate guard in pkg/recfilter needs
it for EC2 size flexibility (#323), as it needs the RDS table from
pkg/common/rds_size.go. Export it as common.EC2NormalizationFactor and have
pkg/exchange use it. Metal stays absent (#552).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The EC2 dedupe keyed on the exact instance type, so a recent regional
Linux/Unix default-tenancy m5.xlarge reservation did not suppress an
m5.large recommendation and the guard could buy a duplicate (#323).

Such entries now also join a family and region budget in normalized units
(common.EC2NormalizationFactor), spent by recommendations that are exactly
Linux/Unix and default tenancy. Zonal, other platforms, dedicated tenancy,
metal and unknown sizes stay exact-type. Wildcard entries still suppress
their exact type but never join the flex budget, and wildcard
recommendations never spend it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dedupeKey includes the deployment, so a Multi-AZ size-flexible RDS
reservation never counted against Single-AZ demand of its family and the
guard could buy a duplicate (#323).

For size-flexible engines a Multi-AZ node now counts as twice the size
units on both sides, and a Single-AZ recommendation also spends the
Multi-AZ budget of its family after the Single-AZ one. Single-AZ still
does not cover Multi-AZ, and exact-class engines keep their key.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A flex entry's leftover units were rounded up to a whole node for the
exact-type path, so one xlarge reservation suppressed a large and an
xlarge recommendation (12 units from 8). The remaining units are now the
only state and the exact path spends whole nodes of floor(units / node).

AWS excludes G4ad, G4dn, G5, G5g, G6, G6e, G6f, Gr6, Gr6f, hpc7a, P5, Inf1,
Inf2, u7i-6tb and u7i-8tb from size flexibility; those families stay
exact-type (common.EC2SizeFlexibleFamily).

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

Size-flexible benefits apply to both deployment options, so a Single-AZ
reservation also pays for Multi-AZ demand at twice the units per node.
Single-AZ and Multi-AZ now share one family budget; any other deployment
(Aurora's empty one) keeps its own pool, and exact-class engines keep
their key.

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

cristim commented Oct 20, 2026

Copy link
Copy Markdown
Member Author

Gate note (claude-cc-libs)

Rebased onto main after the overlapping PRs merged. The only conflict was CHANGELOG.md, resolved by keeping both entries. Excluding CHANGELOG.md, git diff origin/main 7e86db9256077cf3c09f95f4b902f414ab6961eb is identical to the reviewed da95981e986d38a5a9fcdf03f0f84060d376f1ed diff apart from hunk line numbers. Re-verified on the combined tree: vet and go test -count=1 pass.

@cristim
cristim force-pushed the fix/323-ec2-flex-rds-multiaz branch from da95981 to 7e86db9 Compare October 20, 2026 10:52
@cristim

cristim commented Oct 20, 2026

Copy link
Copy Markdown
Member Author

Merge gate verdict (claude-cc-libs)

Every gate holds at head 7e86db9:

  • Two independent reviews approve the reviewed head 7e86db9. The branch was then updated from main, and the PR diff is byte-identical to the reviewed diff (compared mechanically).
  • CI is green on 7e86db9, which is the reviewed change on top of current main.
  • 0 unresolved threads; MERGEABLE/CLEAN.

CodeRabbit is waived as a merge gate under the 2026-10-19 decision. Squash-merging.

@cristim
cristim merged commit e858df6 into main Oct 20, 2026
15 checks passed
@cristim
cristim deleted the fix/323-ec2-flex-rds-multiaz branch October 20, 2026 11:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(recfilter): dedupe key lacks account, platform, tenancy, scope, AZ and size-flex

1 participant