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 active-min-scale annotation #13136

Merged
merged 4 commits into from
Jul 27, 2022
Merged

Conversation

psschwei
Copy link
Contributor

@psschwei psschwei commented Jul 20, 2022

Signed-off-by: Paul S. Schweigert paulschw@us.ibm.com

Proposed Changes

This PR implements a "min-scale, but with scale to zero" feature. In
essence, when this feature is in use, if the service is handling
requests it will never have less than N number of pods (though it can
still scale to zero).

N is specified on a per-revision basis using an
autoscaling.knative.dev/active-min-scale annotation.

This annotation will not impact initial-scale values, as it will only apply on
subsequent scales from zero.

Fixes #11308

/assign @nader-ziada @dprotaso

Signed-off-by: Paul S. Schweigert <paulschw@us.ibm.com>

This PR implements a "min-scale, but with scale to zero" feature. In
essence, when this feature is in use, if the service is handling
requests it will never have less than N number of pods (though it can
still scale to zero).

N is specified on a per-revision basis using an
`autoscaling.knative.dev/min-non-zero-replicas` annotation.

If min-non-zero-replicas > initial-scale, the service will initially
scale to the min-non-zero-replicas value.
@knative-prow knative-prow bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. area/API API objects and controllers area/autoscale labels Jul 20, 2022
@psschwei
Copy link
Contributor Author

@vagababov I think I've seen you pop in a bit recently, so if you have bandwidth to take a look that'd be great (and if not, no worries at all)

/approve cancel

@codecov
Copy link

codecov bot commented Jul 20, 2022

Codecov Report

Merging #13136 (ba7e34b) into main (d366049) will decrease coverage by 0.08%.
The diff coverage is 64.70%.

@@            Coverage Diff             @@
##             main   #13136      +/-   ##
==========================================
- Coverage   86.78%   86.69%   -0.09%     
==========================================
  Files         196      196              
  Lines       14410    14450      +40     
==========================================
+ Hits        12506    12528      +22     
- Misses       1609     1626      +17     
- Partials      295      296       +1     
Impacted Files Coverage Δ
pkg/autoscaler/scaling/multiscaler.go 87.24% <ø> (-1.35%) ⬇️
pkg/apis/autoscaling/annotation_validation.go 95.23% <52.63%> (-4.77%) ⬇️
pkg/autoscaler/scaling/autoscaler.go 96.84% <62.50%> (-1.51%) ⬇️
pkg/apis/autoscaling/v1alpha1/pa_lifecycle.go 100.00% <100.00%> (ø)
...kg/reconciler/autoscaling/kpa/resources/decider.go 100.00% <100.00%> (ø)
cmd/queue/main.go
pkg/queue/sharedmain/main.go 0.64% <0.00%> (ø)
pkg/autoscaler/statforwarder/leases.go 73.95% <0.00%> (+1.56%) ⬆️
pkg/reconciler/revision/controller.go 92.95% <0.00%> (+3.62%) ⬆️

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 d366049...ba7e34b. Read the comment docs.

Copy link
Member

@dprotaso dprotaso left a comment

Choose a reason for hiding this comment

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

I think the annotation name min-non-zero-replicas is confusing. The only alternative I have to offer is min-activate-scale - where active (to me) means the revision is handling a request(s)

Comment on lines 208 to 213
} else if nzMin < 2 {
errs = errs.Also(&apis.FieldError{
Message: fmt.Sprintf("min-non-zero-replicas=%d must be greater than 1", nzMin),
Paths: []string{MinNonZeroReplicasKey},
})
}
Copy link
Member

Choose a reason for hiding this comment

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

Curious if setting a value of 1 would be necessary for the scenario:

min-scale: 0
initial-scale: 0
min-non-zero-replicas: 1

Or is setting it to 1 just not necessary because that's the floor?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My thought here was that if you're going to set this value, it needs to actually do something (setting it equal to one is the same as not setting it at all, and in that case you may as well not use it at all...)

pkg/apis/autoscaling/annotation_validation.go Outdated Show resolved Hide resolved
pkg/apis/autoscaling/v1alpha1/pa_lifecycle_test.go Outdated Show resolved Hide resolved
pkg/reconciler/autoscaling/kpa/resources/decider_test.go Outdated Show resolved Hide resolved
pkg/reconciler/autoscaling/kpa/scaler.go Outdated Show resolved Hide resolved
pkg/autoscaler/scaling/autoscaler.go Outdated Show resolved Hide resolved
Signed-off-by: Paul S. Schweigert <paulschw@us.ibm.com>
Signed-off-by: Paul S. Schweigert <paulschw@us.ibm.com>
@psschwei psschwei changed the title Add min-non-zero-replicas annotation Add min-activate-scale annotation Jul 27, 2022
pkg/autoscaler/scaling/multiscaler.go Outdated Show resolved Hide resolved
pkg/autoscaler/scaling/autoscaler.go Outdated Show resolved Hide resolved
@dprotaso
Copy link
Member

Also - I would do a sanity check on the annotation name say with someone from Docs/UX - in case they have a better suggestion. Worst case we change the name again in a future before (but before the release)

@dprotaso
Copy link
Member

/lgtm
/approve
/hold in case you plan on doing the sanity check - otherwise feel free to /unhold and do a follow up PR if the name changes

@knative-prow knative-prow bot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm Indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Jul 27, 2022
@dprotaso
Copy link
Member

dprotaso commented Jul 27, 2022

I guess one last thing (in a follow up PR) - having an e2e test would be great

Signed-off-by: Paul S. Schweigert <paulschw@us.ibm.com>
@psschwei psschwei changed the title Add min-activate-scale annotation Add active-min-scale annotation Jul 27, 2022
@knative-prow knative-prow bot removed the lgtm Indicates that a PR is ready to be merged. label Jul 27, 2022
@psschwei
Copy link
Contributor Author

psschwei commented Jul 27, 2022

We chatted in slack on the name change
/hold cancel

@knative-prow knative-prow bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 27, 2022
@dprotaso
Copy link
Member

/lgtm
/approve

let's do an e2e test in a followup

@knative-prow knative-prow bot added the lgtm Indicates that a PR is ready to be merged. label Jul 27, 2022
@knative-prow
Copy link

knative-prow bot commented Jul 27, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dprotaso

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

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 lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Is there a way to specify a minimum, non-zero scaling value while keeping scale-to-zero behavior?
3 participants