-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Scale bounds annotations #1980
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
Scale bounds annotations #1980
Conversation
Implements knative#1656
|
/assign @mattmoor |
|
/cc @josephburnett |
Make sure explicitly specified scale bounds are greater than 0.
Plus unit tests
Add scale bounds to spec.md
docs/spec/spec.md
Outdated
| # +optional. When not specified, the revision can scale down to 0 pods | ||
| autoscaling.knative.dev/minReplicaCount: "2" | ||
| # +optional. When not specified, there's no upper scale bound | ||
| autoscaling.knative.dev/maxReplicaCount: "10" |
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 is a feature of the KPA implementation that we bundle today (once you implement it?), so I'd rather not document this here because it is not within the scope of conformance (other KPA implementations may choose to ignore these).
This feels like it belongs in documentation for our KPA plugin. cc @josephburnett
Ack that this feels a bit crazy until we can actually swap in different autoscalers :)
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.
It is (as implemented in this PR) a feature of the bundled KPA, and it's something that (as a user) I'd like other KPA implementations to have.
They can, of course, ignore these annotations, but I'd like Knative to recommend them to minimize user confusion.
As implemented here, these annotations are applicable to both KPA (directly and propagating from Revision) and Revision (directly and via revisionTemplate).
As a user I don't want to know how auto-scaling works. All I care about is that it is present and I can set bounds. It is great to be able to set these bounds declaratively (via revisionTemplate) and very inconvenient to wait until KPA object magically appears once the Revision is created and set them there.
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.
Addressed this above in https://github.com/knative/serving/pull/1980/files#r218251531.
I think we should leave this out of the spec. We propagate all annotation from Service -> Configuration -> Revision so you can use this knob at whatever level you want. But the entities along that path should not necessarily be aware of, or couple with, those annotations. Min/max is an implementation specific knob.
pkg/apis/autoscaling/register.go
Outdated
| ClassAnnotationKey = GroupName + "/class" | ||
|
|
||
| MinScaleAnnotationKey = GroupName + "/minReplicaCount" | ||
| MaxScaleAnnotationKey = GroupName + "/maxReplicaCount" |
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 feel like we should define these in pkg/autoscaler, not alongside our types (continuation of the comment on spec.md)
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.
👍 to @mattmoor.
IMHO honoring ResourceQuota specs for the given namespace of the ReplicaSet wrt maxReplicaCount might be very wise a design.
RFC @mattmoor @imikushin 🙏
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.
@mattmoor The issue this PR is addressing (#1656) suggests the placement and rationale for these annotations:
I would like to add support for two KPA annotations (here) to constrain the min and max number of pods.
autoscaling.knative.dev/minReplicaCount autoscaling.knative.dev/maxReplicaCountThe annotations would be in the user-facing domain (not autoscaling.internal.knative.dev) because they are intended to be set by the Operator to place bounds on resource consumption.
They would also apply to other autoscaling implementations specified by autoscaling.knative.dev/class (if the implementation supports min/max constraints.)
@nrshrivatsan ResourceQuotas address a similar but different concern IMO and they apply to the whole namespace. Scale bounds only apply to specific revisions and enable both upper and lower bounds (kinda opposite to quotas' purpose).
nrshrivatsan
left a comment
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.
Suggestions on abstracting specifics into pkg/autoscaler
pkg/apis/autoscaling/register.go
Outdated
| ClassAnnotationKey = GroupName + "/class" | ||
|
|
||
| MinScaleAnnotationKey = GroupName + "/minReplicaCount" | ||
| MaxScaleAnnotationKey = GroupName + "/maxReplicaCount" |
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.
👍 to @mattmoor.
IMHO honoring ResourceQuota specs for the given namespace of the ReplicaSet wrt maxReplicaCount might be very wise a design.
RFC @mattmoor @imikushin 🙏
|
@josephburnett Can you please review and/or mark as ok to test? |
josephburnett
left a comment
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.
/lgtm
docs/spec/spec.md
Outdated
| knative.dev/type: "function" # One of "function" or "app" | ||
| annotations: | ||
| # +optional. When not specified, the revision can scale down to 0 pods | ||
| autoscaling.knative.dev/minReplicaCount: "2" |
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.
@cooperneil, what do you think about these annotations for providing Knative autoscaling bounds?
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 @imikushin for doing this! I think my suggestion to use the word "replica" is flawed. Knative doesn't talk about "replicas", "instances", "clones" etc.. It only talks about "containers". This was the reason I eventually chose the field name "ContainerConcurrency" in the Revision spec.
I would like to change these annotations to:
autoscaling.knative.dev/minContainerCount
autoscaling.knative.dev/maxContainerCount
What do you think?
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 didn't like the choice of names in the issue either, but thought I'd try to implement and see where it leads. I'd like to suggest:
autoscaling.knative.dev/minScale
autoscaling.knative.dev/maxScale
If you insist on (min|max)ContainerCount I don't mind either. Let me know what you like more and I'll update the PR accordingly.
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.
@josephburnett The reasons behind minScale/maxScale:
- shorter
- don't talk about the actual things being scaled (rumors are: pods might replace containers in revisionTemplate)
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.
Ping @josephburnett !
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 like to update this with whatever you guys decide
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.
@imikushin, yes, I think that autoscaling.knative.dev/minScale and autoscaling.knative.dev/maxScale are better names for the same reasons.
@mattmoor and @cooperneil, if you agree with these names, let's go with it!
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've chatted offline with @mattmoor about how to use these annotations, and I'll restate my understanding here.
The purpose of annotations (over the strongly-typed spec) is to allow users to reach under the covers and tune a component they know is there. In this case, we want to tune the specific implementation of the KPA interface that comes with Knative. The autoscaling.knative.dev/class identifies the particular KPA implementation being used and will remain with the KPA. However other implementation-specific annotations such as autoscaling.knative.dev/minScale and autoscaling.knative.dev/maxScale will remain with the implementation, even if it is separated (at some later time.)
As such, my recommendation is to go ahead with the autoscaling.knative.dev/minScale and autoscaling.knative.dev/maxScale annotation names. But do not document them in the Revision spec. Document them somewhere else (maybe in the https://github.com/knative/serving/blob/master/pkg/autoscaler/README.md file).
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.
Done!
|
/meow |
DetailsIn response to this:
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. |
# Conflicts: # pkg/reconciler/v1alpha1/autoscaling/kpa_scaler.go
|
Resolved merge conflict for the 4th time! /shrug |
|
/approve |
DetailsIn response to this:
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. |
|
/assign @mattmoor |
|
SGTM (but not yet familiar enough with the code base 😅) |
mattmoor
left a comment
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.
So I think with the requested changes, the only thing that should need my approval is the revision controller stuff, which LGTM.
I sent #2098 to correct the autoscaling API OWNERS.
| } | ||
| } | ||
|
|
||
| if err := validateScaleBoundAnnotations(meta.GetAnnotations()); err != nil { |
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 is KPA specific, so can we add it to the KPA validation?
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.
Done
| return 0 | ||
| } | ||
|
|
||
| func getScaleBounds(ctx context.Context, kpa *kpa.PodAutoscaler) (int32, int32) { |
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.
Should this be an accessor on the KPA resource itself?
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.
Done
* Validate metadata on KPA (including scale bounds) * Add kpa.ScaleBounds() accessor method
# Conflicts: # pkg/reconciler/v1alpha1/autoscaling/kpa_scaler.go
|
The following is the coverage report on pkg/.
|
|
/unshrug |
|
@imikushin: ¯\_(ツ)_/¯ DetailsIn response to this:
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. |
|
This needs another @mattmoor I believe I've addressed your feedback (thanks!) |
|
/lgtm |
|
/approve |
|
/assign @mattmoor |
|
/approve |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: imikushin, josephburnett, mattmoor The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |


Fixes #1656
Proposed Changes
autoscaling.knative.dev/minScaleandautoscaling.knative.dev/maxScaleannotations on RevisionTODO
Release Note