From 3abecd0f1960f4508db2eb22654b8b0015102a13 Mon Sep 17 00:00:00 2001 From: Felipe Galindo Sanchez Date: Wed, 23 Feb 2022 08:29:13 -0800 Subject: [PATCH] logging: improve logs for scaling --- controllers/horizontal_runner_autoscaler_webhook.go | 7 +++---- controllers/runnerreplicaset_controller.go | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/controllers/horizontal_runner_autoscaler_webhook.go b/controllers/horizontal_runner_autoscaler_webhook.go index ea407fdb..e2465d0a 100644 --- a/controllers/horizontal_runner_autoscaler_webhook.go +++ b/controllers/horizontal_runner_autoscaler_webhook.go @@ -351,9 +351,7 @@ func (autoscaler *HorizontalRunnerAutoscalerGitHubWebhook) findHRAsByKey(ctx con return nil, err } - for _, d := range hraList.Items { - hras = append(hras, d) - } + hras = append(hras, hraList.Items...) } return hras, nil @@ -791,7 +789,7 @@ func (autoscaler *HorizontalRunnerAutoscalerGitHubWebhook) tryScale(ctx context. } autoscaler.Log.Info( - "Patching hra for capacityReservations update", + fmt.Sprintf("Patching hra %s for capacityReservations update", target.HorizontalRunnerAutoscaler.Name), "before", target.HorizontalRunnerAutoscaler.Spec.CapacityReservations, "after", copy.Spec.CapacityReservations, ) @@ -829,6 +827,7 @@ func (autoscaler *HorizontalRunnerAutoscalerGitHubWebhook) SetupWithManager(mgr hra := rawObj.(*v1alpha1.HorizontalRunnerAutoscaler) if hra.Spec.ScaleTargetRef.Name == "" { + autoscaler.Log.V(1).Info(fmt.Sprintf("scale target ref name not set for hra %s", hra.Name)) return nil } diff --git a/controllers/runnerreplicaset_controller.go b/controllers/runnerreplicaset_controller.go index 2acc93aa..b540fcf3 100644 --- a/controllers/runnerreplicaset_controller.go +++ b/controllers/runnerreplicaset_controller.go @@ -155,7 +155,7 @@ func (r *RunnerReplicaSetReconciler) Reconcile(ctx context.Context, req ctrl.Req if current > desired { n := current - desired - log.V(0).Info(fmt.Sprintf("Deleting %d runners", n), "desired", desired, "current", current, "ready", ready) + log.V(0).Info(fmt.Sprintf("Deleting %d runners from RunnerReplicaSet %s", n, req.NamespacedName), "desired", desired, "current", current, "ready", ready) // get runners that are currently offline/not busy/timed-out to register var deletionCandidates []v1alpha1.Runner @@ -233,7 +233,7 @@ func (r *RunnerReplicaSetReconciler) Reconcile(ctx context.Context, req ctrl.Req } r.Recorder.Event(&rs, corev1.EventTypeNormal, "RunnerDeleted", fmt.Sprintf("Deleted runner '%s'", deletionCandidates[i].Name)) - log.Info("Deleted runner") + log.Info(fmt.Sprintf("Deleted runner %s", deletionCandidates[i].Name)) } } else if desired > current { n := desired - current