mirror of
https://github.com/rancher/rke.git
synced 2025-09-01 15:06:23 +00:00
Added etcd snapshot timeout parameter
This commit is contained in:
@@ -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