diff --git a/pkg/controllers/allocation/controller.go b/pkg/controllers/allocation/controller.go index 669b38ea1878..8fc0961f7b0f 100644 --- a/pkg/controllers/allocation/controller.go +++ b/pkg/controllers/allocation/controller.go @@ -77,7 +77,11 @@ func NewController(kubeClient client.Client, coreV1Client corev1.CoreV1Interface // Reconcile executes an allocation control loop for the resource func (c *Controller) Reconcile(ctx context.Context, req reconcile.Request) (reconcile.Result, error) { - ctx = logging.WithLogger(ctx, logging.FromContext(ctx).Named("Allocation")) + ctx = logging.WithLogger(ctx, logging.FromContext(ctx).Named(fmt.Sprintf("allocation.provisioner/%s", req.Name))) + logging.FromContext(ctx).Infof("Starting provisioning loop") + defer func() { + logging.FromContext(ctx).Infof("Watching for pod events") + }() // 1. Fetch provisioner provisioner, err := c.provisionerFor(ctx, req.NamespacedName) @@ -91,6 +95,7 @@ func (c *Controller) Reconcile(ctx context.Context, req reconcile.Request) (reco } // 2. Wait on a pod batch + logging.FromContext(ctx).Infof("Waiting to batch additional pods") c.Batcher.Wait(provisioner) // 3. Filter pods @@ -98,6 +103,7 @@ func (c *Controller) Reconcile(ctx context.Context, req reconcile.Request) (reco if err != nil { return result.RetryIfError(ctx, fmt.Errorf("filtering pods, %w", err)) } + logging.FromContext(ctx).Infof("Found %d provisionable pods", len(pods)) if len(pods) == 0 { return reconcile.Result{}, nil } diff --git a/pkg/controllers/allocation/filter.go b/pkg/controllers/allocation/filter.go index cb7cfc31c74e..9d504645bd51 100644 --- a/pkg/controllers/allocation/filter.go +++ b/pkg/controllers/allocation/filter.go @@ -38,10 +38,6 @@ func (f *Filter) GetProvisionablePods(ctx context.Context, provisioner *v1alpha3 if err := f.KubeClient.List(ctx, pods, client.MatchingFields{"spec.nodeName": ""}); err != nil { return nil, fmt.Errorf("listing unscheduled pods, %w", err) } - if len(pods.Items) == 0 { - return nil, nil - } - // 2. Filter pods that aren't provisionable provisionable := []*v1.Pod{} for _, p := range pods.Items { @@ -53,7 +49,6 @@ func (f *Filter) GetProvisionablePods(ctx context.Context, provisioner *v1alpha3 } provisionable = append(provisionable, ptr.Pod(p)) } - logging.FromContext(ctx).Infof("Found %d provisionable pods", len(provisionable)) return provisionable, nil }