Skip to content

Commit

Permalink
Reconcile on all private service events in KPA.
Browse files Browse the repository at this point in the history
We used to have a metrics service which the KPA watched and reacted to. We got rid of that and now have a race condition if we specify minScale but the SKS becomes ready with less than minScale pods. Nothing after that will ever kick the KPA to reconcile again.

This fixes that by watching the private services to make sure the KPA sees every change in deployment size. It itself keys off of the private services too to calculate the current replicas, closing the loop here.
  • Loading branch information
markusthoemmes committed Apr 6, 2020
1 parent b958769 commit 4835c3e
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions pkg/reconciler/autoscaling/kpa/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ import (
"knative.dev/pkg/controller"
pkgreconciler "knative.dev/pkg/reconciler"
"knative.dev/serving/pkg/apis/autoscaling"
"knative.dev/serving/pkg/apis/networking"
"knative.dev/serving/pkg/apis/serving"
autoscalerconfig "knative.dev/serving/pkg/autoscaler/config"
servingreconciler "knative.dev/serving/pkg/reconciler"
areconciler "knative.dev/serving/pkg/reconciler/autoscaling"
Expand Down Expand Up @@ -114,16 +116,12 @@ func NewController(
},
})

// Watch all the private service endpoints.
endpointsInformer.Informer().AddEventHandler(cache.FilteringResourceEventHandler{
FilterFunc: pkgreconciler.LabelExistsFilterFunc(autoscaling.KPALabelKey),
Handler: controller.HandleAll(impl.EnqueueLabelOfNamespaceScopedResource("", autoscaling.KPALabelKey)),
FilterFunc: pkgreconciler.LabelFilterFunc(networking.ServiceTypeKey, string(networking.ServiceTypePrivate), false),
Handler: controller.HandleAll(impl.EnqueueLabelOfNamespaceScopedResource("", serving.RevisionLabelKey)),
})

// Watch all the services that we have created.
serviceInformer.Informer().AddEventHandler(cache.FilteringResourceEventHandler{
FilterFunc: onlyKpaClass,
Handler: controller.HandleAll(impl.EnqueueControllerOf),
})
sksInformer.Informer().AddEventHandler(cache.FilteringResourceEventHandler{
FilterFunc: onlyKpaClass,
Handler: controller.HandleAll(impl.EnqueueControllerOf),
Expand Down

0 comments on commit 4835c3e

Please sign in to comment.