1
0
mirror of https://github.com/rancher/rke.git synced 2025-09-18 16:36:41 +00:00

Etcd Backup/restore

This commit is contained in:
galal-hussein
2018-05-09 19:39:19 +02:00
parent 5d718ad123
commit a3416e6b92
13 changed files with 479 additions and 15 deletions

View File

@@ -4,6 +4,7 @@ import (
"context"
"fmt"
"path"
"path/filepath"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
@@ -58,6 +59,7 @@ func (h *Host) CleanUpAll(ctx context.Context, cleanerImage string, prsMap map[s
path.Join(h.PrefixPath, ToCleanTempCertPath),
path.Join(h.PrefixPath, ToCleanCNILib),
}
if !externalEtcd {
toCleanPaths = append(toCleanPaths, path.Join(h.PrefixPath, ToCleanEtcdDir))
}
@@ -116,7 +118,7 @@ func (h *Host) CleanUp(ctx context.Context, toCleanPaths []string, cleanerImage
return err
}
if err := docker.WaitForContainer(ctx, h.DClient, h.Address, CleanerContainerName); err != nil {
if _, err := docker.WaitForContainer(ctx, h.DClient, h.Address, CleanerContainerName); err != nil {
return err
}
@@ -240,8 +242,12 @@ func buildCleanerConfig(host *Host, toCleanDirs []string, cleanerImage string) (
Cmd: cmd,
}
bindMounts := []string{}
bindMountsMap := make(map[string]string)
for _, vol := range toCleanDirs {
bindMounts = append(bindMounts, fmt.Sprintf("%s:%s:z", vol, vol))
bindMountsMap[filepath.Dir(vol)] = vol
}
for dir := range bindMountsMap {
bindMounts = append(bindMounts, fmt.Sprintf("%s:%s:z", dir, dir))
}
hostCfg := &container.HostConfig{
Binds: bindMounts,