-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Validation added for initialScale greater than maxScale (#14153) #14682
Conversation
Hi @yp969803. Thanks for your PR. I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/ok-to-test |
|
||
func validateMaxInitialScale(config *autoscalerconfig.Config, m map[string]string) *apis.FieldError{ | ||
|
||
max,errs := getIntGE0(m,MaxScaleAnnotation) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These annotations could be omitted from the revision so you would need to handle that
see
if k, v, ok := InitialScaleAnnotation.Get(m); ok { |
@dprotaso i have added the further annotations can you review |
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #14682 +/- ##
==========================================
- Coverage 86.05% 85.81% -0.24%
==========================================
Files 197 197
Lines 14937 14974 +37
==========================================
- Hits 12854 12850 -4
- Misses 1774 1810 +36
- Partials 309 314 +5 ☔ View full report in Codecov by Sentry. |
if (initial<0){ | ||
errs=errs.Also(&apis.FieldError{ | ||
Message: fmt.Sprintf("initial-scale=%d should be greater than 0", initial), | ||
Paths: []string{MaxScaleAnnotationKey,InitialScaleAnnotationKey}, | ||
}) | ||
}else if !config.AllowZeroInitialScale && initial==0 { | ||
errs=errs.Also(&apis.FieldError{ | ||
Message: fmt.Sprintf("initial-scale=%d not allowed by cluster", initial), | ||
Paths: []string{MaxScaleAnnotationKey,InitialScaleAnnotationKey}, | ||
}) | ||
}else if max<=0{ | ||
errs=errs.Also(&apis.FieldError{ | ||
Message: fmt.Sprintf("max-scale=%d should be greate than 0",max), | ||
Paths: []string{MaxScaleAnnotationKey,InitialScaleAnnotationKey}, | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think these assertions are needed - we validate InitialScale here
func validateInitialScale(config *autoscalerconfig.Config, m map[string]string) *apis.FieldError { |
We validate max scale here
func validateMinMaxScale(config *autoscalerconfig.Config, m map[string]string) *apis.FieldError { |
We just need to perform validation if initial scale and max scale are present then do the comparison.
See here for examples:
func validateMinMaxScale(config *autoscalerconfig.Config, m map[string]string) *apis.FieldError { |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: yp969803 The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@dprotaso i have updated the pr you can review, adding test is left |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please fix the CI jobs
- code doesn't compile
- you'll need to use gofmt to format the code (linter is complaining)
Secondly, please add a unit test
if initial > max { | ||
return &apis.FieldError{ | ||
Message: fmt.Sprintf("max-scale=%d is less than initial-scale=%d", max, initial), | ||
Paths: []string{MaxScaleAnnotationKey,InitialScaleAnnotationKey}, | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fails when the max scale annotation is not present since max
will be equal to zero
@dprotaso updated the pr and added the unit test |
…tive#14682) linting error removed from annotation_validation.go
@yp969803: The following test failed, say
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
@dprotaso any stuff left? |
CI is failing - see the GitHub checks - I'll wait for them to go green before reviewing again |
Hey @yp969803 the unit tests that are failing is the code you've modified can you take a look? |
Going to close this out due to inactivity. |
Fixes #14153
Proposed Changes
Release Note