@@ -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