-
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
Add default cluster-side min-scale #12290
Add default cluster-side min-scale #12290
Conversation
Codecov Report
@@ Coverage Diff @@
## main #12290 +/- ##
==========================================
- Coverage 87.47% 87.46% -0.01%
==========================================
Files 195 195
Lines 9595 9599 +4
==========================================
+ Hits 8393 8396 +3
+ Misses 923 922 -1
- Partials 279 281 +2
Continue to review full report at Codecov.
|
aaa1dff
to
4a5b800
Compare
@@ -84,9 +84,11 @@ func (pa *PodAutoscaler) annotationFloat64(key string) (float64, bool) { | |||
// not set. | |||
// Note: min will be ignored if the PA is not reachable | |||
func (pa *PodAutoscaler) ScaleBounds(asConfig *autoscalerconfig.Config) (int32, int32) { | |||
var min int32 | |||
min := asConfig.MinScale |
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 think this needs to be in the if block one line down, otherwise we'll keep minScale > 0 even when the revision becomes unreachable, which isn't how specifying min-scale-as-an-annotation acts
@@ -50,6 +50,10 @@ type Config struct { | |||
// services. This can be set to 0 iff AllowZeroInitialScale is true. | |||
InitialScale int32 | |||
|
|||
// MinScale is the default min scale for any revision created without an | |||
// autoscaling.knative.dev/maxScale annotation |
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.
// autoscaling.knative.dev/maxScale annotation | |
// autoscaling.knative.dev/minScale annotation |
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.
fixed, sorry for the typos, went through and made sure there aren't any more
4a5b800
to
7a193f2
Compare
pkg/autoscaler/config/config.go
Outdated
@@ -191,6 +197,10 @@ func validate(lc *autoscalerconfig.Config) (*autoscalerconfig.Config, error) { | |||
return nil, fmt.Errorf("max-scale-limit = %v, must be at least 0", lc.MaxScaleLimit) | |||
} | |||
|
|||
if lc.MinScale > lc.MaxScale { |
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.
what if lc.MaxScale hasn't been set, so is == 0?
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.
added validation and test
@@ -86,7 +86,10 @@ func (pa *PodAutoscaler) annotationFloat64(key string) (float64, bool) { | |||
func (pa *PodAutoscaler) ScaleBounds(asConfig *autoscalerconfig.Config) (int32, int32) { | |||
var min int32 | |||
if pa.Spec.Reachability != ReachabilityUnreachable { | |||
min, _ = pa.annotationInt32(autoscaling.MinScaleAnnotationKey) | |||
min = asConfig.MinScale |
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'd add a test to the test table for this case (i.e. that when minScale > 1 but unreachable we still return 0) since nothing caught this being one line too high before :)
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.
added test
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.
not super important at all, but jfwiw it's a little easier to review if you push new commits rather than force pushing a squashed commit (just because that way the reviewer doesn't need to read back through the whole thing), and prow is set up to auto-squash when merging anyway
7a193f2
to
1a13736
Compare
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.
thanks @nader-ziada!
/lgtm
/approve
@@ -86,7 +86,10 @@ func (pa *PodAutoscaler) annotationFloat64(key string) (float64, bool) { | |||
func (pa *PodAutoscaler) ScaleBounds(asConfig *autoscalerconfig.Config) (int32, int32) { | |||
var min int32 | |||
if pa.Spec.Reachability != ReachabilityUnreachable { | |||
min, _ = pa.annotationInt32(autoscaling.MinScaleAnnotationKey) | |||
min = asConfig.MinScale |
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.
not super important at all, but jfwiw it's a little easier to review if you push new commits rather than force pushing a squashed commit (just because that way the reviewer doesn't need to read back through the whole thing), and prow is set up to auto-squash when merging anyway
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: julz, nader-ziada The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@julz sorry about that, didn't know prow was set to squash commits |
@nader-ziada thanks for the quick turnaround on this, I just saw! Looking forward to 1.1 🤩 |
based on a slack conversation: https://knative.slack.com/archives/C94SPR60H/p1637002245043400
Proposed Changes
Release Note