mirror of
https://github.com/rancher/rke.git
synced 2025-07-13 15:15:59 +00:00
Correct system image for etcd snapshot removal
when removal is executed as a part of restoration
This commit is contained in:
parent
58cd00391c
commit
2bc68c7118
@ -130,8 +130,10 @@ func (c *Cluster) PrepareBackup(ctx context.Context, snapshotPath string) error
|
|||||||
func (c *Cluster) RestoreEtcdSnapshot(ctx context.Context, snapshotPath string) error {
|
func (c *Cluster) RestoreEtcdSnapshot(ctx context.Context, snapshotPath string) error {
|
||||||
// Start restore process on all etcd hosts
|
// Start restore process on all etcd hosts
|
||||||
initCluster := services.GetEtcdInitialCluster(c.EtcdHosts)
|
initCluster := services.GetEtcdInitialCluster(c.EtcdHosts)
|
||||||
|
backupImage := c.getBackupImage()
|
||||||
for _, host := range c.EtcdHosts {
|
for _, host := range c.EtcdHosts {
|
||||||
if err := services.RestoreEtcdSnapshot(ctx, host, c.PrivateRegistriesMap, c.SystemImages.Etcd, snapshotPath, initCluster, c.Services.Etcd); err != nil {
|
if err := services.RestoreEtcdSnapshot(ctx, 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)
|
return fmt.Errorf("[etcd] Failed to restore etcd snapshot: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -141,7 +143,8 @@ func (c *Cluster) RestoreEtcdSnapshot(ctx context.Context, snapshotPath string)
|
|||||||
func (c *Cluster) RemoveEtcdSnapshot(ctx context.Context, snapshotName string) error {
|
func (c *Cluster) RemoveEtcdSnapshot(ctx context.Context, snapshotName string) error {
|
||||||
backupImage := c.getBackupImage()
|
backupImage := c.getBackupImage()
|
||||||
for _, host := range c.EtcdHosts {
|
for _, host := range c.EtcdHosts {
|
||||||
if err := services.RunEtcdSnapshotRemove(ctx, host, c.PrivateRegistriesMap, backupImage, snapshotName, false, c.Services.Etcd); err != nil {
|
if err := services.RunEtcdSnapshotRemove(ctx, host, c.PrivateRegistriesMap, backupImage, snapshotName,
|
||||||
|
false, c.Services.Etcd); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -435,7 +435,8 @@ func DownloadEtcdSnapshotFromS3(ctx context.Context, etcdHost *hosts.Host, prsMa
|
|||||||
return docker.RemoveContainer(ctx, etcdHost.DClient, etcdHost.Address, EtcdDownloadBackupContainerName)
|
return docker.RemoveContainer(ctx, etcdHost.DClient, etcdHost.Address, EtcdDownloadBackupContainerName)
|
||||||
}
|
}
|
||||||
|
|
||||||
func RestoreEtcdSnapshot(ctx context.Context, etcdHost *hosts.Host, prsMap map[string]v3.PrivateRegistry, etcdRestoreImage, snapshotName, initCluster string, es v3.ETCDService) error {
|
func RestoreEtcdSnapshot(ctx context.Context, etcdHost *hosts.Host, prsMap map[string]v3.PrivateRegistry,
|
||||||
|
etcdRestoreImage, etcdBackupImage, snapshotName, initCluster string, es v3.ETCDService) error {
|
||||||
log.Infof(ctx, "[etcd] Restoring [%s] snapshot on etcd host [%s]", snapshotName, etcdHost.Address)
|
log.Infof(ctx, "[etcd] Restoring [%s] snapshot on etcd host [%s]", snapshotName, etcdHost.Address)
|
||||||
nodeName := pki.GetCrtNameForHost(etcdHost, pki.EtcdCertName)
|
nodeName := pki.GetCrtNameForHost(etcdHost, pki.EtcdCertName)
|
||||||
snapshotPath := fmt.Sprintf("%s%s", EtcdSnapshotPath, snapshotName)
|
snapshotPath := fmt.Sprintf("%s%s", EtcdSnapshotPath, snapshotName)
|
||||||
@ -494,7 +495,7 @@ func RestoreEtcdSnapshot(ctx context.Context, etcdHost *hosts.Host, prsMap map[s
|
|||||||
if err := docker.RemoveContainer(ctx, etcdHost.DClient, etcdHost.Address, EtcdRestoreContainerName); err != nil {
|
if err := docker.RemoveContainer(ctx, etcdHost.DClient, etcdHost.Address, EtcdRestoreContainerName); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return RunEtcdSnapshotRemove(ctx, etcdHost, prsMap, etcdRestoreImage, snapshotName, true, es)
|
return RunEtcdSnapshotRemove(ctx, etcdHost, prsMap, etcdBackupImage, snapshotName, true, es)
|
||||||
}
|
}
|
||||||
|
|
||||||
func RunEtcdSnapshotRemove(ctx context.Context, etcdHost *hosts.Host, prsMap map[string]v3.PrivateRegistry, etcdSnapshotImage string, name string, cleanupRestore bool, es v3.ETCDService) error {
|
func RunEtcdSnapshotRemove(ctx context.Context, etcdHost *hosts.Host, prsMap map[string]v3.PrivateRegistry, etcdSnapshotImage string, name string, cleanupRestore bool, es v3.ETCDService) error {
|
||||||
|
Loading…
Reference in New Issue
Block a user