Skip to content

Commit 859eaf8

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

File tree

4 files changed

+19
-0
lines changed

4 files changed

+19
-0
lines changed

Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
2323
* Update k8s client to `v0.18.2`
2424
* Update kubebuilder (to `v2.3.1`) along with controller-runtime (to `v0.6.0`) and controller-gen
2525
* Update rclone to `v1.52.3`
26+
* Operator will now reset replication on master after failover
2627
### Removed
2728
### Fixed
2829
* Fix pod labels diff of map

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/fake/client.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,3 +348,8 @@ func (o *OrcFakeClient) EndMaintenance(key InstanceKey) error {
348348
func (o *OrcFakeClient) Maintenance() ([]Maintenance, error) {
349349
return nil, nil
350350
}
351+
352+
// ResetReplication resets replication on a node
353+
func (o *OrcFakeClient) ResetReplication(key InstanceKey) error {
354+
return nil
355+
}

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)