mirror of
https://github.com/rancher/rke.git
synced 2025-09-17 15:40:07 +00:00
Fixed snapshot restore unable to archive pki bundle
Fixed TempCertPath on extract of pki bundle Fixed Extract & Save of pki bundle by removing PrefixPath
This commit is contained in:
11
pki/pki.go
11
pki/pki.go
@@ -233,7 +233,7 @@ func SaveBackupBundleOnHost(ctx context.Context, host *hosts.Host, alpineSystemI
|
|||||||
Cmd: []string{
|
Cmd: []string{
|
||||||
"sh",
|
"sh",
|
||||||
"-c",
|
"-c",
|
||||||
fmt.Sprintf("if [ -d %s ] && [ \"$(ls -A %s)\" ]; then tar czvf %s %s;fi", path.Join(host.PrefixPath, TempCertPath), path.Join(host.PrefixPath, TempCertPath), BundleCertPath, path.Join(host.PrefixPath, TempCertPath)),
|
fmt.Sprintf("if [ -d %s ] && [ \"$(ls -A %s)\" ]; then tar czvf %s %s;fi", TempCertPath, TempCertPath, BundleCertPath, TempCertPath),
|
||||||
},
|
},
|
||||||
Image: alpineSystemImage,
|
Image: alpineSystemImage,
|
||||||
}
|
}
|
||||||
@@ -260,17 +260,16 @@ func SaveBackupBundleOnHost(ctx context.Context, host *hosts.Host, alpineSystemI
|
|||||||
}
|
}
|
||||||
|
|
||||||
func ExtractBackupBundleOnHost(ctx context.Context, host *hosts.Host, alpineSystemImage, etcdSnapshotPath string, prsMap map[string]v3.PrivateRegistry) error {
|
func ExtractBackupBundleOnHost(ctx context.Context, host *hosts.Host, alpineSystemImage, etcdSnapshotPath string, prsMap map[string]v3.PrivateRegistry) error {
|
||||||
fullTempCertPath := path.Join(host.PrefixPath, TempCertPath)
|
|
||||||
imageCfg := &container.Config{
|
imageCfg := &container.Config{
|
||||||
Cmd: []string{
|
Cmd: []string{
|
||||||
"sh",
|
"sh",
|
||||||
"-c",
|
"-c",
|
||||||
fmt.Sprintf(
|
fmt.Sprintf(
|
||||||
"mkdir -p %s; tar xzvf %s -C %s --strip-components %d",
|
"mkdir -p %s; tar xzvf %s -C %s --strip-components %d",
|
||||||
fullTempCertPath,
|
TempCertPath,
|
||||||
BundleCertPath,
|
BundleCertPath,
|
||||||
fullTempCertPath,
|
TempCertPath,
|
||||||
len(strings.Split(fullTempCertPath, "/"))-1),
|
len(strings.Split(TempCertPath, "/"))-1),
|
||||||
},
|
},
|
||||||
Image: alpineSystemImage,
|
Image: alpineSystemImage,
|
||||||
}
|
}
|
||||||
@@ -300,6 +299,6 @@ func ExtractBackupBundleOnHost(ctx context.Context, host *hosts.Host, alpineSyst
|
|||||||
}
|
}
|
||||||
return fmt.Errorf("Failed to run certificate bundle extract, exit status is: %d, container logs: %s", status, containerLog)
|
return fmt.Errorf("Failed to run certificate bundle extract, exit status is: %d, container logs: %s", status, containerLog)
|
||||||
}
|
}
|
||||||
log.Infof(ctx, "[certificates] successfully extracted certificate bundle on host [%s] to backup path [%s]", host.Address, fullTempCertPath)
|
log.Infof(ctx, "[certificates] successfully extracted certificate bundle on host [%s] to backup path [%s]", host.Address, TempCertPath)
|
||||||
return docker.RemoveContainer(ctx, host.DClient, host.Address, BundleCertContainer)
|
return docker.RemoveContainer(ctx, host.DClient, host.Address, BundleCertContainer)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user