Skip to content

Support manually specify backup candidate node #843

Open
@drivebyer

Description

@drivebyer

Now, the backup candidate node is calculate by:

// getBackupCandidate returns the hostname of the first not-lagged and
// replicating slave node, else returns the master node.
func (s *jobSyncer) getBackupCandidate() string {
for _, node := range s.cluster.Status.Nodes {
master := s.cluster.GetNodeCondition(node.Name, api.NodeConditionMaster)
replicating := s.cluster.GetNodeCondition(node.Name, api.NodeConditionReplicating)
lagged := s.cluster.GetNodeCondition(node.Name, api.NodeConditionLagged)
if master == nil || replicating == nil || lagged == nil {
continue
}
isMaster := master.Status == core.ConditionTrue
isReplicating := replicating.Status == core.ConditionTrue
isLagged := lagged.Status == core.ConditionTrue
// select a node that is not master is replicating and is not lagged
if !isMaster && isReplicating && !isLagged {
return node.Name
}
}
log.Info("no healthy slave node found so returns the master node", "master_node", s.cluster.GetMasterHost(),
"key", s.cluster, "backup", s.backup)
return s.cluster.GetMasterHost()
}

In some cases, we need backup spcify node, for example:

  1. a node is created only for backup or
  2. a node has less stress which is more suitable for backup

So, I think we should support manually specify backup candidate node to cover more backup scenario

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions