Skip to content

Commit

Permalink
Merge pull request #328 from acekingke/followerCloneFirst
Browse files Browse the repository at this point in the history
sidecar:  first choose follower to clone init #322
  • Loading branch information
andyli029 authored Dec 8, 2021
2 parents b8cb91a + 0323a5b commit 6e348b3
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions sidecar/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,16 @@ func CheckServiceExist(cfg *Config, service string) bool {

// Clone from leader or follower.
func runCloneAndInit(cfg *Config) error {
//check leader is exist?
serviceURL := ""
if len(serviceURL) == 0 && CheckServiceExist(cfg, "leader") {
serviceURL = fmt.Sprintf("http://%s-%s:%v", cfg.ClusterName, "leader", utils.XBackupPort)
}
//check follower is exists?
serviceURL := ""
if len(serviceURL) == 0 && CheckServiceExist(cfg, "follower") {
serviceURL = fmt.Sprintf("http://%s-%s:%v", cfg.ClusterName, "follower", utils.XBackupPort)
}
//check leader is exist?
if len(serviceURL) == 0 && CheckServiceExist(cfg, "leader") {
serviceURL = fmt.Sprintf("http://%s-%s:%v", cfg.ClusterName, "leader", utils.XBackupPort)
}

if len(serviceURL) != 0 {
// backup at first
Args := fmt.Sprintf("rm -rf /backup/initbackup;mkdir -p /backup/initbackup;curl --user $BACKUP_USER:$BACKUP_PASSWORD %s/download|xbstream -x -C /backup/initbackup; exit ${PIPESTATUS[0]}",
Expand Down

0 comments on commit 6e348b3

Please sign in to comment.