From 02f8e60eb7812e1886ff5e5f0c664b4cabb81649 Mon Sep 17 00:00:00 2001 From: souravbiswassanto Date: Fri, 8 Nov 2024 16:28:29 +0600 Subject: [PATCH] remove unnecessary logs Signed-off-by: souravbiswassanto --- pkg/controllers/apps/pod.go | 3 --- pkg/controllers/apps/sidekick.go | 5 ----- pkg/controllers/apps/sidekick_controller.go | 1 + 3 files changed, 1 insertion(+), 8 deletions(-) diff --git a/pkg/controllers/apps/pod.go b/pkg/controllers/apps/pod.go index 692913a..77d369f 100644 --- a/pkg/controllers/apps/pod.go +++ b/pkg/controllers/apps/pod.go @@ -23,7 +23,6 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/klog/v2" cu "kmodules.xyz/client-go/client" core_util "kmodules.xyz/client-go/core/v1" ctrl "sigs.k8s.io/controller-runtime" @@ -109,8 +108,6 @@ func (r *SidekickReconciler) setDeletionInitiatorAnnotation(ctx context.Context, return po }, ) - klog.Infoln("pod annotation set: ", pod.Annotations) - return err } diff --git a/pkg/controllers/apps/sidekick.go b/pkg/controllers/apps/sidekick.go index b227060..45b834b 100644 --- a/pkg/controllers/apps/sidekick.go +++ b/pkg/controllers/apps/sidekick.go @@ -23,7 +23,6 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/klog/v2" "k8s.io/utils/ptr" cu "kmodules.xyz/client-go/client" core_util "kmodules.xyz/client-go/core/v1" @@ -96,11 +95,9 @@ func (r *SidekickReconciler) calculateSidekickPhase(ctx context.Context, sidekic if err != nil && !errors.IsNotFound(err) { return sidekick.Status.Phase, err } - if err == nil { restartCounter := getContainerRestartCounts(&pod) podUID := string(pod.GetUID()) - sidekick.Status.ContainerRestartCountsPerPod[podUID] = restartCounter if pod.Status.Phase == corev1.PodFailed && pod.ObjectMeta.DeletionTimestamp == nil { sidekick.Status.FailureCount[podUID] = true @@ -110,7 +107,6 @@ func (r *SidekickReconciler) calculateSidekickPhase(ctx context.Context, sidekic sidekick.Status.FailureCount[podUID] = false } } - } phase := r.getSidekickPhase(sidekick, &pod) @@ -170,7 +166,6 @@ func getTotalBackOffCounts(sidekick *appsv1alpha1.Sidekick) int32 { if sidekick.Spec.BackoffLimit == nil { sidekick.Spec.BackoffLimit = ptr.To(int32(0)) } - klog.Infoln(*sidekick.Spec.BackoffLimit, totalContainerRestartCount, failureCount) return failureCount + totalContainerRestartCount } diff --git a/pkg/controllers/apps/sidekick_controller.go b/pkg/controllers/apps/sidekick_controller.go index 08ecf16..d42c965 100644 --- a/pkg/controllers/apps/sidekick_controller.go +++ b/pkg/controllers/apps/sidekick_controller.go @@ -141,6 +141,7 @@ func (r *SidekickReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c if e2 == nil { expectedHash := meta.GenerationHash(&sidekick) actualHash := pod.Annotations[keyHash] + if expectedHash != actualHash || leader.Name != pod.Annotations[keyLeader] || leader.Spec.NodeName != pod.Spec.NodeName || (pod.Status.Phase == corev1.PodFailed && sidekick.Spec.RestartPolicy == corev1.RestartPolicyNever) {