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

Reset replication on master after failover #617

Closed
wants to merge 1 commit into from
Closed
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
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
}