1
0
mirror of https://github.com/rancher/rke.git synced 2025-04-27 11:21:08 +00:00

Dont deploy statefile if its not readable

This commit is contained in:
Sebastiaan van Steenis 2021-05-15 18:55:04 +02:00
parent 05f08baddb
commit 738bda5fb6
2 changed files with 11 additions and 1 deletions

View File

@ -68,6 +68,16 @@ func (c *Cluster) DeployRestoreCerts(ctx context.Context, clusterCerts map[strin
}
func (c *Cluster) DeployStateFile(ctx context.Context, stateFilePath, snapshotName string) error {
stateFileExists, err := util.IsFileExists(stateFilePath)
if err != nil {
logrus.Warnf("Could not read cluster state file from [%s], error: [%v]. Snapshot will be created without cluster state file. You can retrieve the cluster state file using 'rke util get-state-file'", stateFilePath, err)
return nil
}
if !stateFileExists {
logrus.Warnf("Could not read cluster state file from [%s], file does not exist. Snapshot will be created without cluster state file. You can retrieve the cluster state file using 'rke util get-state-file'", stateFilePath)
return nil
}
var errgrp errgroup.Group
hostsQueue := util.GetObjectQueue(c.EtcdHosts)
for w := 0; w < WorkerThreads; w++ {

View File

@ -313,7 +313,7 @@ func SnapshotSaveEtcdHostsFromCli(ctx *cli.Context) error {
etcdSnapshotName := ctx.String("name")
if etcdSnapshotName == "" {
etcdSnapshotName = fmt.Sprintf("rke_etcd_snapshot_%s", time.Now().Format(time.RFC3339))
logrus.Warnf("Name of the snapshot is not specified using [%s]", etcdSnapshotName)
logrus.Warnf("Name of the snapshot is not specified, using [%s]", etcdSnapshotName)
}
// setting up the flags
flags := cluster.GetExternalFlags(false, false, false, false, "", filePath)