diff --git a/cluster/etcd.go b/cluster/etcd.go index cd45156d..8a0f68fe 100644 --- a/cluster/etcd.go +++ b/cluster/etcd.go @@ -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++ { diff --git a/cmd/etcd.go b/cmd/etcd.go index 608757a5..d4f65d75 100644 --- a/cmd/etcd.go +++ b/cmd/etcd.go @@ -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)