mirror of
https://github.com/rancher/rke.git
synced 2025-08-02 07:43:04 +00:00
Add BackupConfig Enabled flag
This commit is contained in:
parent
efab83d804
commit
1e34a7c5fa
@ -11,7 +11,7 @@ import (
|
||||
"github.com/rancher/rke/log"
|
||||
"github.com/rancher/rke/services"
|
||||
"github.com/rancher/rke/templates"
|
||||
"github.com/rancher/types/apis/management.cattle.io/v3"
|
||||
v3 "github.com/rancher/types/apis/management.cattle.io/v3"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -201,7 +201,7 @@ func (c *Cluster) setClusterServicesDefaults() {
|
||||
c.Services.Etcd.ExtraArgs[DefaultEtcdHeartbeatIntervalName] = DefaultEtcdHeartbeatIntervalValue
|
||||
}
|
||||
|
||||
if c.Services.Etcd.BackupConfig != nil {
|
||||
if c.Services.Etcd.BackupConfig != nil && c.Services.Etcd.BackupConfig.Enabled != nil && *c.Services.Etcd.BackupConfig.Enabled {
|
||||
if c.Services.Etcd.BackupConfig.IntervalHours == 0 {
|
||||
c.Services.Etcd.BackupConfig.IntervalHours = DefaultEtcdBackupConfigIntervalHours
|
||||
}
|
||||
|
@ -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 || // legacy rke local backup
|
||||
if c.Services.Etcd.BackupConfig == nil || (c.Services.Etcd.BackupConfig.Enabled != nil && !*c.Services.Etcd.BackupConfig.Enabled) || // 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 {
|
||||
@ -101,7 +101,9 @@ func (c *Cluster) PrepareBackup(ctx context.Context, snapshotPath string) error
|
||||
}
|
||||
|
||||
// s3 backup case
|
||||
if c.Services.Etcd.BackupConfig != nil && c.Services.Etcd.BackupConfig.S3BackupConfig != nil {
|
||||
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 {
|
||||
return err
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
"github.com/rancher/rke/log"
|
||||
"github.com/rancher/rke/services"
|
||||
"github.com/rancher/rke/util"
|
||||
"github.com/rancher/types/apis/management.cattle.io/v3"
|
||||
v3 "github.com/rancher/types/apis/management.cattle.io/v3"
|
||||
"k8s.io/apimachinery/pkg/util/validation"
|
||||
)
|
||||
|
||||
@ -139,7 +139,8 @@ func validateServicesOptions(c *Cluster) error {
|
||||
}
|
||||
|
||||
func validateEtcdBackupOptions(c *Cluster) error {
|
||||
if c.Services.Etcd.BackupConfig != nil {
|
||||
if c.Services.Etcd.BackupConfig != nil &&
|
||||
c.Services.Etcd.BackupConfig.Enabled != nil && *c.Services.Etcd.BackupConfig.Enabled {
|
||||
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")
|
||||
|
@ -10,7 +10,7 @@ import (
|
||||
"github.com/rancher/rke/cluster"
|
||||
"github.com/rancher/rke/hosts"
|
||||
"github.com/rancher/rke/log"
|
||||
"github.com/rancher/types/apis/management.cattle.io/v3"
|
||||
v3 "github.com/rancher/types/apis/management.cattle.io/v3"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
@ -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 {
|
||||
if es.BackupConfig != nil && es.BackupConfig.Enabled != nil && *es.BackupConfig.Enabled {
|
||||
imageCfg = configS3BackupImgCmd(ctx, imageCfg, es.BackupConfig)
|
||||
}
|
||||
hostCfg := &container.HostConfig{
|
||||
|
Loading…
Reference in New Issue
Block a user