Repository navigation
Reconcile HPA class PodAutoscalers #2 - #2457
Conversation
| logger.Info("Updating PA %q", desiredPa.Name) | ||
| pa.Spec = desiredPa.Spec | ||
| pa.Annotations = desiredPa.Annotations | ||
| if _, err := c.updateKPA(ctx, pa); err != nil { |
There was a problem hiding this comment.
This will update the annotations. We'd discussed making class annotations immutable on the PodAutoscaler (we should probably do this @ Revision as well), which simplifies this a bit.
There was a problem hiding this comment.
Correct. I want the class and metric annotations to be immutable. But I want the others to be reconciled (minScale, maxScale, target).
My plan was to just reconcile all annotations from Revision to PodAutoscaler (for simplicity). And to use the Revision webhook to disallow class and metric changes. That means I will also be adding defaults in the Revision webhook.
There was a problem hiding this comment.
After chatting with @mattmoor, I'll make the class annotation immutable on the Revision (enforced through webhook). But if I can't allow metric to change, I'll give an error from the PodAutoscaler webhook or reconciler, so I don't leak implementation-specific annotations into higher layers.
| original, err := c.paLister.PodAutoscalers(namespace).Get(name) | ||
| if errors.IsNotFound(err) { | ||
| logger.Debug("PA no longer exists") | ||
| return c.deleteHpa(ctx, key) |
There was a problem hiding this comment.
Here and below, I think we should set up the invariants such that a PodAutoscaler never changes classes.
This line is problematic because it could create a requeue spin loop when deletions fail (e.g. on NotFound).
There was a problem hiding this comment.
c.deleteHpa handles NotFound (search for "This is fine"). So think this is okay. Am I missing something else?
|
So weird. That unit test passes on my machine: |
|
@josephburnett I think this is one of the flaky unit tests. Might not be related to your PR. See #2443 |
|
/test pull-knative-serving-unit-tests |
|
Okay @mattmoor this is ready for another look. |
mattmoor
left a comment
There was a problem hiding this comment.
/lgtm
/approve
/hold
One thing worth confirming before this goes in, but otherwise this LGTM. thanks!
| // PodAutoscaler should attempt to maintain. For example, | ||
| // autoscaling.knative.dev/metric: cpu | ||
| // autoscaling.knative.dev/target: 75 # target 75% cpu utilizationa | ||
| TargetAnnotationKey = GroupName + "/target" |
There was a problem hiding this comment.
What I was saying "No" to was having the Revision controller put containerConcurrency into the annotation instead of a field. I wasn't suggesting we need any change here, just answering @markusthoemmes comment ;-)
| Handler: cache.ResourceEventHandlerFuncs{ | ||
| AddFunc: impl.EnqueueControllerOf, | ||
| UpdateFunc: controller.PassNew(impl.EnqueueControllerOf), | ||
| DeleteFunc: impl.EnqueueControllerOf, |
There was a problem hiding this comment.
🎉 This is looking awesome 🎉
| UpdateFunc: controller.PassNew(impl.EnqueueLabelOfNamespaceScopedResource("", autoscaling.KPALabelKey)), | ||
| DeleteFunc: impl.EnqueueLabelOfNamespaceScopedResource("", autoscaling.KPALabelKey), | ||
| endpointsInformer.Informer().AddEventHandler(cache.FilteringResourceEventHandler{ | ||
| FilterFunc: onlyKpaClass, |
There was a problem hiding this comment.
I'm not sure the Kubernetes Endpoints object gets annotations. Can you confirm this works?
There was a problem hiding this comment.
It does work, but only because I let PodAutoscalers missing the annotation through to the KPA (but not HPA) controller, for backward compatibility.
I've removed the filter since it's useless. Good catch!
There was a problem hiding this comment.
(note true in the last parameter to AnnotationFilterFunc)
There was a problem hiding this comment.
Yep, that's what I suspected :D
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: 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 |
|
The following is the coverage report on pkg/.
|
Fixes #2205
Fixes #1928
Proposed Changes
autoscaling.knative.dev/classannotation.hpaclass PodAutoscalers to a Kubernetes HorizontalPodAutoscaler.kpato justpa(drop thek). The short namekpais now taken to mean kpa-class PodAutoscalers andhpato mean hpa-class PodAutoscalers.autoscaling.knative.dev/metricannotation to chooseconcurrencyorcpubased autoscaling (cpuwill default theclasstohpa).autoscaling.knative.dev/targetannotation to choose the specific value formetric.classandmetricannotation are immutable on PodAutoscaler, enforced by webhook. Other annotations (target,minScale,maxScale) are mutable.Release Note