Add validations related to minReplicas and maxReplicas before updating HPA#451
Add validations related to minReplicas and maxReplicas before updating HPA#451AVSBharadwaj wants to merge 1 commit intomainfrom
Conversation
| } | ||
|
|
||
| // Ensure minReplicas doesn't exceed maxReplicas | ||
| if recommendMin > recommendMax { |
There was a problem hiding this comment.
I feel like there's a bug with the recommender logic if it ever returns recommendMin > recommendMax, should there also be a fix there?
There was a problem hiding this comment.
The recommender will not result in such a recommendations ( where recommendMin > recommendMax) . This is added just for completion sake to cover all possible cases.
djahandarie
left a comment
There was a problem hiding this comment.
The changes look safe to me and fix a bug, so I think we should more forward with them.
Though, as mentioned on Slack, I think this routine needs some refactoring to make it clearer what invariants we are trying to preserve (probably by having a pure subroutine which purely is responsible for enforcing those invariants, and nothing else), and that subroutine can be called as many times as needed. Should be fine to do in a separate PR.
Summary
Adds comprehensive validation logic to prevent Kubernetes HPA validation errors by ensuring
minReplicas <= maxReplicasand respecting all replica bounds across all Tortoise phases.What Changed
New Validation Logic
minReplicas/maxReplicasagainst user and cluster limitsminReplicas <= maxReplicasminReplicas = maxReplicasmaxReplicasfor safe gradual reductionEnhanced Logging
WarningReplicaValidationevent for better categorizationTest Coverage
Added 8 test cases covering all validation scenarios including edge cases and phase transitions.
Why These Changes
Problem
minReplicas > maxReplicasSolution
Benefits
Testing
Type: Enhancement
Breaking Change: No
Testing: ✅ Unit tests added