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: fetch cluster view after leader recover #92

Merged
merged 2 commits into from
Feb 28, 2021
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
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