From 503decb0f37c2639dcdecd27e2592768e02a700b Mon Sep 17 00:00:00 2001 From: Francesco Romani Date: Thu, 6 Jun 2024 16:18:59 +0200 Subject: [PATCH] OCPBUGS-34972: perfprof: bump verbosiness of logs Increase the verbosiness required to emit log messages to reduce the log amount. Note this change doesn't address the reason for periodic reconciles, we only review the verbosiness of log messages. Signed-off-by: Francesco Romani --- .../components/handler/handler.go | 13 +++++++------ .../performanceprofile/resources/resources.go | 16 ++++++++-------- .../performanceprofile/status/writer.go | 3 ++- .../controller/performanceprofile_controller.go | 6 +++--- 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/pkg/performanceprofile/controller/performanceprofile/components/handler/handler.go b/pkg/performanceprofile/controller/performanceprofile/components/handler/handler.go index 2205037622..28346a9fff 100644 --- a/pkg/performanceprofile/controller/performanceprofile/components/handler/handler.go +++ b/pkg/performanceprofile/controller/performanceprofile/components/handler/handler.go @@ -42,6 +42,7 @@ func (h *handler) Apply(ctx context.Context, obj client.Object, recorder record. } if profileutil.IsPaused(profile) { + // this is expected to be exceptional, hence we omit V() klog.Infof("Ignoring reconcile loop for pause performance profile %s", profile.Name) return nil } @@ -50,7 +51,7 @@ func (h *handler) Apply(ctx context.Context, obj client.Object, recorder record. if err != nil { return fmt.Errorf("could not determine high-performance runtime class container-runtime for profile %q; %w", profile.Name, err) } - klog.Infof("using %q as high-performance runtime class container-runtime for profile %q", ctrRuntime, profile.Name) + klog.V(2).Infof("using %q as high-performance runtime class container-runtime for profile %q", ctrRuntime, profile.Name) opts.MachineConfig.DefaultRuntime = ctrRuntime components, err := manifestset.GetNewComponents(profile, opts) @@ -146,23 +147,23 @@ func (h *handler) Delete(ctx context.Context, profileName string) error { func (h *handler) Exists(ctx context.Context, profileName string) bool { tunedName := components.GetComponentName(profileName, components.ProfileNamePerformance) if _, err := resources.GetTuned(ctx, h.Client, tunedName, components.NamespaceNodeTuningOperator); !k8serros.IsNotFound(err) { - klog.Infof("Tuned %q custom resource is still exists in the namespace %q", tunedName, components.NamespaceNodeTuningOperator) + klog.V(1).Infof("Tuned %q custom resource is still exists in the namespace %q", tunedName, components.NamespaceNodeTuningOperator) return true } name := components.GetComponentName(profileName, components.ComponentNamePrefix) if _, err := resources.GetKubeletConfig(ctx, h.Client, name); !k8serros.IsNotFound(err) { - klog.Infof("Kubelet Config %q exists in the cluster", name) + klog.V(1).Infof("Kubelet Config %q exists in the cluster", name) return true } if _, err := resources.GetRuntimeClass(ctx, h.Client, name); !k8serros.IsNotFound(err) { - klog.Infof("Runtime class %q exists in the cluster", name) + klog.V(1).Infof("Runtime class %q exists in the cluster", name) return true } if _, err := resources.GetMachineConfig(ctx, h.Client, machineconfig.GetMachineConfigName(profileName)); !k8serros.IsNotFound(err) { - klog.Infof("Machine Config %q exists in the cluster", name) + klog.V(1).Infof("Machine Config %q exists in the cluster", name) return true } return false @@ -192,7 +193,7 @@ func (h *handler) getContainerRuntimeName(ctx context.Context, profile *performa } if len(ctrcfgs) == 0 { - klog.Infof("no ContainerRuntimeConfig found that matches MCP labels %s that associated with performance profile %q; using default container runtime", mcpSetLabels.String(), profile.Name) + klog.V(1).Infof("no ContainerRuntimeConfig found that matches MCP labels %s that associated with performance profile %q; using default container runtime", mcpSetLabels.String(), profile.Name) return mcov1.ContainerRuntimeDefaultRuntimeRunc, nil } diff --git a/pkg/performanceprofile/controller/performanceprofile/resources/resources.go b/pkg/performanceprofile/controller/performanceprofile/resources/resources.go index 6b415d4da3..b9c90025fe 100644 --- a/pkg/performanceprofile/controller/performanceprofile/resources/resources.go +++ b/pkg/performanceprofile/controller/performanceprofile/resources/resources.go @@ -83,7 +83,7 @@ func GetClusterOperator(ctx context.Context, cli client.Client) (*apiconfigv1.Cl func CreateOrUpdateMachineConfig(ctx context.Context, cli client.Client, mc *mcov1.MachineConfig) error { _, err := GetMachineConfig(ctx, cli, mc.Name) if errors.IsNotFound(err) { - klog.Infof("Create machine-config %q", mc.Name) + klog.V(1).Infof("Create machine-config %q", mc.Name) if err := cli.Create(ctx, mc); err != nil { return err } @@ -94,7 +94,7 @@ func CreateOrUpdateMachineConfig(ctx context.Context, cli client.Client, mc *mco return err } - klog.Infof("Update machine-config %q", mc.Name) + klog.V(2).Infof("Update machine-config %q", mc.Name) return cli.Update(ctx, mc) } @@ -162,7 +162,7 @@ func GetMutatedKubeletConfig(ctx context.Context, cli client.Client, kc *mcov1.K func CreateOrUpdateKubeletConfig(ctx context.Context, cli client.Client, kc *mcov1.KubeletConfig) error { _, err := GetKubeletConfig(ctx, cli, kc.Name) if errors.IsNotFound(err) { - klog.Infof("Create kubelet-config %q", kc.Name) + klog.V(1).Infof("Create kubelet-config %q", kc.Name) if err := cli.Create(ctx, kc); err != nil { return err } @@ -173,7 +173,7 @@ func CreateOrUpdateKubeletConfig(ctx context.Context, cli client.Client, kc *mco return err } - klog.Infof("Update kubelet-config %q", kc.Name) + klog.V(2).Infof("Update kubelet-config %q", kc.Name) return cli.Update(ctx, kc) } @@ -232,7 +232,7 @@ func CreateOrUpdateTuned(ctx context.Context, cli client.Client, tuned *tunedv1. _, err := GetTuned(ctx, cli, tuned.Name, tuned.Namespace) if errors.IsNotFound(err) { - klog.Infof("Create tuned %q under the namespace %q", tuned.Name, tuned.Namespace) + klog.V(1).Infof("Create tuned %q in the namespace %q", tuned.Name, tuned.Namespace) if err := cli.Create(ctx, tuned); err != nil { return err } @@ -243,7 +243,7 @@ func CreateOrUpdateTuned(ctx context.Context, cli client.Client, tuned *tunedv1. return err } - klog.Infof("Update tuned %q under the namespace %q", tuned.Name, tuned.Namespace) + klog.V(2).Infof("Update tuned %q in the namespace %q", tuned.Name, tuned.Namespace) return cli.Update(ctx, tuned) } @@ -320,7 +320,7 @@ func GetMutatedRuntimeClass(ctx context.Context, cli client.Client, runtimeClass func CreateOrUpdateRuntimeClass(ctx context.Context, cli client.Client, runtimeClass *nodev1.RuntimeClass) error { _, err := GetRuntimeClass(ctx, cli, runtimeClass.Name) if errors.IsNotFound(err) { - klog.Infof("Create runtime class %q", runtimeClass.Name) + klog.V(1).Infof("Create runtime class %q", runtimeClass.Name) if err := cli.Create(ctx, runtimeClass); err != nil { return err } @@ -331,7 +331,7 @@ func CreateOrUpdateRuntimeClass(ctx context.Context, cli client.Client, runtimeC return err } - klog.Infof("Update runtime class %q", runtimeClass.Name) + klog.V(2).Infof("Update runtime class %q", runtimeClass.Name) return cli.Update(ctx, runtimeClass) } diff --git a/pkg/performanceprofile/controller/performanceprofile/status/writer.go b/pkg/performanceprofile/controller/performanceprofile/status/writer.go index 8bd0d89b31..7c72cf2f62 100644 --- a/pkg/performanceprofile/controller/performanceprofile/status/writer.go +++ b/pkg/performanceprofile/controller/performanceprofile/status/writer.go @@ -3,6 +3,7 @@ package status import ( "context" "fmt" + "github.com/openshift/cluster-node-tuning-operator/pkg/performanceprofile/controller/performanceprofile/resources" "k8s.io/apimachinery/pkg/types" @@ -128,6 +129,6 @@ func (w *writer) update(ctx context.Context, profile *performancev2.PerformanceP return nil } - klog.Infof("Updating the performance profile %q status", profile.Name) + klog.V(4).Infof("Updating the performance profile %q status", profile.Name) return w.Client.Status().Update(ctx, profileCopy) } diff --git a/pkg/performanceprofile/controller/performanceprofile_controller.go b/pkg/performanceprofile/controller/performanceprofile_controller.go index 90b2638515..0554c339e5 100644 --- a/pkg/performanceprofile/controller/performanceprofile_controller.go +++ b/pkg/performanceprofile/controller/performanceprofile_controller.go @@ -290,7 +290,7 @@ func (r *PerformanceProfileReconciler) ctrRuntimeConfToPerformanceProfile(ctx co klog.Errorf("failed to get container runtime config; name=%q err=%v", ctrRuntimeConfObj.GetName(), err) return nil } - klog.Infof("reconciling from ContainerRuntimeConfig %q", ctrcfg.Name) + klog.V(2).Infof("reconciling from ContainerRuntimeConfig %q", ctrcfg.Name) selector, err := metav1.LabelSelectorAsSelector(ctrcfg.Spec.MachineConfigPoolSelector) if err != nil { @@ -309,7 +309,7 @@ func (r *PerformanceProfileReconciler) ctrRuntimeConfToPerformanceProfile(ctx co return nil } - klog.Infof("reconciling from ContainerRuntimeConfig %q selector %v: %d MCPs", ctrcfg.Name, ctrcfg.Spec.MachineConfigPoolSelector, len(mcps.Items)) + klog.V(2).Infof("reconciling from ContainerRuntimeConfig %q selector %v: %d MCPs", ctrcfg.Name, ctrcfg.Spec.MachineConfigPoolSelector, len(mcps.Items)) profiles := &performancev2.PerformanceProfileList{} err = r.List(ctx, profiles) @@ -383,7 +383,7 @@ func (r *PerformanceProfileReconciler) Reconcile(ctx context.Context, req ctrl.R operatorReleaseVersion := os.Getenv("RELEASE_VERSION") operandReleaseVersion := operatorv1helpers.FindOperandVersion(co.Status.Versions, tunedv1.TunedOperandName) if operandReleaseVersion == nil || operatorReleaseVersion != operandReleaseVersion.Version { - // Upgrade in progress + // Upgrade in progress. Should happen rarely, so we omit V() klog.Infof("operator and operand release versions do not match") return reconcile.Result{RequeueAfter: 10 * time.Second}, nil }