Skip to content

Commit 299d0b1

Browse files
author
Arsenii Pastushenko
committed
Reset replication on master after failover
1 parent d9a3f08 commit 299d0b1

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

pkg/controller/orchestrator/orchestrator_reconcile.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,10 @@ func (ou *orcUpdater) updateClusterFailoverInProgressStatus(master *orc.Instance
293293
if master != nil && master.SecondsSinceLastSeen.Valid && master.SecondsSinceLastSeen.Int64 < 5 {
294294
ou.cluster.UpdateStatusCondition(api.ClusterConditionFailoverInProgress, core.ConditionFalse,
295295
"ClusterMasterHealthy", "Master is healthy in orchestrator")
296+
297+
if err := ou.orcClient.ResetReplication(master.Key); err != nil {
298+
ou.log.Error(err, "Error resetting master replication!")
299+
}
296300
}
297301
}
298302

pkg/orchestrator/orchestrator.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ type Interface interface {
3939
BeginMaintenance(key InstanceKey, owner, reason string) error
4040
EndMaintenance(key InstanceKey) error
4141
Maintenance() ([]Maintenance, error)
42+
43+
ResetReplication(key InstanceKey) error
4244
}
4345

4446
type orchestrator struct {
@@ -154,3 +156,10 @@ func (o *orchestrator) Maintenance() ([]Maintenance, error) {
154156

155157
return maintenances, nil
156158
}
159+
160+
func (o *orchestrator) ResetReplication(key InstanceKey) error {
161+
if err := o.makeGetAPIRequest(fmt.Sprintf("reset-slave/%s/%d", key.Hostname, key.Port), nil); err != nil {
162+
return err
163+
}
164+
return nil
165+
}

0 commit comments

Comments
 (0)