Commit 12c6d6a5 authored by Brad Davidson's avatar Brad Davidson Committed by Brad Davidson

Actually fix agent certificate rotation

Signed-off-by: 's avatarBrad Davidson <brad.davidson@rancher.com> (cherry picked from commit 4cc73b1f)
parent 2ae9eacc
......@@ -5,7 +5,6 @@ import (
"fmt"
"os"
"path/filepath"
"strconv"
"strings"
"time"
......@@ -191,14 +190,20 @@ func rotate(app *cli.Context, cfg *cmds.Server) error {
}
func backupCertificates(serverDataDir, agentDataDir string, fileMap map[string][]string) (string, error) {
backupDirName := fmt.Sprintf("tls-%d", time.Now().Unix())
serverTLSDir := filepath.Join(serverDataDir, "tls")
tlsBackupDir := filepath.Join(serverDataDir, "tls-"+strconv.Itoa(int(time.Now().Unix())))
tlsBackupDir := filepath.Join(agentDataDir, backupDirName)
// backup the server TLS dir if it exists
if _, err := os.Stat(serverTLSDir); err != nil {
return "", err
}
if err := copy.Copy(serverTLSDir, tlsBackupDir); err != nil {
return "", err
if !os.IsNotExist(err) {
return "", err
}
} else {
tlsBackupDir = filepath.Join(serverDataDir, backupDirName)
if err := copy.Copy(serverTLSDir, tlsBackupDir); err != nil {
return "", err
}
}
for _, files := range fileMap {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment