From 5d1084ad80108f9fbbf180acc364ddcf36988ba7 Mon Sep 17 00:00:00 2001 From: moelsayed Date: Tue, 12 Mar 2019 01:04:08 +0200 Subject: [PATCH] Don't disable all backups based on backup flag --- cluster/etcd.go | 3 +-- cluster/validation.go | 3 +-- services/etcd.go | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/cluster/etcd.go b/cluster/etcd.go index 336beeb2..38bddcf8 100644 --- a/cluster/etcd.go +++ b/cluster/etcd.go @@ -59,7 +59,7 @@ func (c *Cluster) PrepareBackup(ctx context.Context, snapshotPath string) 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) } - if c.Services.Etcd.BackupConfig == nil || (c.Services.Etcd.BackupConfig.Enabled != nil && !*c.Services.Etcd.BackupConfig.Enabled) || // legacy rke local backup + if c.Services.Etcd.BackupConfig == nil || // legacy rke local backup (c.Services.Etcd.BackupConfig != nil && c.Services.Etcd.BackupConfig.S3BackupConfig == nil) { // rancher local backup, no s3 // stop etcd on all etcd nodes, we need this because we start the backup server on the same port for _, host := range c.EtcdHosts { @@ -102,7 +102,6 @@ func (c *Cluster) PrepareBackup(ctx context.Context, snapshotPath string) error // s3 backup case if c.Services.Etcd.BackupConfig != nil && - c.Services.Etcd.BackupConfig.Enabled != nil && *c.Services.Etcd.BackupConfig.Enabled && c.Services.Etcd.BackupConfig.S3BackupConfig != nil { for _, host := range c.EtcdHosts { if err := services.DownloadEtcdSnapshotFromS3(ctx, host, c.PrivateRegistriesMap, backupImage, snapshotPath, c.Services.Etcd); err != nil { diff --git a/cluster/validation.go b/cluster/validation.go index 6c497430..d5188168 100644 --- a/cluster/validation.go +++ b/cluster/validation.go @@ -139,8 +139,7 @@ func validateServicesOptions(c *Cluster) error { } func validateEtcdBackupOptions(c *Cluster) error { - if c.Services.Etcd.BackupConfig != nil && - c.Services.Etcd.BackupConfig.Enabled != nil && *c.Services.Etcd.BackupConfig.Enabled { + if c.Services.Etcd.BackupConfig != nil { if c.Services.Etcd.BackupConfig.S3BackupConfig != nil { if len(c.Services.Etcd.BackupConfig.S3BackupConfig.Endpoint) == 0 { return fmt.Errorf("etcd s3 backup backend endpoint can't be empty") diff --git a/services/etcd.go b/services/etcd.go index 960722bd..06746cea 100644 --- a/services/etcd.go +++ b/services/etcd.go @@ -293,7 +293,7 @@ func RunEtcdSnapshotSave(ctx context.Context, etcdHost *hosts.Host, prsMap map[s imageCfg.Cmd = append(imageCfg.Cmd, "--creation="+es.Creation) } - if es.BackupConfig != nil && es.BackupConfig.Enabled != nil && *es.BackupConfig.Enabled { + if es.BackupConfig != nil { imageCfg = configS3BackupImgCmd(ctx, imageCfg, es.BackupConfig) } hostCfg := &container.HostConfig{