Skip to content
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

Merged
merged 1 commit into from
Nov 18, 2021

Conversation

nader-ziada
Copy link
Member

based on a slack conversation: https://knative.slack.com/archives/C94SPR60H/p1637002245043400

Proposed Changes

  • add a cluster-wide config value for min-scale

Release Note

Add cluster wide default min-scale

@google-cla google-cla bot added the cla: yes Indicates the PR's author has signed the CLA. label Nov 16, 2021
@knative-prow-robot knative-prow-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. area/API API objects and controllers area/autoscale labels Nov 16, 2021
@codecov
Copy link

codecov bot commented Nov 16, 2021

Codecov Report

Merging #12290 (1a13736) into main (a902f25) will decrease coverage by 0.00%.
The diff coverage is 77.77%.

Impacted file tree graph

@@            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     
Impacted Files Coverage Δ
pkg/autoscaler/config/config.go 97.91% <66.66%> (-2.09%) ⬇️
pkg/apis/autoscaling/v1alpha1/pa_lifecycle.go 100.00% <100.00%> (ø)
pkg/reconciler/revision/background.go 90.00% <0.00%> (-1.82%) ⬇️
pkg/reconciler/configuration/configuration.go 84.61% <0.00%> (-1.54%) ⬇️
cmd/queue/main.go 0.53% <0.00%> (+<0.01%) ⬆️
pkg/queue/concurrency_state.go 79.71% <0.00%> (+3.65%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a902f25...1a13736. Read the comment docs.

@knative-prow-robot knative-prow-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Nov 16, 2021
@@ -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
Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// autoscaling.knative.dev/maxScale annotation
// autoscaling.knative.dev/minScale annotation

Copy link
Member Author

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

pkg/autoscaler/config/config.go Show resolved Hide resolved
@knative-prow-robot knative-prow-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Nov 17, 2021
@@ -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 {
Copy link
Member

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?

Copy link
Member Author

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
Copy link
Member

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 :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added test

Copy link
Member

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

Copy link
Member

@julz julz left a 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
Copy link
Member

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

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Nov 18, 2021
@knative-prow-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow-robot knative-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 18, 2021
@knative-prow-robot knative-prow-robot merged commit b4768b1 into knative:main Nov 18, 2021
@nader-ziada
Copy link
Member Author

@julz sorry about that, didn't know prow was set to squash commits

@mattmoor
Copy link
Member

@nader-ziada thanks for the quick turnaround on this, I just saw! Looking forward to 1.1 🤩

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/API API objects and controllers area/autoscale cla: yes Indicates the PR's author has signed the CLA. lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants