Skip to content

Commit

Permalink
pao:log: small refining
Browse files Browse the repository at this point in the history
- Move logs to V(4)
- Fix typos
- Remove redundant spacing
- Consistent HyperShift naming

Signed-off-by: Talor Itzhak <[email protected]>
  • Loading branch information
Tal-or committed Jun 6, 2024
1 parent dd75be3 commit 2391f85
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 21 deletions.
6 changes: 3 additions & 3 deletions cmd/cluster-node-tuning-operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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{}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 2391f85

Please sign in to comment.