From 3c43ec9b88196aa61dfab9a48207abfef2403b94 Mon Sep 17 00:00:00 2001 From: Alexey Kazakov Date: Thu, 8 Aug 2024 13:38:46 -0700 Subject: [PATCH] logs --- pkg/autoscaler/autoscaler.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pkg/autoscaler/autoscaler.go b/pkg/autoscaler/autoscaler.go index 79c36077..ad759e77 100644 --- a/pkg/autoscaler/autoscaler.go +++ b/pkg/autoscaler/autoscaler.go @@ -13,6 +13,7 @@ import ( "k8s.io/apimachinery/pkg/runtime/serializer" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/log" ) type BufferConfiguration interface { @@ -26,13 +27,20 @@ func Deploy(ctx context.Context, cl client.Client, s *runtime.Scheme, namespace if err != nil { return err } + logger := log.FromContext(ctx) applyClient := applycl.NewApplyClient(cl) // create all objects that are within the template, and update only when the object has changed. for _, obj := range objs { - if _, err := applyClient.ApplyObject(ctx, obj); err != nil { + applied, err := applyClient.ApplyObject(ctx, obj) + if err != nil { return errs.Wrap(err, "cannot deploy autoscaling buffer template") } + if applied { + logger.Info("Autoscaling Buffer object created or updated", "kind", obj.GetObjectKind(), "namespace", obj.GetNamespace(), "name", obj.GetName()) + } else { + logger.Info("Autoscaling Buffer object has not changed", "kind", obj.GetObjectKind(), "namespace", obj.GetNamespace(), "name", obj.GetName()) + } } return nil }