1
0
mirror of https://github.com/rancher/rke.git synced 2025-09-04 08:24:28 +00:00

restore certificates to at least on etcd/control plane

This commit is contained in:
galal-hussein
2018-06-13 23:26:03 +02:00
committed by Alena Prokharchyk
parent cafc7218fb
commit 1f8113428e
2 changed files with 12 additions and 4 deletions

View File

@@ -265,14 +265,22 @@ func (c *Cluster) SaveBackupCertificateBundle(ctx context.Context) error {
func (c *Cluster) ExtractBackupCertificateBundle(ctx context.Context) error { func (c *Cluster) ExtractBackupCertificateBundle(ctx context.Context) error {
backupHosts := c.getBackupHosts() backupHosts := c.getBackupHosts()
var errgrp errgroup.Group var errgrp errgroup.Group
errList := []string{}
for _, host := range backupHosts { for _, host := range backupHosts {
runHost := host runHost := host
errgrp.Go(func() error { errgrp.Go(func() error {
return pki.ExtractBackupBundleOnHost(ctx, runHost, c.SystemImages.Alpine, services.EtcdSnapshotPath, c.PrivateRegistriesMap) if err := pki.ExtractBackupBundleOnHost(ctx, runHost, c.SystemImages.Alpine, services.EtcdSnapshotPath, c.PrivateRegistriesMap); err != nil {
errList = append(errList, fmt.Errorf(
"Failed to extract certificate bundle on host [%s], please make sure etcd bundle exist in /opt/rke/etcd-snapshots/pki.bundle.tar.gz: %v", runHost.Address, err).Error())
}
return nil
}) })
} }
return errgrp.Wait() errgrp.Wait()
if len(errList) == len(backupHosts) {
return fmt.Errorf(strings.Join(errList, ","))
}
return nil
} }
func (c *Cluster) getBackupHosts() []*hosts.Host { func (c *Cluster) getBackupHosts() []*hosts.Host {

View File

@@ -249,7 +249,7 @@ func ExtractBackupBundleOnHost(ctx context.Context, host *hosts.Host, alpineSyst
Cmd: []string{ Cmd: []string{
"sh", "sh",
"-c", "-c",
fmt.Sprintf("if [ -f %s ];then tar xzvf %s -C %s --strip-components %d; fi", BundleCertPath, BundleCertPath, fullTempCertPath, len(strings.Split(fullTempCertPath, "/"))-1), fmt.Sprintf("mkdir -p /etc/kubernetes/.tmp/; tar xzvf %s -C %s --strip-components %d", BundleCertPath, fullTempCertPath, len(strings.Split(fullTempCertPath, "/"))-1),
}, },
Image: alpineSystemImage, Image: alpineSystemImage,
} }