From 2391f85e72b3c97046b533ef59e92c3dfb0e20a8 Mon Sep 17 00:00:00 2001 From: Talor Itzhak Date: Sun, 2 Jun 2024 16:35:04 +0300 Subject: [PATCH] pao:log: small refining - Move logs to V(4) - Fix typos - Remove redundant spacing - Consistent HyperShift naming Signed-off-by: Talor Itzhak --- cmd/cluster-node-tuning-operator/main.go | 6 +++--- .../components/handler/handler.go | 8 ++++---- .../hypershift/components/handler.go | 13 ++++--------- .../controller/performanceprofile/status/status.go | 2 +- .../controller/performanceprofile_controller.go | 8 ++++---- 5 files changed, 16 insertions(+), 21 deletions(-) diff --git a/cmd/cluster-node-tuning-operator/main.go b/cmd/cluster-node-tuning-operator/main.go index 4683867b3d..a60ba1586b 100644 --- a/cmd/cluster-node-tuning-operator/main.go +++ b/cmd/cluster-node-tuning-operator/main.go @@ -205,7 +205,7 @@ func operatorRun() { klog.Exitf("unable to create PerformanceProfile v2 webhook: %v", err) } } else { - // Hypershift configuration + // HyperShift configuration restConfig, err := ntoclient.GetInClusterConfig() if err != nil { klog.Exitf("unable to create get InClusterConfiguration while creating PerformanceProfile controller: %v", err) @@ -228,11 +228,11 @@ func operatorRun() { } managementCluster, err := cluster.New(restConfig, fOps) if err != nil { - klog.Exitf("unable to create ManagementCluster while creating PerformanceProfile controller : %v", err) + klog.Exitf("unable to create ManagementCluster while creating PerformanceProfile controller: %v", err) } if err := mgr.Add(managementCluster); err != nil { - klog.Exitf("unable to add ManagementCluster to manger while creating PerformanceProfile controller : %v", err) + klog.Exitf("unable to add ManagementCluster to manger while creating PerformanceProfile controller: %v", err) } if err = (&paocontroller.PerformanceProfileReconciler{ // dataPlaneClient diff --git a/pkg/performanceprofile/controller/performanceprofile/components/handler/handler.go b/pkg/performanceprofile/controller/performanceprofile/components/handler/handler.go index 04bdfe0cdc..2205037622 100644 --- a/pkg/performanceprofile/controller/performanceprofile/components/handler/handler.go +++ b/pkg/performanceprofile/controller/performanceprofile/components/handler/handler.go @@ -146,23 +146,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 under the namespace %q", tunedName, components.NamespaceNodeTuningOperator) + klog.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 under the cluster", name) + klog.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 under the cluster", name) + klog.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 under the cluster", name) + klog.Infof("Machine Config %q exists in the cluster", name) return true } return false diff --git a/pkg/performanceprofile/controller/performanceprofile/hypershift/components/handler.go b/pkg/performanceprofile/controller/performanceprofile/hypershift/components/handler.go index f6d3ade344..2038ab7868 100644 --- a/pkg/performanceprofile/controller/performanceprofile/hypershift/components/handler.go +++ b/pkg/performanceprofile/controller/performanceprofile/hypershift/components/handler.go @@ -76,34 +76,29 @@ func (h *handler) Exists(ctx context.Context, profileName string) bool { operatorNamespace := config.OperatorNamespace() tunedName := components.GetComponentName(profileName, components.ProfileNamePerformance) if _, err := resources.GetTuned(ctx, h.controlPlaneClient, tunedName, operatorNamespace); !k8serrors.IsNotFound(err) { - klog.Infof("Tuned %q is still exists under the namespace %q", tunedName, operatorNamespace) + klog.Infof("Tuned %q is still exists in the namespace %q", tunedName, operatorNamespace) return true } name := components.GetComponentName(profileName, components.ComponentNamePrefix) if _, err := resources.GetKubeletConfig(ctx, h.controlPlaneClient, name); !k8serrors.IsNotFound(err) { - klog.Infof("Kubelet Config %q exists under the namespace %q", name, operatorNamespace) + klog.Infof("Kubelet Config %q exists in the namespace %q", name, operatorNamespace) return true } if _, err := resources.GetRuntimeClass(ctx, h.dataPlaneClient, name); !k8serrors.IsNotFound(err) { - klog.Infof("Runtime class %q exists under the hosted cluster", name) + klog.Infof("Runtime class %q exists in the hosted cluster", name) return true } if _, err := resources.GetMachineConfig(ctx, h.controlPlaneClient, machineconfig.GetMachineConfigName(profileName)); !k8serrors.IsNotFound(err) { - klog.Infof("Machine Config %q exists under the namespace %q", name, operatorNamespace) + klog.Infof("Machine Config %q exists in the namespace %q", name, operatorNamespace) return true } return false } func (h *handler) Apply(ctx context.Context, obj client.Object, recorder record.EventRecorder, options *components.Options) error { - // TODO handle naming - // Jose left the following comment: - // Make PerformanceProfile names unique if a PerformanceProfile is duplicated across NodePools - // for example, if one ConfigMap is referenced in multiple NodePools - // need to check whether this comment is relevant or not. instance, ok := obj.(*corev1.ConfigMap) if !ok { return fmt.Errorf("wrong type conversion; want=ConfigMap got=%T", obj) diff --git a/pkg/performanceprofile/controller/performanceprofile/status/status.go b/pkg/performanceprofile/controller/performanceprofile/status/status.go index d2b78f9877..d090fdf712 100644 --- a/pkg/performanceprofile/controller/performanceprofile/status/status.go +++ b/pkg/performanceprofile/controller/performanceprofile/status/status.go @@ -179,7 +179,7 @@ func GetKubeletConditionsByProfile(ctx context.Context, client client.Client, pr func GetTunedConditionsByProfile(ctx context.Context, cli client.Client, profile *performancev2.PerformanceProfile) ([]conditionsv1.Condition, error) { tunedProfileList := &tunedv1.ProfileList{} if err := cli.List(ctx, tunedProfileList); err != nil { - klog.Errorf("Cannot list Tuned Profiles to match with profile %q : %v", profile.Name, err) + klog.Errorf("Cannot list Tuned Profiles to match with profile %q: %v", profile.Name, err) return nil, err } diff --git a/pkg/performanceprofile/controller/performanceprofile_controller.go b/pkg/performanceprofile/controller/performanceprofile_controller.go index 481e47d952..90b2638515 100644 --- a/pkg/performanceprofile/controller/performanceprofile_controller.go +++ b/pkg/performanceprofile/controller/performanceprofile_controller.go @@ -172,7 +172,7 @@ func (r *PerformanceProfileReconciler) SetupWithManager(mgr ctrl.Manager) error } func (r *PerformanceProfileReconciler) SetupWithManagerForHypershift(mgr ctrl.Manager, managementCluster cluster.Cluster) error { - // Running on hypershift controller should watch for the ConfigMaps created by Hypershift Operator in the + // Running on HyperShift controller should watch for the ConfigMaps created by HyperShift Operator in the // controller namespace with the right label. p := predicate.Funcs{ UpdateFunc: func(ue event.UpdateEvent) bool { @@ -388,8 +388,8 @@ func (r *PerformanceProfileReconciler) Reconcile(ctx context.Context, req ctrl.R return reconcile.Result{RequeueAfter: 10 * time.Second}, nil } - klog.InfoS("Reconciling", "reqNamespace", req.NamespacedName) - defer klog.InfoS("Exit Reconciling", "reqNamespace", req.NamespacedName) + klog.V(4).InfoS("Reconciling", "reqNamespace", req.NamespacedName) + defer klog.V(4).InfoS("Exit Reconciling", "reqNamespace", req.NamespacedName) var instance client.Object instance = &performancev2.PerformanceProfile{} @@ -511,7 +511,7 @@ func hasFinalizer(obj client.Object, finalizer string) bool { func (r *PerformanceProfileReconciler) getAndValidateMCP(ctx context.Context, instance client.Object) (*mcov1.MachineConfigPool, *reconcile.Result, error) { profile, ok := instance.(*performancev2.PerformanceProfile) - // can happen on Hypershift, which expects ConfigMap instead. + // can happen on HyperShift, which expects ConfigMap instead. // but on hypershift we do not have MCPs anyway, so it's fine to return empty here. if !ok { return nil, nil, nil