1
0
mirror of https://github.com/rancher/rke.git synced 2025-08-31 14:36:32 +00:00

Handle missing backup kube-etcd gracefully

This commit is contained in:
moelsayed
2018-04-25 07:11:57 +02:00
committed by Darren Shepherd
parent 0715323263
commit a2d985ef46
3 changed files with 48 additions and 3 deletions

View File

@@ -135,12 +135,19 @@ func FetchCertificatesFromHost(ctx context.Context, extraHosts []*hosts.Host, ho
for certName, config := range crtList {
certificate := CertificatePKI{}
crt, err := fetchFileFromHost(ctx, GetCertTempPath(certName), image, host, prsMap)
if err != nil {
// I will only exit with an error if it's not a not-found-error and this is not an etcd certificate
if err != nil && !strings.HasPrefix(certName, "kube-etcd") {
if strings.Contains(err.Error(), "no such file or directory") ||
strings.Contains(err.Error(), "Could not find the file") {
return nil, nil
}
return nil, err
}
// If I can't find an etcd cert, I will not fail and will create it later.
if crt == "" && strings.HasPrefix(certName, "kube-etcd") {
tmpCerts[certName] = CertificatePKI{}
continue
}
key, err := fetchFileFromHost(ctx, GetKeyTempPath(certName), image, host, prsMap)