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

[Fix] : returned both a non-zero result and a non-nil error #705

Merged
merged 1 commit into from
Nov 21, 2023
Merged
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
28 changes: 14 additions & 14 deletions controllers/rediscluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@
totalReplicas := leaderReplicas + followerReplicas

if err = k8sutils.HandleRedisClusterFinalizer(r.Client, r.K8sClient, r.Log, instance); err != nil {
return ctrl.Result{RequeueAfter: time.Second * 60}, err
return ctrl.Result{}, err

Check warning on line 69 in controllers/rediscluster_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/rediscluster_controller.go#L69

Added line #L69 was not covered by tests
}

if err = k8sutils.AddRedisClusterFinalizer(instance, r.Client); err != nil {
return ctrl.Result{RequeueAfter: time.Second * 60}, err
return ctrl.Result{}, err

Check warning on line 73 in controllers/rediscluster_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/rediscluster_controller.go#L73

Added line #L73 was not covered by tests
}

// Check if the cluster is downscaled
Expand Down Expand Up @@ -102,7 +102,7 @@
reqLogger.Info("Redis cluster is downscaled... Rebalancing the cluster is done")
err = k8sutils.UpdateRedisClusterStatus(instance, status.RedisClusterReady, status.ReadyClusterReason, leaderReplicas, leaderReplicas)
if err != nil {
return ctrl.Result{RequeueAfter: time.Second * 10}, err
return ctrl.Result{}, err

Check warning on line 105 in controllers/rediscluster_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/rediscluster_controller.go#L105

Added line #L105 was not covered by tests
}
return ctrl.Result{RequeueAfter: time.Second * 60}, nil
}
Expand All @@ -111,24 +111,24 @@
if instance.Status.ReadyLeaderReplicas == 0 && instance.Status.ReadyFollowerReplicas == 0 {
err = k8sutils.UpdateRedisClusterStatus(instance, status.RedisClusterInitializing, status.InitializingClusterLeaderReason, 0, 0)
if err != nil {
return ctrl.Result{RequeueAfter: time.Second * 10}, err
return ctrl.Result{}, err

Check warning on line 114 in controllers/rediscluster_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/rediscluster_controller.go#L114

Added line #L114 was not covered by tests
}
}

err = k8sutils.CreateRedisLeader(instance)
if err != nil {
return ctrl.Result{RequeueAfter: time.Second * 60}, err
return ctrl.Result{}, err

Check warning on line 120 in controllers/rediscluster_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/rediscluster_controller.go#L120

Added line #L120 was not covered by tests
}
if leaderReplicas != 0 {
err = k8sutils.CreateRedisLeaderService(instance)
if err != nil {
return ctrl.Result{RequeueAfter: time.Second * 60}, err
return ctrl.Result{}, err

Check warning on line 125 in controllers/rediscluster_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/rediscluster_controller.go#L125

Added line #L125 was not covered by tests
}
}

err = k8sutils.ReconcileRedisPodDisruptionBudget(instance, "leader", instance.Spec.RedisLeader.PodDisruptionBudget)
if err != nil {
return ctrl.Result{RequeueAfter: time.Second * 60}, err
return ctrl.Result{}, err

Check warning on line 131 in controllers/rediscluster_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/rediscluster_controller.go#L131

Added line #L131 was not covered by tests
}

redisLeaderInfo, err := k8sutils.GetStatefulSet(instance.Namespace, instance.ObjectMeta.Name+"-leader")
Expand All @@ -145,24 +145,24 @@
if instance.Status.ReadyLeaderReplicas == 0 && instance.Status.ReadyFollowerReplicas == 0 {
err = k8sutils.UpdateRedisClusterStatus(instance, status.RedisClusterInitializing, status.InitializingClusterFollowerReason, leaderReplicas, 0)
if err != nil {
return ctrl.Result{RequeueAfter: time.Second * 10}, err
return ctrl.Result{}, err

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)
if err != nil {
return ctrl.Result{RequeueAfter: time.Second * 60}, err
return ctrl.Result{}, err

Check warning on line 154 in controllers/rediscluster_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/rediscluster_controller.go#L154

Added line #L154 was not covered by tests
}
// if we have followers create their service.
if followerReplicas != 0 {
err = k8sutils.CreateRedisFollowerService(instance)
if err != nil {
return ctrl.Result{RequeueAfter: time.Second * 60}, err
return ctrl.Result{}, err

Check warning on line 160 in controllers/rediscluster_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/rediscluster_controller.go#L160

Added line #L160 was not covered by tests
}
}
err = k8sutils.ReconcileRedisPodDisruptionBudget(instance, "follower", instance.Spec.RedisFollower.PodDisruptionBudget)
if err != nil {
return ctrl.Result{RequeueAfter: time.Second * 60}, err
return ctrl.Result{}, err

Check warning on line 165 in controllers/rediscluster_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/rediscluster_controller.go#L165

Added line #L165 was not covered by tests
}
}
redisFollowerInfo, err := k8sutils.GetStatefulSet(instance.Namespace, instance.ObjectMeta.Name+"-follower")
Expand All @@ -187,7 +187,7 @@
if !(instance.Status.ReadyLeaderReplicas == leaderReplicas && instance.Status.ReadyFollowerReplicas == followerReplicas) {
err = k8sutils.UpdateRedisClusterStatus(instance, status.RedisClusterBootstrap, status.BootstrapClusterReason, leaderReplicas, followerReplicas)
if err != nil {
return ctrl.Result{RequeueAfter: time.Second * 10}, err
return ctrl.Result{}, err

Check warning on line 190 in controllers/rediscluster_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/rediscluster_controller.go#L190

Added line #L190 was not covered by tests
}
}

Expand Down Expand Up @@ -224,7 +224,7 @@
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{RequeueAfter: time.Second * 10}, err
return ctrl.Result{}, err

Check warning on line 227 in controllers/rediscluster_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/rediscluster_controller.go#L227

Added line #L227 was not covered by tests
}
}

Expand All @@ -238,7 +238,7 @@
if instance.Status.ReadyLeaderReplicas == leaderReplicas && instance.Status.ReadyFollowerReplicas == followerReplicas {
err = k8sutils.UpdateRedisClusterStatus(instance, status.RedisClusterReady, status.ReadyClusterReason, leaderReplicas, followerReplicas)
if err != nil {
return ctrl.Result{RequeueAfter: time.Second * 10}, err
return ctrl.Result{}, err

Check warning on line 241 in controllers/rediscluster_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/rediscluster_controller.go#L241

Added line #L241 was not covered by tests
}
}

Expand Down
Loading