mirror of
https://github.com/rancher/rke.git
synced 2025-09-02 15:34:36 +00:00
Added etcd snapshot timeout parameter
This commit is contained in:
@@ -54,6 +54,7 @@ const (
|
||||
DefaultMonitoringProvider = "metrics-server"
|
||||
DefaultEtcdBackupConfigIntervalHours = 12
|
||||
DefaultEtcdBackupConfigRetention = 6
|
||||
DefaultEtcdBackupConfigTimeout = docker.WaitTimeout
|
||||
|
||||
DefaultDNSProvider = "kube-dns"
|
||||
K8sVersionCoreDNS = "1.14.0"
|
||||
@@ -336,6 +337,9 @@ func (c *Cluster) setClusterServicesDefaults() {
|
||||
if c.Services.Etcd.BackupConfig.Retention == 0 {
|
||||
c.Services.Etcd.BackupConfig.Retention = DefaultEtcdBackupConfigRetention
|
||||
}
|
||||
if c.Services.Etcd.BackupConfig.Timeout == 0 {
|
||||
c.Services.Etcd.BackupConfig.Timeout = DefaultEtcdBackupConfigTimeout
|
||||
}
|
||||
}
|
||||
|
||||
if _, ok := c.Services.KubeAPI.ExtraArgs[KubeAPIArgAdmissionControlConfigFile]; !ok {
|
||||
|
@@ -18,7 +18,12 @@ import (
|
||||
func (c *Cluster) SnapshotEtcd(ctx context.Context, snapshotName string) error {
|
||||
backupImage := c.getBackupImage()
|
||||
for _, host := range c.EtcdHosts {
|
||||
if err := services.RunEtcdSnapshotSave(ctx, host, c.PrivateRegistriesMap, backupImage, snapshotName, true, c.Services.Etcd); err != nil {
|
||||
containerTimeout := DefaultEtcdBackupConfigTimeout
|
||||
if c.Services.Etcd.BackupConfig != nil && c.Services.Etcd.BackupConfig.Timeout > 0 {
|
||||
containerTimeout = c.Services.Etcd.BackupConfig.Timeout
|
||||
}
|
||||
newCtx := context.WithValue(ctx, docker.WaitTimeoutContextKey, containerTimeout)
|
||||
if err := services.RunEtcdSnapshotSave(newCtx, host, c.PrivateRegistriesMap, backupImage, snapshotName, true, c.Services.Etcd); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -175,7 +180,12 @@ func (c *Cluster) RestoreEtcdSnapshot(ctx context.Context, snapshotPath string)
|
||||
initCluster := services.GetEtcdInitialCluster(c.EtcdHosts)
|
||||
backupImage := c.getBackupImage()
|
||||
for _, host := range c.EtcdHosts {
|
||||
if err := services.RestoreEtcdSnapshot(ctx, host, c.PrivateRegistriesMap, c.SystemImages.Etcd, backupImage,
|
||||
containerTimeout := DefaultEtcdBackupConfigTimeout
|
||||
if c.Services.Etcd.BackupConfig != nil && c.Services.Etcd.BackupConfig.Timeout > 0 {
|
||||
containerTimeout = c.Services.Etcd.BackupConfig.Timeout
|
||||
}
|
||||
newCtx := context.WithValue(ctx, docker.WaitTimeoutContextKey, containerTimeout)
|
||||
if err := services.RestoreEtcdSnapshot(newCtx, host, c.PrivateRegistriesMap, c.SystemImages.Etcd, backupImage,
|
||||
snapshotPath, initCluster, c.Services.Etcd); err != nil {
|
||||
return fmt.Errorf("[etcd] Failed to restore etcd snapshot: %v", err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user