Skip to content

Commit

Permalink
opt: keep ports config for TiFlash 7.1.0+ to avoid restarting (#5223) (
Browse files Browse the repository at this point in the history
…#5225)

Co-authored-by: csuzhangxc <csuzhangxc@gmail.com>
  • Loading branch information
ti-chi-bot and csuzhangxc committed Aug 4, 2023
1 parent 62f179f commit 4d31255
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
5 changes: 5 additions & 0 deletions pkg/apis/label/label.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ const (
// when TiDB cluster is restored from volume snapshot based backup.
AnnTiKVVolumesReadyKey = "tidb.pingcap.com/tikv-volumes-ready"

// AnnoTiFlash710KeepPortsKey is the annotation key to indicate whether the TiFlash v7.1.0+ keeps ports to avoid restart.
// ports: tcp_port, http_port, tcp_port_secure and https_port.
// NOTE: this annotation should only be used for existing TiFlash v7.1.0+ clusters with ports config items.
AnnoTiFlash710KeepPortsKey = "tidb.pingcap.com/tiflash-710-keep-ports"

// PDLabelVal is PD label value
PDLabelVal string = "pd"
// TiDBLabelVal is TiDB label value
Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/pingcap/v1alpha1/tidbcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -1132,6 +1132,11 @@ func (tc *TidbCluster) SkipTLSWhenConnectTiDB() bool {
return ok
}

func (tc *TidbCluster) KeepTiFlash710Ports() bool {
_, ok := tc.Annotations[label.AnnoTiFlash710KeepPortsKey]
return ok
}

// TODO: We Should better do not specified the default value ourself if user not specified the item.
func (tc *TidbCluster) TiCDCTimezone() string {
if tc.Spec.TiCDC != nil && tc.Spec.TiCDC.Config != nil {
Expand Down
4 changes: 2 additions & 2 deletions pkg/manager/member/tiflash_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func getTiFlashConfigV2(tc *v1alpha1.TidbCluster) *v1alpha1.TiFlashConfigWraper
common.SetIfNil("tmp_path", "/data0/tmp")

// port
if ok, err := tiflashEqualOrGreaterThanV710.Check(version); err == nil && !ok {
if ok, err := tiflashEqualOrGreaterThanV710.Check(version); err == nil && !ok || tc.KeepTiFlash710Ports() {
common.SetIfNil("tcp_port", int64(v1alpha1.DefaultTiFlashTcpPort))
common.SetIfNil("http_port", int64(v1alpha1.DefaultTiFlashHttpPort))
}
Expand Down Expand Up @@ -229,7 +229,7 @@ func getTiFlashConfigV2(tc *v1alpha1.TidbCluster) *v1alpha1.TiFlashConfigWraper
common.Set("security.ca_path", path.Join(tiflashCertPath, corev1.ServiceAccountRootCAKey))
common.Set("security.cert_path", path.Join(tiflashCertPath, corev1.TLSCertKey))
common.Set("security.key_path", path.Join(tiflashCertPath, corev1.TLSPrivateKeyKey))
if ok, err := tiflashEqualOrGreaterThanV710.Check(version); err == nil && !ok {
if ok, err := tiflashEqualOrGreaterThanV710.Check(version); err == nil && !ok || tc.KeepTiFlash710Ports() {
common.SetIfNil("tcp_port_secure", int64(v1alpha1.DefaultTiFlashTcpPort))
common.SetIfNil("https_port", int64(v1alpha1.DefaultTiFlashHttpPort))
}
Expand Down

0 comments on commit 4d31255

Please sign in to comment.