diff --git a/pkg/apply/processor/delete.go b/pkg/apply/processor/delete.go index 3e24b54b664..319f9a46f68 100644 --- a/pkg/apply/processor/delete.go +++ b/pkg/apply/processor/delete.go @@ -74,7 +74,13 @@ func (d *DeleteProcessor) PreProcess(cluster *v2.Cluster) error { func (d *DeleteProcessor) UndoBootstrap(cluster *v2.Cluster) error { logger.Info("Executing pipeline Bootstrap in DeleteProcessor") hosts := append(cluster.GetMasterIPAndPortList(), cluster.GetNodeIPAndPortList()...) - bs := bootstrap.New(d.ClusterFile.GetCluster()) + var cls *v2.Cluster + if v := d.ClusterFile.GetCluster(); v != nil { + cls = v + } else { + cls = cluster + } + bs := bootstrap.New(cls) return bs.Delete(hosts...) } @@ -96,7 +102,14 @@ func (d *DeleteProcessor) UnMountRootfs(cluster *v2.Cluster) error { if err != nil { return err } - return fs.UnMountRootfs(d.ClusterFile.GetCluster(), hosts) + var cls *v2.Cluster + if v := d.ClusterFile.GetCluster(); v != nil { + cls = v + } else { + cls = cluster + } + + return fs.UnMountRootfs(cls, hosts) } func (d *DeleteProcessor) UnMountImage(cluster *v2.Cluster) error { diff --git a/pkg/apply/reset.go b/pkg/apply/reset.go index c3f35c10b39..921a4d1fd60 100644 --- a/pkg/apply/reset.go +++ b/pkg/apply/reset.go @@ -15,6 +15,7 @@ package apply import ( + "errors" "fmt" "github.com/spf13/cobra" @@ -32,6 +33,7 @@ func NewApplierFromResetArgs(cmd *cobra.Command, args *ResetArgs) (applydrivers. clusterPath := constants.Clusterfile(args.ClusterName) cf := clusterfile.NewClusterFile(clusterPath) err := cf.Process() + // incase we want to reset force if err != nil && err != clusterfile.ErrClusterFileNotExists { return nil, err } @@ -58,7 +60,7 @@ func (r *ClusterArgs) resetArgs(cmd *cobra.Command, args *ResetArgs) error { } override := getSSHFromCommand(cmd) if override != nil { - r.cluster.Spec.SSH = *override + ssh.OverSSHConfig(&r.cluster.Spec.SSH, override) } if len(args.Cluster.Masters) > 0 { @@ -73,6 +75,10 @@ func (r *ClusterArgs) resetArgs(cmd *cobra.Command, args *ResetArgs) error { } r.cluster.Spec.Hosts = r.hosts } + + if r.cluster.ObjectMeta.CreationTimestamp.IsZero() && len(r.cluster.Spec.Hosts) == 0 { + return errors.New("must specified '--masters' or '--nodes' when clusterfile is not exists") + } logger.Debug("cluster info: %v", r.cluster) return nil }