mirror of
https://github.com/rancher/rke.git
synced 2025-04-28 03:31:24 +00:00
Dont deploy statefile if its not readable
This commit is contained in:
parent
05f08baddb
commit
738bda5fb6
@ -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 {
|
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
|
var errgrp errgroup.Group
|
||||||
hostsQueue := util.GetObjectQueue(c.EtcdHosts)
|
hostsQueue := util.GetObjectQueue(c.EtcdHosts)
|
||||||
for w := 0; w < WorkerThreads; w++ {
|
for w := 0; w < WorkerThreads; w++ {
|
||||||
|
@ -313,7 +313,7 @@ func SnapshotSaveEtcdHostsFromCli(ctx *cli.Context) error {
|
|||||||
etcdSnapshotName := ctx.String("name")
|
etcdSnapshotName := ctx.String("name")
|
||||||
if etcdSnapshotName == "" {
|
if etcdSnapshotName == "" {
|
||||||
etcdSnapshotName = fmt.Sprintf("rke_etcd_snapshot_%s", time.Now().Format(time.RFC3339))
|
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
|
// setting up the flags
|
||||||
flags := cluster.GetExternalFlags(false, false, false, false, "", filePath)
|
flags := cluster.GetExternalFlags(false, false, false, false, "", filePath)
|
||||||
|
Loading…
Reference in New Issue
Block a user