Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: add common controller util #977

Merged
merged 2 commits into from
Jun 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 9 additions & 16 deletions controllers/redis_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@

redisv1beta2 "github.com/OT-CONTAINER-KIT/redis-operator/api/v1beta2"
"github.com/OT-CONTAINER-KIT/redis-operator/k8sutils"
intctrlutil "github.com/OT-CONTAINER-KIT/redis-operator/pkg/controllerutil"
"github.com/go-logr/logr"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/dynamic"
"k8s.io/client-go/kubernetes"
Expand All @@ -47,36 +47,29 @@

err := r.Client.Get(context.TODO(), req.NamespacedName, instance)
if err != nil {
if errors.IsNotFound(err) {
return ctrl.Result{}, nil
}
return ctrl.Result{}, err
return intctrlutil.RequeueWithErrorChecking(err, reqLogger, "failed to get redis instance")
}
if instance.ObjectMeta.GetDeletionTimestamp() != nil {
if err = k8sutils.HandleRedisFinalizer(r.Client, r.K8sClient, r.Log, instance); err != nil {
return ctrl.Result{}, err
return intctrlutil.RequeueWithError(err, reqLogger, "failed to handle redis finalizer")

Check warning on line 54 in controllers/redis_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/redis_controller.go#L54

Added line #L54 was not covered by tests
}
return ctrl.Result{}, nil
return intctrlutil.Reconciled()

Check warning on line 56 in controllers/redis_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/redis_controller.go#L56

Added line #L56 was not covered by tests
}
if _, found := instance.ObjectMeta.GetAnnotations()["redis.opstreelabs.in/skip-reconcile"]; found {
reqLogger.Info("Found annotations redis.opstreelabs.in/skip-reconcile, so skipping reconcile")
return ctrl.Result{RequeueAfter: time.Second * 10}, nil
return intctrlutil.RequeueAfter(reqLogger, time.Second*10, "found skip reconcile annotation")

Check warning on line 59 in controllers/redis_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/redis_controller.go#L59

Added line #L59 was not covered by tests
}
if err = k8sutils.AddFinalizer(instance, k8sutils.RedisFinalizer, r.Client); err != nil {
return ctrl.Result{}, err
return intctrlutil.RequeueWithError(err, reqLogger, "failed to add finalizer")
}

err = k8sutils.CreateStandaloneRedis(instance, r.K8sClient)
if err != nil {
return ctrl.Result{}, err
return intctrlutil.RequeueWithError(err, reqLogger, "failed to create redis")

Check warning on line 66 in controllers/redis_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/redis_controller.go#L66

Added line #L66 was not covered by tests
}
err = k8sutils.CreateStandaloneService(instance, r.K8sClient)
if err != nil {
return ctrl.Result{}, err
return intctrlutil.RequeueWithError(err, reqLogger, "failed to create service")

Check warning on line 70 in controllers/redis_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/redis_controller.go#L70

Added line #L70 was not covered by tests
}

reqLogger.Info("Will reconcile redis operator in again 10 seconds")
return ctrl.Result{RequeueAfter: time.Second * 10}, nil
return intctrlutil.RequeueAfter(reqLogger, time.Second*10, "requeue after 10 seconds")
}

// SetupWithManager sets up the controller with the Manager.
Expand Down
61 changes: 27 additions & 34 deletions controllers/rediscluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"github.com/OT-CONTAINER-KIT/redis-operator/api/status"
redisv1beta2 "github.com/OT-CONTAINER-KIT/redis-operator/api/v1beta2"
"github.com/OT-CONTAINER-KIT/redis-operator/k8sutils"
intctrlutil "github.com/OT-CONTAINER-KIT/redis-operator/pkg/controllerutil"
"github.com/go-logr/logr"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime"
Expand All @@ -50,20 +51,16 @@

err := r.Client.Get(context.TODO(), req.NamespacedName, instance)
if err != nil {
if errors.IsNotFound(err) {
return ctrl.Result{}, nil
}
return ctrl.Result{}, err
return intctrlutil.RequeueWithErrorChecking(err, reqLogger, "failed to get redis cluster instance")
}
if instance.ObjectMeta.GetDeletionTimestamp() != nil {
if err = k8sutils.HandleRedisClusterFinalizer(r.Client, r.K8sClient, r.Log, instance); err != nil {
return ctrl.Result{}, err
return intctrlutil.RequeueWithError(err, reqLogger, "failed to handle redis cluster finalizer")

Check warning on line 58 in controllers/rediscluster_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/rediscluster_controller.go#L58

Added line #L58 was not covered by tests
}
return ctrl.Result{}, nil
return intctrlutil.Reconciled()

Check warning on line 60 in controllers/rediscluster_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/rediscluster_controller.go#L60

Added line #L60 was not covered by tests
}
if _, found := instance.ObjectMeta.GetAnnotations()["rediscluster.opstreelabs.in/skip-reconcile"]; found {
reqLogger.Info("Found annotations rediscluster.opstreelabs.in/skip-reconcile, so skipping reconcile")
return ctrl.Result{RequeueAfter: time.Second * 10}, nil
return intctrlutil.RequeueAfter(reqLogger, time.Second*10, "found skip reconcile annotation")

Check warning on line 63 in controllers/rediscluster_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/rediscluster_controller.go#L63

Added line #L63 was not covered by tests
}
instance.SetDefault()

Expand All @@ -72,7 +69,7 @@
totalReplicas := leaderReplicas + followerReplicas

if err = k8sutils.AddFinalizer(instance, k8sutils.RedisClusterFinalizer, r.Client); err != nil {
return ctrl.Result{}, err
return intctrlutil.RequeueWithError(err, reqLogger, "failed to add finalizer")
}

// Check if the cluster is downscaled
Expand All @@ -98,41 +95,41 @@
// Step 3 Rebalance the cluster
k8sutils.RebalanceRedisCluster(r.K8sClient, r.Log, instance)
reqLogger.Info("Redis cluster is downscaled... Rebalancing the cluster is done")
return ctrl.Result{RequeueAfter: time.Second * 10}, nil
return intctrlutil.RequeueAfter(reqLogger, time.Second*10, "")

Check warning on line 98 in controllers/rediscluster_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/rediscluster_controller.go#L98

Added line #L98 was not covered by tests
}

// Mark the cluster status as initializing if there are no leader or follower nodes
if (instance.Status.ReadyLeaderReplicas == 0 && instance.Status.ReadyFollowerReplicas == 0) ||
instance.Status.ReadyLeaderReplicas != leaderReplicas {
err = k8sutils.UpdateRedisClusterStatus(instance, status.RedisClusterInitializing, status.InitializingClusterLeaderReason, instance.Status.ReadyLeaderReplicas, instance.Status.ReadyFollowerReplicas, r.Dk8sClient)
if err != nil {
return ctrl.Result{}, err
return intctrlutil.RequeueWithError(err, reqLogger, "")

Check warning on line 106 in controllers/rediscluster_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/rediscluster_controller.go#L106

Added line #L106 was not covered by tests
}
}

if leaderReplicas != 0 {
err = k8sutils.CreateRedisLeaderService(instance, r.K8sClient)
if err != nil {
return ctrl.Result{}, err
return intctrlutil.RequeueWithError(err, reqLogger, "")

Check warning on line 113 in controllers/rediscluster_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/rediscluster_controller.go#L113

Added line #L113 was not covered by tests
}
}
err = k8sutils.CreateRedisLeader(instance, r.K8sClient)
if err != nil {
return ctrl.Result{}, err
return intctrlutil.RequeueWithError(err, reqLogger, "")

Check warning on line 118 in controllers/rediscluster_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/rediscluster_controller.go#L118

Added line #L118 was not covered by tests
}

err = k8sutils.ReconcileRedisPodDisruptionBudget(instance, "leader", instance.Spec.RedisLeader.PodDisruptionBudget, r.K8sClient)
if err != nil {
return ctrl.Result{}, err
return intctrlutil.RequeueWithError(err, reqLogger, "")

Check warning on line 123 in controllers/rediscluster_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/rediscluster_controller.go#L123

Added line #L123 was not covered by tests
}

// todo: remove me after watch statefulset in controller
redisLeaderInfo, err := k8sutils.GetStatefulSet(r.K8sClient, r.Log, instance.GetNamespace(), instance.GetName()+"-leader")
if err != nil {
if errors.IsNotFound(err) {
return ctrl.Result{RequeueAfter: time.Second * 60}, nil
return intctrlutil.RequeueAfter(reqLogger, time.Second*60, "")

Check warning on line 130 in controllers/rediscluster_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/rediscluster_controller.go#L130

Added line #L130 was not covered by tests
}
return ctrl.Result{}, err
return intctrlutil.RequeueWithError(err, reqLogger, "")

Check warning on line 132 in controllers/rediscluster_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/rediscluster_controller.go#L132

Added line #L132 was not covered by tests
}

if r.IsStatefulSetReady(ctx, instance.Namespace, instance.Name+"-leader") {
Expand All @@ -141,54 +138,52 @@
instance.Status.ReadyFollowerReplicas != followerReplicas {
err = k8sutils.UpdateRedisClusterStatus(instance, status.RedisClusterInitializing, status.InitializingClusterFollowerReason, leaderReplicas, instance.Status.ReadyFollowerReplicas, r.Dk8sClient)
if err != nil {
return ctrl.Result{}, err
return intctrlutil.RequeueWithError(err, reqLogger, "")

Check warning on line 141 in controllers/rediscluster_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/rediscluster_controller.go#L141

Added line #L141 was not covered by tests
}
}
// if we have followers create their service.
if followerReplicas != 0 {
err = k8sutils.CreateRedisFollowerService(instance, r.K8sClient)
if err != nil {
return ctrl.Result{}, err
return intctrlutil.RequeueWithError(err, reqLogger, "")

Check warning on line 148 in controllers/rediscluster_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/rediscluster_controller.go#L148

Added line #L148 was not covered by tests
}
}
err = k8sutils.CreateRedisFollower(instance, r.K8sClient)
if err != nil {
return ctrl.Result{}, err
return intctrlutil.RequeueWithError(err, reqLogger, "")

Check warning on line 153 in controllers/rediscluster_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/rediscluster_controller.go#L153

Added line #L153 was not covered by tests
}
err = k8sutils.ReconcileRedisPodDisruptionBudget(instance, "follower", instance.Spec.RedisFollower.PodDisruptionBudget, r.K8sClient)
if err != nil {
return ctrl.Result{}, err
return intctrlutil.RequeueWithError(err, reqLogger, "")

Check warning on line 157 in controllers/rediscluster_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/rediscluster_controller.go#L157

Added line #L157 was not covered by tests
}
}
// todo: remove me after watch statefulset in controller
redisFollowerInfo, err := k8sutils.GetStatefulSet(r.K8sClient, r.Log, instance.GetNamespace(), instance.GetName()+"-follower")
if err != nil {
if errors.IsNotFound(err) {
return ctrl.Result{RequeueAfter: time.Second * 60}, nil
return intctrlutil.RequeueAfter(reqLogger, time.Second*60, "")
}
return ctrl.Result{}, err
return intctrlutil.RequeueWithError(err, reqLogger, "")

Check warning on line 166 in controllers/rediscluster_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/rediscluster_controller.go#L166

Added line #L166 was not covered by tests
}

if leaderReplicas == 0 {
reqLogger.Info("Redis leaders Cannot be 0", "Ready.Replicas", strconv.Itoa(int(redisLeaderInfo.Status.ReadyReplicas)), "Expected.Replicas", leaderReplicas)
return ctrl.Result{RequeueAfter: time.Second * 60}, nil
return intctrlutil.RequeueAfter(reqLogger, time.Second*60, "Redis leaders Cannot be 0", "Ready.Replicas", strconv.Itoa(int(redisLeaderInfo.Status.ReadyReplicas)), "Expected.Replicas", leaderReplicas)

Check warning on line 170 in controllers/rediscluster_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/rediscluster_controller.go#L170

Added line #L170 was not covered by tests
}

if !(r.IsStatefulSetReady(ctx, instance.Namespace, instance.Name+"-leader") && r.IsStatefulSetReady(ctx, instance.Namespace, instance.Name+"-follower")) {
reqLogger.Info("Redis leader and follower nodes are not ready yet")
return ctrl.Result{RequeueAfter: time.Second * 30}, nil
return intctrlutil.RequeueAfter(reqLogger, time.Second*60, "Redis leader and follower nodes are not ready yet")

Check warning on line 174 in controllers/rediscluster_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/rediscluster_controller.go#L174

Added line #L174 was not covered by tests
}

// Mark the cluster status as bootstrapping if all the leader and follower nodes are ready
if !(instance.Status.ReadyLeaderReplicas == leaderReplicas && instance.Status.ReadyFollowerReplicas == followerReplicas) {
err = k8sutils.UpdateRedisClusterStatus(instance, status.RedisClusterBootstrap, status.BootstrapClusterReason, leaderReplicas, followerReplicas, r.Dk8sClient)
if err != nil {
return ctrl.Result{}, err
return intctrlutil.RequeueWithError(err, reqLogger, "")

Check warning on line 181 in controllers/rediscluster_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/rediscluster_controller.go#L181

Added line #L181 was not covered by tests
}
}

if nc := k8sutils.CheckRedisNodeCount(ctx, r.K8sClient, r.Log, instance, ""); nc != totalReplicas {
reqLogger.Info("Creating redis cluster by executing cluster creation commands", "Leaders.Ready", strconv.Itoa(int(redisLeaderInfo.Status.ReadyReplicas)), "Followers.Ready", strconv.Itoa(int(redisFollowerInfo.Status.ReadyReplicas)))
reqLogger.Info("Creating redis cluster by executing cluster creation commands", "Leaders.Ready", redisLeaderInfo.Status.ReadyReplicas, "Followers.Ready", redisFollowerInfo.Status.ReadyReplicas)

Check warning on line 186 in controllers/rediscluster_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/rediscluster_controller.go#L186

Added line #L186 was not covered by tests
leaderCount := k8sutils.CheckRedisNodeCount(ctx, r.K8sClient, r.Log, instance, "leader")
if leaderCount != leaderReplicas {
reqLogger.Info("Not all leader are part of the cluster...", "Leaders.Count", leaderCount, "Instance.Size", leaderReplicas)
Expand All @@ -211,16 +206,15 @@
reqLogger.Info("no follower/replicas configured, skipping replication configuration", "Leaders.Count", leaderCount, "Leader.Size", leaderReplicas, "Follower.Replicas", followerReplicas)
}
}
reqLogger.Info("Redis cluster count is not desired", "Current.Count", nc, "Desired.Count", totalReplicas)
return ctrl.Result{RequeueAfter: time.Second * 60}, nil
return intctrlutil.RequeueAfter(reqLogger, time.Second*60, "Redis cluster count is not desired", "Current.Count", nc, "Desired.Count", totalReplicas)

Check warning on line 209 in controllers/rediscluster_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/rediscluster_controller.go#L209

Added line #L209 was not covered by tests
}

reqLogger.Info("Redis cluster count is desired")
if int(totalReplicas) > 1 && k8sutils.CheckRedisClusterState(ctx, r.K8sClient, r.Log, instance) >= int(totalReplicas)-1 {
reqLogger.Info("Redis leader is not desired, executing failover operation")
err = k8sutils.ExecuteFailoverOperation(ctx, r.K8sClient, r.Log, instance)
if err != nil {
return ctrl.Result{}, err
return intctrlutil.RequeueWithError(err, reqLogger, "")

Check warning on line 217 in controllers/rediscluster_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/rediscluster_controller.go#L217

Added line #L217 was not covered by tests
}
}

Expand All @@ -234,12 +228,11 @@
if k8sutils.RedisClusterStatusHealth(ctx, r.K8sClient, r.Log, instance) {
err = k8sutils.UpdateRedisClusterStatus(instance, status.RedisClusterReady, status.ReadyClusterReason, leaderReplicas, followerReplicas, r.Dk8sClient)
if err != nil {
return ctrl.Result{}, err
return intctrlutil.RequeueWithError(err, reqLogger, "")

Check warning on line 231 in controllers/rediscluster_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/rediscluster_controller.go#L231

Added line #L231 was not covered by tests
}
}
}
reqLogger.Info("Will reconcile redis cluster operator in again 10 seconds")
return ctrl.Result{RequeueAfter: time.Second * 10}, nil
return intctrlutil.RequeueAfter(reqLogger, time.Second*10, "")

Check warning on line 235 in controllers/rediscluster_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/rediscluster_controller.go#L235

Added line #L235 was not covered by tests
}

// SetupWithManager sets up the controller with the Manager.
Expand Down
34 changes: 14 additions & 20 deletions controllers/redisreplication_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

redisv1beta2 "github.com/OT-CONTAINER-KIT/redis-operator/api/v1beta2"
"github.com/OT-CONTAINER-KIT/redis-operator/k8sutils"
intctrlutil "github.com/OT-CONTAINER-KIT/redis-operator/pkg/controllerutil"
"github.com/go-logr/logr"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/dynamic"
"k8s.io/client-go/kubernetes"
Expand All @@ -34,50 +34,45 @@

err := r.Client.Get(context.TODO(), req.NamespacedName, instance)
if err != nil {
if errors.IsNotFound(err) {
return ctrl.Result{}, nil
}
return ctrl.Result{}, err
return intctrlutil.RequeueWithErrorChecking(err, reqLogger, "")
}
if instance.ObjectMeta.GetDeletionTimestamp() != nil {
if err = k8sutils.HandleRedisReplicationFinalizer(r.Client, r.K8sClient, r.Log, instance); err != nil {
return ctrl.Result{}, err
return intctrlutil.RequeueWithError(err, reqLogger, "")

Check warning on line 41 in controllers/redisreplication_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/redisreplication_controller.go#L41

Added line #L41 was not covered by tests
}
return ctrl.Result{}, nil
return intctrlutil.Reconciled()

Check warning on line 43 in controllers/redisreplication_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/redisreplication_controller.go#L43

Added line #L43 was not covered by tests
}
if _, found := instance.ObjectMeta.GetAnnotations()["redisreplication.opstreelabs.in/skip-reconcile"]; found {
reqLogger.Info("Found annotations redisreplication.opstreelabs.in/skip-reconcile, so skipping reconcile")
return ctrl.Result{RequeueAfter: time.Second * 10}, nil
return intctrlutil.RequeueAfter(reqLogger, time.Second*10, "found skip reconcile annotation")

Check warning on line 46 in controllers/redisreplication_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/redisreplication_controller.go#L46

Added line #L46 was not covered by tests
}

leaderReplicas := int32(1)
followerReplicas := instance.Spec.GetReplicationCounts("replication") - leaderReplicas
totalReplicas := leaderReplicas + followerReplicas

if err = k8sutils.AddFinalizer(instance, k8sutils.RedisReplicationFinalizer, r.Client); err != nil {
return ctrl.Result{}, err
return intctrlutil.RequeueWithError(err, reqLogger, "")
}

err = k8sutils.CreateReplicationRedis(instance, r.K8sClient)
if err != nil {
return ctrl.Result{}, err
return intctrlutil.RequeueWithError(err, reqLogger, "")

Check warning on line 59 in controllers/redisreplication_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/redisreplication_controller.go#L59

Added line #L59 was not covered by tests
}
err = k8sutils.CreateReplicationService(instance, r.K8sClient)
if err != nil {
return ctrl.Result{}, err
return intctrlutil.RequeueWithError(err, reqLogger, "")

Check warning on line 63 in controllers/redisreplication_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/redisreplication_controller.go#L63

Added line #L63 was not covered by tests
}

// Set Pod distruptiuon Budget Later

redisReplicationInfo, err := k8sutils.GetStatefulSet(r.K8sClient, r.Log, instance.GetNamespace(), instance.GetName())
if err != nil {
return ctrl.Result{RequeueAfter: time.Second * 60}, err
return intctrlutil.RequeueAfter(reqLogger, time.Second*60, "")

Check warning on line 70 in controllers/redisreplication_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/redisreplication_controller.go#L70

Added line #L70 was not covered by tests
}

// Check that the Leader and Follower are ready in redis replication
if redisReplicationInfo.Status.ReadyReplicas != totalReplicas {
reqLogger.Info("Redis replication nodes are not ready yet", "Ready.Replicas", strconv.Itoa(int(redisReplicationInfo.Status.ReadyReplicas)), "Expected.Replicas", totalReplicas)
return ctrl.Result{RequeueAfter: time.Second * 60}, nil
return intctrlutil.RequeueAfter(reqLogger, time.Second*60, "Redis replication nodes are not ready yet", "Ready.Replicas", redisReplicationInfo.Status.ReadyReplicas, "Expected.Replicas", totalReplicas)
}

var realMaster string
Expand All @@ -90,18 +85,17 @@
realMaster = masterNodes[0]
}
if err = k8sutils.CreateMasterSlaveReplication(ctx, r.K8sClient, r.Log, instance, masterNodes, realMaster); err != nil {
return ctrl.Result{RequeueAfter: time.Second * 60}, err
return intctrlutil.RequeueAfter(reqLogger, time.Second*60, "")

Check warning on line 88 in controllers/redisreplication_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/redisreplication_controller.go#L88

Added line #L88 was not covered by tests
}
}
realMaster = k8sutils.GetRedisReplicationRealMaster(ctx, r.K8sClient, r.Log, instance, masterNodes)
if err = r.UpdateRedisReplicationMaster(ctx, instance, realMaster); err != nil {
return ctrl.Result{}, err
return intctrlutil.RequeueWithError(err, reqLogger, "")

Check warning on line 93 in controllers/redisreplication_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/redisreplication_controller.go#L93

Added line #L93 was not covered by tests
}
if err = r.UpdateRedisPodRoleLabel(ctx, instance, realMaster); err != nil {
return ctrl.Result{}, err
return intctrlutil.RequeueWithError(err, reqLogger, "")

Check warning on line 96 in controllers/redisreplication_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/redisreplication_controller.go#L96

Added line #L96 was not covered by tests
}
reqLogger.Info("Will reconcile redis operator in again 10 seconds")
return ctrl.Result{RequeueAfter: time.Second * 10}, nil
return intctrlutil.RequeueAfter(reqLogger, time.Second*10, "")

Check warning on line 98 in controllers/redisreplication_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/redisreplication_controller.go#L98

Added line #L98 was not covered by tests
}

func (r *RedisReplicationReconciler) UpdateRedisReplicationMaster(ctx context.Context, instance *redisv1beta2.RedisReplication, masterNode string) error {
Expand Down
Loading
Loading