Skip to content

Commit dc6edc6

Browse files
author
mluffman
committed
golangci-lint fixes
Signed-off-by: mluffman <mluffman@thoughtmachine.net>
1 parent 74ee4c3 commit dc6edc6

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ fmt:
7070
vet:
7171
go vet ./...
7272

73+
lint: golangci-lint
74+
$(GOLANGCI_LINT) run
75+
7376
# Generate code
7477
generate: controller-gen
7578
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
@@ -207,8 +210,6 @@ kind: $(KIND) ## Download golangci-lint locally if necessary.
207210
$(KIND): $(LOCALBIN)
208211
$(call go-install-tool,$(KIND),sigs.k8s.io/kind,${KIND_VERSION})
209212

210-
211-
212213
.PHONY: kuttl
213214
kuttl: $(KUTTL) ## Download kuttl locally if necessary.
214215
$(KUTTL): $(LOCALBIN)

pkg/controllers/rediscluster/rediscluster_controller.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -195,27 +195,27 @@ func (r *RedisClusterReconciler) Reconcile(ctx context.Context, req ctrl.Request
195195
}
196196
if int(totalReplicas) > 1 && unhealthyNodeCount >= int(totalReplicas)-1 {
197197
reqLogger.Info("healthy leader count does not match desired; attempting to repair disconnected masters")
198-
if err := k8sutils.RepairDisconnectedMasters(ctx, r.K8sClient, r.Log, instance); err != nil {
198+
if err = k8sutils.RepairDisconnectedMasters(ctx, r.K8sClient, r.Log, instance); err != nil {
199199
reqLogger.Error(err, "failed to repair disconnected masters")
200200
}
201201

202-
err := retry.Do(func() error {
203-
unhealthyNodeCount, err := k8sutils.UnhealthyNodesInCluster(ctx, r.K8sClient, r.Log, instance)
204-
if err != nil {
205-
return err
202+
err = retry.Do(func() error {
203+
nc, nErr := k8sutils.UnhealthyNodesInCluster(ctx, r.K8sClient, r.Log, instance)
204+
if nErr != nil {
205+
return nErr
206206
}
207-
if unhealthyNodeCount == 0 {
207+
if nc == 0 {
208208
return nil
209209
}
210-
return fmt.Errorf("%d unhealthy nodes", unhealthyNodeCount)
210+
return fmt.Errorf("%d unhealthy nodes", nc)
211211
}, retry.Attempts(3), retry.Delay(time.Second*5))
212212

213213
if err == nil {
214214
reqLogger.Info("repairing unhealthy masters successful, no unhealthy masters left")
215215
return intctrlutil.RequeueAfter(reqLogger, time.Second*30, "no unhealthy nodes found after repairing disconnected masters")
216216
}
217217
reqLogger.Info("unhealthy nodes exist after attempting to repair disconnected masters; starting failover")
218-
if err := k8sutils.ExecuteFailoverOperation(ctx, r.K8sClient, r.Log, instance); err != nil {
218+
if err = k8sutils.ExecuteFailoverOperation(ctx, r.K8sClient, r.Log, instance); err != nil {
219219
return intctrlutil.RequeueWithError(err, reqLogger, "")
220220
}
221221
}

0 commit comments

Comments
 (0)