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

Always mark the failovers as ok or error #133

Merged
merged 1 commit into from
Mar 25, 2019
Merged
Show file tree
Hide file tree
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
4 changes: 0 additions & 4 deletions operator/redisfailover/checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ func (r *RedisFailoverHandler) CheckAndHeal(rf *redisfailoverv1alpha2.RedisFailo
r.logger.Debugf("time %.f more than expected. Not even one master, fixing...", minTime.Round(time.Second).Seconds())
// We can consider there's an error
if err2 := r.rfHealer.SetOldestAsMaster(rf); err2 != nil {
r.mClient.SetClusterError(rf.Namespace, rf.Name)
return err2
}
} else {
Expand All @@ -64,7 +63,6 @@ func (r *RedisFailoverHandler) CheckAndHeal(rf *redisfailoverv1alpha2.RedisFailo
case 1:
break
default:
r.mClient.SetClusterError(rf.Namespace, rf.Name)
return errors.New("More than one master, fix manually")
}

Expand Down Expand Up @@ -97,7 +95,6 @@ func (r *RedisFailoverHandler) CheckAndHeal(rf *redisfailoverv1alpha2.RedisFailo
if err := r.rfChecker.CheckSentinelMonitor(sip, master); err != nil {
r.logger.Debug("Sentinel is not monitoring the correct master")
if err := r.rfHealer.NewSentinelMonitor(sip, master, rf); err != nil {
r.mClient.SetClusterError(rf.Namespace, rf.Name)
return err
}
}
Expand All @@ -123,6 +120,5 @@ func (r *RedisFailoverHandler) CheckAndHeal(rf *redisfailoverv1alpha2.RedisFailo
return err
}
}
r.mClient.SetClusterOK(rf.Namespace, rf.Name)
return nil
}
9 changes: 8 additions & 1 deletion operator/redisfailover/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,17 @@ func (r *RedisFailoverHandler) Add(_ context.Context, obj runtime.Object) error
labels := r.mergeLabels(rf)

if err := r.Ensure(rf, labels, oRefs); err != nil {
r.mClient.SetClusterError(rf.Namespace, rf.Name)
return err
}

if err := r.CheckAndHeal(rf); err != nil {
r.mClient.SetClusterError(rf.Namespace, rf.Name)
return err
}

return r.CheckAndHeal(rf)
r.mClient.SetClusterOK(rf.Namespace, rf.Name)
return nil
}

// Delete handles the deletion of a RF.
Expand Down