Repository navigation
fix(validation): apply HPA scale target bounds per metric - #6140
Merged
github-actions[bot] merged 1 commit intoSep 14, 2026
Merged
Conversation
Fixes kserve#5981 The validateScalingHPACompExtension function had an operator precedence bug where the condition 'metric == MetricCPU && target < 1 || target > 100' was evaluated as '(metric == MetricCPU && target < 1) || (target > 100)', causing: 1. The upper bound check to apply to all metrics instead of just CPU 2. Memory targets > 100 to be rejected with a CPU-specific error message 3. The memory-specific validation to use wrong semantics (MiB vs percentage) Fix by reusing the existing validateTargetUtilization helper, which properly enforces [1-100] bounds for both CPU and memory metrics, matching the pattern used in validateScalingKedaCompExtension. Signed-off-by: Claude Fable 5.1 <[email protected]> Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01Qnxf2u2kSBxRM1AT7kD8BD Signed-off-by: Kush Zingade <[email protected]>
Contributor
|
/lgtm Thanks @UgaTheDev |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does / why we need it:
validateScalingHPACompExtensionchecksif metric == MetricCPU && target < 1 || target > 100. Go binds&&tighter than||, so this parses as(metric == MetricCPU && target < 1) || (target > 100): the upper bound applies to every metric, and a memory target over 100 is rejected with the CPU "target utilization percentage" message. The separate memory branch below it then only ever fires fortarget < 1, with a "greater than 1 MiB" message even though memoryScaleTargeton the HPA path is a utilization percentage.This replaces both branches with the existing
validateTargetUtilizationhelper, so CPU and memory targets get the same[1, 100]bound and the same message, matching what the KEDA validation path already does. Accepted values do not change: memory targets in[1, 100]were already the only ones that passed. Only the error text for out-of-range memory targets changes.Which issue(s) this PR fixes:
Fixes #5981
Feature/Issue validation/testing:
TestAutoscalerClassHPAfor CPU and memory at 0, 1, 100 and 101. The memory 101 case fails on master with the CPU-worded error and passes here with the unified message.go test ./pkg/apis/serving/v1beta1/ -run TestAutoscalerClassHPA -count=1passes;gofmt -lclean.Special notes for your reviewer:
The removed "target memory should be greater than 1 MiB" message was unreachable for any value the first branch did not already reject, except
target < 1for memory; that case is now covered by the shared message.Checklist:
Release note:
🤖 Generated with Claude Code
https://claude.ai/code/session_01Qnxf2u2kSBxRM1AT7kD8BD