From 6d23cc6fedc770d062e27329670075c08ed6300e Mon Sep 17 00:00:00 2001 From: Husni Alhamdani Date: Thu, 9 Jan 2025 11:13:25 +0700 Subject: [PATCH] fix: skip-reconcile annotation still skipping reconcile even the value is false --- pkg/controllers/redis/redis_controller.go | 2 +- pkg/controllers/rediscluster/rediscluster_controller.go | 2 +- pkg/controllers/redisreplication/redisreplication_controller.go | 2 +- pkg/controllers/redissentinel/redissentinel_controller.go | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/controllers/redis/redis_controller.go b/pkg/controllers/redis/redis_controller.go index 199483527..5d47fb04c 100644 --- a/pkg/controllers/redis/redis_controller.go +++ b/pkg/controllers/redis/redis_controller.go @@ -47,7 +47,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu } return intctrlutil.Reconciled() } - if _, found := instance.ObjectMeta.GetAnnotations()["redis.opstreelabs.in/skip-reconcile"]; found { + if value, found := instance.ObjectMeta.GetAnnotations()["redis.opstreelabs.in/skip-reconcile"]; found && value == "true" { return intctrlutil.RequeueAfter(ctx, time.Second*10, "found skip reconcile annotation") } if err = k8sutils.AddFinalizer(ctx, instance, k8sutils.RedisFinalizer, r.Client); err != nil { diff --git a/pkg/controllers/rediscluster/rediscluster_controller.go b/pkg/controllers/rediscluster/rediscluster_controller.go index cba1f6291..e2403e4f1 100644 --- a/pkg/controllers/rediscluster/rediscluster_controller.go +++ b/pkg/controllers/rediscluster/rediscluster_controller.go @@ -60,7 +60,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu } return intctrlutil.Reconciled() } - if _, found := instance.ObjectMeta.GetAnnotations()["rediscluster.opstreelabs.in/skip-reconcile"]; found { + if value, found := instance.ObjectMeta.GetAnnotations()["rediscluster.opstreelabs.in/skip-reconcile"]; found && value == "true" { log.FromContext(ctx).Info("found skip reconcile annotation", "namespace", instance.Namespace, "name", instance.Name) return intctrlutil.RequeueAfter(ctx, time.Second*10, "found skip reconcile annotation") } diff --git a/pkg/controllers/redisreplication/redisreplication_controller.go b/pkg/controllers/redisreplication/redisreplication_controller.go index bc53305f8..54a304833 100644 --- a/pkg/controllers/redisreplication/redisreplication_controller.go +++ b/pkg/controllers/redisreplication/redisreplication_controller.go @@ -124,7 +124,7 @@ func (r *Reconciler) reconcileFinalizer(ctx context.Context, instance *redisv1be } func (r *Reconciler) reconcileAnnotation(ctx context.Context, instance *redisv1beta2.RedisReplication) (ctrl.Result, error) { - if _, found := instance.ObjectMeta.GetAnnotations()["redisreplication.opstreelabs.in/skip-reconcile"]; found { + if value, found := instance.ObjectMeta.GetAnnotations()["redisreplication.opstreelabs.in/skip-reconcile"]; found && value == "true" { log.FromContext(ctx).Info("found skip reconcile annotation", "namespace", instance.Namespace, "name", instance.Name) return intctrlutil.RequeueAfter(ctx, time.Second*10, "found skip reconcile annotation") } diff --git a/pkg/controllers/redissentinel/redissentinel_controller.go b/pkg/controllers/redissentinel/redissentinel_controller.go index 6828cfe88..4ecbb8ea2 100644 --- a/pkg/controllers/redissentinel/redissentinel_controller.go +++ b/pkg/controllers/redissentinel/redissentinel_controller.go @@ -81,7 +81,7 @@ func (r *RedisSentinelReconciler) reconcileFinalizer(ctx context.Context, instan } func (r *RedisSentinelReconciler) reconcileAnnotation(ctx context.Context, instance *redisv1beta2.RedisSentinel) (ctrl.Result, error) { - if _, found := instance.ObjectMeta.GetAnnotations()["redissentinel.opstreelabs.in/skip-reconcile"]; found { + if value, found := instance.ObjectMeta.GetAnnotations()["redissentinel.opstreelabs.in/skip-reconcile"]; found && value == "true" { log.FromContext(ctx).Info("found skip reconcile annotation", "namespace", instance.Namespace, "name", instance.Name) return intctrlutil.RequeueAfter(ctx, time.Second*10, "found skip reconcile annotation") }