mirror of
https://github.com/rancher/rke.git
synced 2025-09-24 21:07:32 +00:00
Handle missing backups
This commit is contained in:
committed by
Alena Prokharchyk
parent
bc5c061527
commit
05d19122ac
@@ -16,7 +16,7 @@ import (
|
||||
"github.com/rancher/rke/log"
|
||||
"github.com/rancher/rke/pki"
|
||||
"github.com/rancher/rke/util"
|
||||
"github.com/rancher/types/apis/management.cattle.io/v3"
|
||||
v3 "github.com/rancher/types/apis/management.cattle.io/v3"
|
||||
"github.com/sirupsen/logrus"
|
||||
"golang.org/x/sync/errgroup"
|
||||
"k8s.io/client-go/util/cert"
|
||||
@@ -511,14 +511,33 @@ func StartBackupServer(ctx context.Context, etcdHost *hosts.Host, prsMap map[str
|
||||
},
|
||||
Image: etcdSnapshotImage,
|
||||
}
|
||||
|
||||
hostCfg := &container.HostConfig{
|
||||
Binds: []string{
|
||||
fmt.Sprintf("%s:/backup", EtcdSnapshotPath),
|
||||
fmt.Sprintf("%s:/etc/kubernetes:z", path.Join(etcdHost.PrefixPath, "/etc/kubernetes"))},
|
||||
NetworkMode: container.NetworkMode("host"),
|
||||
RestartPolicy: container.RestartPolicy{Name: "on-failure"},
|
||||
RestartPolicy: container.RestartPolicy{Name: "no"},
|
||||
}
|
||||
return docker.DoRunContainer(ctx, etcdHost.DClient, imageCfg, hostCfg, EtcdServeBackupContainerName, etcdHost.Address, ETCDRole, prsMap)
|
||||
if err := docker.DoRunContainer(ctx, etcdHost.DClient, imageCfg, hostCfg, EtcdServeBackupContainerName, etcdHost.Address, ETCDRole, prsMap); err != nil {
|
||||
return err
|
||||
}
|
||||
container, err := docker.InspectContainer(ctx, etcdHost.DClient, etcdHost.Address, EtcdServeBackupContainerName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !container.State.Running {
|
||||
containerLog, _, err := docker.GetContainerLogsStdoutStderr(ctx, etcdHost.DClient, EtcdServeBackupContainerName, "1", false)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := docker.RemoveContainer(ctx, etcdHost.DClient, etcdHost.Address, EtcdServeBackupContainerName); err != nil {
|
||||
return err
|
||||
}
|
||||
// printing the restore container's logs
|
||||
return fmt.Errorf("Failed to run backup server container, container logs: %s", containerLog)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func DownloadEtcdSnapshotFromBackupServer(ctx context.Context, etcdHost *hosts.Host, prsMap map[string]v3.PrivateRegistry, etcdSnapshotImage, name string, backupServer *hosts.Host) error {
|
||||
|
Reference in New Issue
Block a user