fix(no-anti-affinity): support topology spread constraints#1224
fix(no-anti-affinity): support topology spread constraints#1224mwozniakk wants to merge 2 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Central YAML (base), Organization UI (inherited) Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughSummary by CodeRabbit
WalkthroughThe anti-affinity checker now treats matching ChangesTopologySpreadConstraints support
Estimated code review effort: 2 (Simple) | ~12 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pkg/templates/antiaffinity/template_test.go`:
- Around line 135-152: Add a focused test covering TopologySpreadConstraints
with WhenUnsatisfiable set to ScheduleAnyway in the AntiAffinityTestSuite
helpers and related deployment setup. The current
addDeploymentWithTopologySpreadConstraint path only exercises DoNotSchedule, so
extend the test suite with a case that uses ScheduleAnyway and asserts the
intended behavior in topologySpreadConstraintsMatchAgainstNodes and the
deployment validation flow. Use the existing
addDeploymentWithTopologySpreadConstraint, addDeploymentWithReplicas, and
ctx.ModifyDeployment helpers to keep the new case aligned with the current test
structure.
In `@pkg/templates/antiaffinity/template.go`:
- Around line 115-127: The helper topologySpreadConstraintsMatchAgainstNodes
currently treats every matching TopologySpreadConstraint as enforcing spread,
including soft preferences. Update this function to only return true when the
constraint’s WhenUnsatisfiable is DoNotSchedule, in addition to the existing
topologyKeyMatcher and labelSelector match. Keep the LabelSelectorAsSelector
error handling as-is, and add the new guard directly in the conditional so
ScheduleAnyway constraints are ignored.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Central YAML (base), Organization UI (inherited)
Review profile: CHILL
Plan: Enterprise
Run ID: 8c1c8f5e-a8f2-43c2-a656-48d1c2fa212a
⛔ Files ignored due to path filters (1)
docs/generated/checks.mdis excluded by!**/generated/**
📒 Files selected for processing (3)
pkg/builtinchecks/yamls/no-anti-affinity.yamlpkg/templates/antiaffinity/template.gopkg/templates/antiaffinity/template_test.go
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1224 +/- ##
===========================================
- Coverage 62.36% 31.42% -30.94%
===========================================
Files 197 239 +42
Lines 4854 6572 +1718
===========================================
- Hits 3027 2065 -962
- Misses 1439 4329 +2890
+ Partials 388 178 -210
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Fixes #894.
Summary:
Testing: