1
0
mirror of https://github.com/rancher/rke.git synced 2025-09-02 07:24:20 +00:00

Handle missing backups

This commit is contained in:
moelsayed
2019-02-27 07:34:54 +02:00
committed by Alena Prokharchyk
parent bc5c061527
commit 05d19122ac
3 changed files with 43 additions and 6 deletions

View File

@@ -28,6 +28,7 @@ func (c *Cluster) PrepareBackup(ctx context.Context, snapshotPath string) error
// local backup case
var backupServer *hosts.Host
backupImage := c.getBackupImage()
var errors []error
if !util.IsRancherBackupSupported(c.SystemImages.Alpine) {
log.Warnf(ctx, "Auto local backup sync is not supported in `%s`. Using `%s` instead.", c.SystemImages.Alpine, backupImage)
}
@@ -41,11 +42,22 @@ func (c *Cluster) PrepareBackup(ctx context.Context, snapshotPath string) error
if backupServer == nil { // start the download server, only one node should have it!
if err := services.StartBackupServer(ctx, host, c.PrivateRegistriesMap, backupImage, snapshotPath); err != nil {
log.Warnf(ctx, "failed to start backup server on host [%s]: %v", host.Address, err)
errors = append(errors, err)
continue
}
backupServer = host
break
}
}
if backupServer == nil { //failed to start the backupServer, I will cleanup and exit
for _, host := range c.EtcdHosts {
if err := docker.StartContainer(ctx, host.DClient, host.Address, services.EtcdContainerName); err != nil {
log.Warnf(ctx, "failed to start etcd container on host [%s]: %v", host.Address, err)
}
}
return fmt.Errorf("failed to start backup server on all etcd nodes: %v", errors)
}
// start downloading the snapshot
for _, host := range c.EtcdHosts {
if backupServer != nil && host.Address == backupServer.Address { // we skip the backup server if it's there