From de6ecc96716dac83f4b1479159275728c70799d0 Mon Sep 17 00:00:00 2001 From: Jose Valdes Date: Wed, 27 Nov 2024 16:28:01 -0500 Subject: [PATCH 1/3] [cmd] Log platform type at setup This commit introduces a log to print the platform type of the cluster to enhance the WMCO pod log for better triage. --- cmd/operator/main.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cmd/operator/main.go b/cmd/operator/main.go index 7174177042..341f97a30b 100644 --- a/cmd/operator/main.go +++ b/cmd/operator/main.go @@ -118,6 +118,8 @@ func main() { os.Exit(1) } + setupLog.Info("platform", "type", clusterConfig.Platform()) + // Checking if required files exist before starting the operator requiredFiles := []string{ payload.HostLocalCNIPlugin, From 87704291662f2559b96cb0f4d7fcbaa5713d6e09 Mon Sep 17 00:00:00 2001 From: Jose Valdes Date: Wed, 27 Nov 2024 21:17:51 -0500 Subject: [PATCH 2/3] [controller] Improve RB and CRB creation logging This commit improve the WICD roleBinding and clusterRoleBinding creation log messages with addition information for better correlation. --- controllers/configmap_controller.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/controllers/configmap_controller.go b/controllers/configmap_controller.go index 33e325c19f..b3c9dc3f93 100644 --- a/controllers/configmap_controller.go +++ b/controllers/configmap_controller.go @@ -604,13 +604,15 @@ func (r *ConfigMapReconciler) ensureWICDRoleBinding(ctx context.Context) error { "RoleRef", existingRB.RoleRef.Name, "Subjects", existingRB.Subjects) } // create proper resource if it does not exist - _, err = r.k8sclientset.RbacV1().RoleBindings(r.watchNamespace).Create(ctx, expectedRB, + createdRB, err := r.k8sclientset.RbacV1().RoleBindings(r.watchNamespace).Create(ctx, expectedRB, meta.CreateOptions{}) if err != nil { return fmt.Errorf("unable to create RoleBinding %s/%s: %w", r.watchNamespace, wicdRBACResourceName, err) } r.log.Info("Created resource", "RoleBinding", - kubeTypes.NamespacedName{Namespace: r.watchNamespace, Name: expectedRB.Name}) + kubeTypes.NamespacedName{Namespace: createdRB.Namespace, Name: createdRB.Name}, + "RoleRef", createdRB.RoleRef.Name, "Subjects", createdRB.Subjects) + return nil } @@ -653,9 +655,10 @@ func (r *ConfigMapReconciler) ensureWICDClusterRoleBinding(ctx context.Context) "RoleRef", existingCRB.RoleRef.Name, "Subjects", existingCRB.Subjects) } // create proper resource if it does not exist - _, err = r.k8sclientset.RbacV1().ClusterRoleBindings().Create(ctx, expectedCRB, meta.CreateOptions{}) + createdCRB, err := r.k8sclientset.RbacV1().ClusterRoleBindings().Create(ctx, expectedCRB, meta.CreateOptions{}) if err == nil { - r.log.Info("Created resource", "ClusterRoleBinding", expectedCRB.Name) + r.log.Info("Created resource", "ClusterRoleBinding", createdCRB.Name, + "RoleRef", createdCRB.RoleRef.Name, "Subjects", createdCRB.Subjects) } return err } From a739d43d23a3b44f830a505b8fd8efb34c17ffd7 Mon Sep 17 00:00:00 2001 From: Jose Valdes Date: Wed, 27 Nov 2024 23:19:39 -0500 Subject: [PATCH 3/3] [controller] Fix log message at RB deletion This commit adjust the roleBinding creation log message to correctly show the namespace of the malformed resource existing in the cluster. --- controllers/configmap_controller.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/configmap_controller.go b/controllers/configmap_controller.go index b3c9dc3f93..a65330ddb0 100644 --- a/controllers/configmap_controller.go +++ b/controllers/configmap_controller.go @@ -600,7 +600,7 @@ func (r *ConfigMapReconciler) ensureWICDRoleBinding(ctx context.Context) error { return fmt.Errorf("unable to delete RoleBinding %s/%s: %w", r.watchNamespace, wicdRBACResourceName, err) } r.log.Info("Deleted malformed resource", "RoleBinding", - kubeTypes.NamespacedName{Namespace: r.watchNamespace, Name: existingRB.Name}, + kubeTypes.NamespacedName{Namespace: existingRB.Namespace, Name: existingRB.Name}, "RoleRef", existingRB.RoleRef.Name, "Subjects", existingRB.Subjects) } // create proper resource if it does not exist