Skip to content

Commit

Permalink
cluster: Ignore the nightly version when judging whether the TiFlash …
Browse files Browse the repository at this point in the history
…version supports TLS (#1735)
  • Loading branch information
srstack authored Jan 26, 2022
1 parent 84b544b commit 4486823
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 21 deletions.
16 changes: 16 additions & 0 deletions pkg/cluster/manager/basic.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import (
"github.com/pingcap/tiup/pkg/meta"
"github.com/pingcap/tiup/pkg/set"
"github.com/pingcap/tiup/pkg/tui"
"github.com/pingcap/tiup/pkg/utils"
"golang.org/x/mod/semver"
)

// EnableCluster enable/disable the service in a cluster
Expand Down Expand Up @@ -281,3 +283,17 @@ func getMonitorHosts(topo spec.Topology) (map[string]hostInfo, set.StringSet) {

return uniqueHosts, noAgentHosts
}

// checkTiFlashWithTLS check tiflash vserson
func checkTiFlashWithTLS(topo spec.Topology, version string) error {
if clusterSpec, ok := topo.(*spec.Specification); ok {
if clusterSpec.GlobalOptions.TLSEnabled {
if (semver.Compare(version, "v4.0.5") < 0 &&
len(clusterSpec.TiFlashServers) > 0) &&
version != utils.NightlyVersionAlias {
return fmt.Errorf("TiFlash %s is not supported in TLS enabled cluster", version)
}
}
}
return nil
}
10 changes: 3 additions & 7 deletions pkg/cluster/manager/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import (
"github.com/pingcap/tiup/pkg/set"
"github.com/pingcap/tiup/pkg/tui"
"github.com/pingcap/tiup/pkg/utils"
"golang.org/x/mod/semver"
)

// DeployOptions contains the options for scale out.
Expand Down Expand Up @@ -88,12 +87,9 @@ func (m *Manager) Deploy(
if err := spec.ParseTopologyYaml(topoFile, topo); err != nil {
return err
}
if clusterSpec, ok := topo.(*spec.Specification); ok {
if clusterSpec.GlobalOptions.TLSEnabled &&
semver.Compare(clusterVersion, "v4.0.5") < 0 &&
len(clusterSpec.TiFlashServers) > 0 {
return fmt.Errorf("TiFlash %s is not supported in TLS enabled cluster", clusterVersion)
}

if err := checkTiFlashWithTLS(topo, clusterVersion); err != nil {
return err
}

instCnt := 0
Expand Down
9 changes: 2 additions & 7 deletions pkg/cluster/manager/scale_out.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import (
"github.com/pingcap/tiup/pkg/set"
"github.com/pingcap/tiup/pkg/tui"
"github.com/pingcap/tiup/pkg/utils"
"golang.org/x/mod/semver"
"gopkg.in/yaml.v3"
)

Expand Down Expand Up @@ -93,12 +92,8 @@ func (m *Manager) ScaleOut(
return err
}

if clusterSpec, ok := topo.(*spec.Specification); ok {
if clusterSpec.GlobalOptions.TLSEnabled &&
semver.Compare(base.Version, "v4.0.5") < 0 &&
len(clusterSpec.TiFlashServers) > 0 {
return fmt.Errorf("TiFlash %s is not supported in TLS enabled cluster", base.Version)
}
if err := checkTiFlashWithTLS(topo, base.Version); err != nil {
return err
}

if newPartTopo, ok := newPart.(*spec.Specification); ok {
Expand Down
11 changes: 4 additions & 7 deletions pkg/cluster/manager/tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (

"github.com/pingcap/tiup/pkg/set"
"github.com/pingcap/tiup/pkg/tui"
"golang.org/x/mod/semver"
)

// TLS set cluster enable/disable encrypt communication by tls
Expand Down Expand Up @@ -129,13 +128,11 @@ func (m *Manager) TLS(name string, gOpt operator.Options, enable, cleanCertifica
// checkTLSEnv check tiflash vserson and show confirm
func checkTLSEnv(topo spec.Topology, clusterName, version string, skipConfirm bool) error {
// check tiflash version
if clusterSpec, ok := topo.(*spec.Specification); ok {
if clusterSpec.GlobalOptions.TLSEnabled {
if semver.Compare(version, "v4.0.5") < 0 && len(clusterSpec.TiFlashServers) > 0 {
return fmt.Errorf("TiFlash %s is not supported in TLS enabled cluster", version)
}
}
if err := checkTiFlashWithTLS(topo, version); err != nil {
return err
}

if clusterSpec, ok := topo.(*spec.Specification); ok {
if len(clusterSpec.PDServers) != 1 {
return errorx.EnsureStackTrace(fmt.Errorf("Having multiple PD nodes is not supported when enable/disable TLS")).
WithProperty(tui.SuggestionFromString("Please `scale-in` PD nodes to one and try again."))
Expand Down

0 comments on commit 4486823

Please sign in to comment.