Skip to content

Commit

Permalink
fix: fetch cluster view after leader recover (#92)
Browse files Browse the repository at this point in the history
* fix: fetch cluster view after leader recover

* fix: fetch cluster again view only when leader recover

Co-authored-by: shaimoria <shai.moria@zooz.com>
  • Loading branch information
shyimo and shaiMoria authored Feb 28, 2021
1 parent f215a06 commit 65814d0
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions controllers/rediscluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,7 @@ func (r *RedisClusterReconciler) handleFailover(redisCluster *dbv1.RedisCluster,
}

func (r *RedisClusterReconciler) recoverCluster(redisCluster *dbv1.RedisCluster) error {
var runLeaderRecover bool = false
clusterView, err := r.NewRedisClusterView(redisCluster)
if err != nil {
return err
Expand All @@ -635,6 +636,8 @@ func (r *RedisClusterReconciler) recoverCluster(redisCluster *dbv1.RedisCluster)
r.Log.Info(clusterView.String())
for i, leader := range *clusterView {
if leader.Failed {
runLeaderRecover = true

if leader.Terminating {
if err = r.waitForPodDelete(*leader.Pod); err != nil {
return errors.Errorf("Failed to wait for leader pod to be deleted %s: %v", leader.NodeNumber, err)
Expand Down Expand Up @@ -666,6 +669,17 @@ func (r *RedisClusterReconciler) recoverCluster(redisCluster *dbv1.RedisCluster)
}
}

if runLeaderRecover {
// we fetch again the cluster view in case the state has changed
// since the last check (before handling the failed leaders)
clusterView, err = r.NewRedisClusterView(redisCluster)
if err != nil {
return err
}

r.Log.Info(clusterView.String())
}

for _, leader := range *clusterView {
var missingFollowers []NodeNumbers
var failedFollowerIPs []string
Expand Down

0 comments on commit 65814d0

Please sign in to comment.