mirror of
https://github.com/rancher/rke.git
synced 2025-09-10 03:20:20 +00:00
Fix broken etcd rolling snapshot
This commit is contained in:
committed by
Alena Prokharchyk
parent
fd99385ab1
commit
631c0725f4
@@ -32,7 +32,7 @@ const (
|
||||
|
||||
DefaultIngressController = "nginx"
|
||||
DefaultEtcdBackupCreationPeriod = "12h"
|
||||
DefaultEtcdBackupRetentionPeriod = "3d"
|
||||
DefaultEtcdBackupRetentionPeriod = "72h"
|
||||
DefaultEtcdSnapshot = true
|
||||
DefaultMonitoringProvider = "metrics-server"
|
||||
|
||||
|
@@ -282,7 +282,8 @@ func RunEtcdSnapshotSave(ctx context.Context, etcdHost *hosts.Host, prsMap map[s
|
||||
Binds: []string{
|
||||
fmt.Sprintf("%s:/backup", EtcdSnapshotPath),
|
||||
fmt.Sprintf("%s:/etc/kubernetes:z", path.Join(etcdHost.PrefixPath, "/etc/kubernetes"))},
|
||||
NetworkMode: container.NetworkMode("host"),
|
||||
NetworkMode: container.NetworkMode("host"),
|
||||
RestartPolicy: container.RestartPolicy{Name: "always"},
|
||||
}
|
||||
|
||||
if once {
|
||||
@@ -295,7 +296,20 @@ func RunEtcdSnapshotSave(ctx context.Context, etcdHost *hosts.Host, prsMap map[s
|
||||
}
|
||||
return docker.RemoveContainer(ctx, etcdHost.DClient, etcdHost.Address, EtcdSnapshotOnceContainerName)
|
||||
}
|
||||
return docker.DoRunContainer(ctx, etcdHost.DClient, imageCfg, hostCfg, EtcdSnapshotContainerName, etcdHost.Address, ETCDRole, prsMap)
|
||||
if err := docker.DoRunContainer(ctx, etcdHost.DClient, imageCfg, hostCfg, EtcdSnapshotContainerName, etcdHost.Address, ETCDRole, prsMap); err != nil {
|
||||
return err
|
||||
}
|
||||
// check if the container exited with error
|
||||
snapshotCont, err := docker.InspectContainer(ctx, etcdHost.DClient, etcdHost.Address, EtcdSnapshotContainerName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if snapshotCont.State.Status == "exited" || snapshotCont.State.Restarting {
|
||||
log.Warnf(ctx, "Etcd rolling snapshot container failed to start correctly")
|
||||
return docker.RemoveContainer(ctx, etcdHost.DClient, etcdHost.Address, EtcdSnapshotContainerName)
|
||||
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func RestoreEtcdSnapshot(ctx context.Context, etcdHost *hosts.Host, prsMap map[string]v3.PrivateRegistry, etcdRestoreImage, snapshotName, initCluster string) error {
|
||||
|
Reference in New Issue
Block a user