Skip to content

Commit

Permalink
Reset replication on master after failover
Browse files Browse the repository at this point in the history
  • Loading branch information
Arsenii Pastushenko committed Oct 23, 2020
1 parent d9a3f08 commit 859eaf8
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
* Update k8s client to `v0.18.2`
* Update kubebuilder (to `v2.3.1`) along with controller-runtime (to `v0.6.0`) and controller-gen
* Update rclone to `v1.52.3`
* Operator will now reset replication on master after failover
### Removed
### Fixed
* Fix pod labels diff of map
Expand Down
4 changes: 4 additions & 0 deletions pkg/controller/orchestrator/orchestrator_reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,10 @@ func (ou *orcUpdater) updateClusterFailoverInProgressStatus(master *orc.Instance
if master != nil && master.SecondsSinceLastSeen.Valid && master.SecondsSinceLastSeen.Int64 < 5 {
ou.cluster.UpdateStatusCondition(api.ClusterConditionFailoverInProgress, core.ConditionFalse,
"ClusterMasterHealthy", "Master is healthy in orchestrator")

if err := ou.orcClient.ResetReplication(master.Key); err != nil {
ou.log.Error(err, "Error resetting master replication!")
}
}
}

Expand Down
5 changes: 5 additions & 0 deletions pkg/orchestrator/fake/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,3 +348,8 @@ func (o *OrcFakeClient) EndMaintenance(key InstanceKey) error {
func (o *OrcFakeClient) Maintenance() ([]Maintenance, error) {
return nil, nil
}

// ResetReplication resets replication on a node
func (o *OrcFakeClient) ResetReplication(key InstanceKey) error {
return nil
}
9 changes: 9 additions & 0 deletions pkg/orchestrator/orchestrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ type Interface interface {
BeginMaintenance(key InstanceKey, owner, reason string) error
EndMaintenance(key InstanceKey) error
Maintenance() ([]Maintenance, error)

ResetReplication(key InstanceKey) error
}

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

return maintenances, nil
}

func (o *orchestrator) ResetReplication(key InstanceKey) error {
if err := o.makeGetAPIRequest(fmt.Sprintf("reset-slave/%s/%d", key.Hostname, key.Port), nil); err != nil {
return err
}
return nil
}

0 comments on commit 859eaf8

Please sign in to comment.