diff --git a/components/cluster/command/destroy.go b/components/cluster/command/destroy.go index bd2c8f1d3f..cdb1c4b047 100644 --- a/components/cluster/command/destroy.go +++ b/components/cluster/command/destroy.go @@ -69,7 +69,8 @@ You can retain some nodes and roles data when destroy cluster, eg: logger.EnableAuditLog() metadata, err := spec.ClusterMetadata(clusterName) - if err != nil && !errors.Is(perrs.Cause(err), meta.ErrValidate) { + if err != nil && !errors.Is(perrs.Cause(err), meta.ErrValidate) && + perrs.Cause(err) != spec.ErrNoTiSparkMaster { return err } diff --git a/components/cluster/command/display.go b/components/cluster/command/display.go index fc0f1fd5ce..7fc6306eea 100644 --- a/components/cluster/command/display.go +++ b/components/cluster/command/display.go @@ -72,7 +72,8 @@ func newDisplayCmd() *cobra.Command { } metadata, err := spec.ClusterMetadata(clusterName) - if err != nil && !errors.Is(perrs.Cause(err), meta.ErrValidate) { + if err != nil && !errors.Is(perrs.Cause(err), meta.ErrValidate) && + perrs.Cause(err) != spec.ErrNoTiSparkMaster { return perrs.AddStack(err) } return destroyTombstoneIfNeed(clusterName, metadata, gOpt) @@ -88,7 +89,8 @@ func newDisplayCmd() *cobra.Command { func displayDashboardInfo(clusterName string) error { metadata, err := spec.ClusterMetadata(clusterName) - if err != nil && !errors.Is(perrs.Cause(err), meta.ErrValidate) { + if err != nil && !errors.Is(perrs.Cause(err), meta.ErrValidate) && + perrs.Cause(err) != spec.ErrNoTiSparkMaster { return err } @@ -121,7 +123,8 @@ func displayDashboardInfo(clusterName string) error { func displayClusterMeta(clusterName string, opt *operator.Options) error { clsMeta, err := spec.ClusterMetadata(clusterName) - if err != nil && !errors.Is(perrs.Cause(err), meta.ErrValidate) { + if err != nil && !errors.Is(perrs.Cause(err), meta.ErrValidate) && + perrs.Cause(err) != spec.ErrNoTiSparkMaster { return err } @@ -175,7 +178,8 @@ func destroyTombstoneIfNeed(clusterName string, metadata *spec.ClusterMeta, opt func displayClusterTopology(clusterName string, opt *operator.Options) error { metadata, err := spec.ClusterMetadata(clusterName) - if err != nil && !errors.Is(perrs.Cause(err), meta.ErrValidate) { + if err != nil && !errors.Is(perrs.Cause(err), meta.ErrValidate) && + perrs.Cause(err) != spec.ErrNoTiSparkMaster { return err } diff --git a/components/cluster/command/scale_out.go b/components/cluster/command/scale_out.go index b33281d902..5673c51b2f 100644 --- a/components/cluster/command/scale_out.go +++ b/components/cluster/command/scale_out.go @@ -92,7 +92,7 @@ func scaleOut(clusterName, topoFile string, opt scaleOutOptions) error { MonitoredOptions: metadata.Topology.MonitoredOptions, ServerConfigs: metadata.Topology.ServerConfigs, } - if err := clusterutil.ParseTopologyYaml(topoFile, &newPart); err != nil { + if err := clusterutil.ParseTopologyYaml(topoFile, &newPart); err != nil && errors.Cause(err) != spec.ErrNoTiSparkMaster { return err } diff --git a/pkg/cluster/spec/spec.go b/pkg/cluster/spec/spec.go index 3f39888e4d..96d580964e 100644 --- a/pkg/cluster/spec/spec.go +++ b/pkg/cluster/spec/spec.go @@ -36,9 +36,11 @@ const ( // general role names var ( - RoleMonitor = "monitor" - RoleTiSparkMaster = "tispark-master" - RoleTiSparkWorker = "tispark-worker" + RoleMonitor = "monitor" + RoleTiSparkMaster = "tispark-master" + RoleTiSparkWorker = "tispark-worker" + ErrNoTiSparkMaster = errors.New("There must be a Spark master node if you want to use the TiSpark component") + ErrMultipleTiSparkMaster = errors.New("TiSpark enabled cluster with more than 1 Spark master node is not supported") ) type ( @@ -507,12 +509,12 @@ func (s *Specification) validateTiSparkSpec() error { if s.TiSparkWorkers == nil || len(s.TiSparkWorkers) == 0 { return nil } - return errors.New("There must be a Spark master node if you want to use the TiSpark component") + return ErrNoTiSparkMaster } // We only support 1 spark master at present if s.TiSparkMasters != nil && len(s.TiSparkMasters) > 1 { - return errors.New("TiSpark enabled cluster with more than 1 Spark master node is not supported") + return ErrMultipleTiSparkMaster } return nil diff --git a/pkg/cluster/spec/util.go b/pkg/cluster/spec/util.go index dc007e5667..74bb892cdf 100644 --- a/pkg/cluster/spec/util.go +++ b/pkg/cluster/spec/util.go @@ -57,7 +57,7 @@ func ClusterMetadata(clusterName string) (*ClusterMeta, error) { var cm ClusterMeta err := GetSpecManager().Metadata(clusterName, &cm) if err != nil { - return nil, errors.AddStack(err) + return &cm, errors.AddStack(err) } return &cm, nil diff --git a/tests/tiup-cluster/script/cmd_subtest.sh b/tests/tiup-cluster/script/cmd_subtest.sh index e590d259ac..5ef162ff0a 100755 --- a/tests/tiup-cluster/script/cmd_subtest.sh +++ b/tests/tiup-cluster/script/cmd_subtest.sh @@ -88,9 +88,9 @@ function cmd_subtest() { echo "start scale in tispark" yes | tiup-cluster --yes scale-in $name -N 172.19.0.104:7078 + wait_instance_num_reach $name $total_sub_one echo "start scale out tispark" yes | tiup-cluster --yes scale-out $name ./topo/full_scale_in_tispark.yaml - wait_instance_num_reach $name $total_sub_one echo "start scale in grafana" tiup-cluster --yes scale-in $name -N 172.19.0.101:3000