From 824467c40df383668e59574462982b0602df0c63 Mon Sep 17 00:00:00 2001 From: csuzhangxc Date: Fri, 4 Aug 2023 06:21:06 +0000 Subject: [PATCH 1/2] opt: keep ports config for TiFlash 7.1.0+ to avoid restarting --- pkg/apis/label/label.go | 5 +++++ pkg/apis/pingcap/v1alpha1/tidbcluster.go | 5 +++++ pkg/manager/member/tiflash_util.go | 4 ++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/pkg/apis/label/label.go b/pkg/apis/label/label.go index c70a650c29..3476d8816c 100644 --- a/pkg/apis/label/label.go +++ b/pkg/apis/label/label.go @@ -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-port" + // PDLabelVal is PD label value PDLabelVal string = "pd" // TiDBLabelVal is TiDB label value diff --git a/pkg/apis/pingcap/v1alpha1/tidbcluster.go b/pkg/apis/pingcap/v1alpha1/tidbcluster.go index 8f4698f002..0b4abbf54a 100644 --- a/pkg/apis/pingcap/v1alpha1/tidbcluster.go +++ b/pkg/apis/pingcap/v1alpha1/tidbcluster.go @@ -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 { diff --git a/pkg/manager/member/tiflash_util.go b/pkg/manager/member/tiflash_util.go index f954385289..f10c54c0c0 100644 --- a/pkg/manager/member/tiflash_util.go +++ b/pkg/manager/member/tiflash_util.go @@ -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)) } @@ -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)) } From 8f9e0561addf964ffc763acc5c15123eb5dc5059 Mon Sep 17 00:00:00 2001 From: csuzhangxc Date: Fri, 4 Aug 2023 06:22:37 +0000 Subject: [PATCH 2/2] fix word --- pkg/apis/label/label.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/apis/label/label.go b/pkg/apis/label/label.go index 3476d8816c..3007555fd2 100644 --- a/pkg/apis/label/label.go +++ b/pkg/apis/label/label.go @@ -143,7 +143,7 @@ const ( // 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-port" + AnnoTiFlash710KeepPortsKey = "tidb.pingcap.com/tiflash-710-keep-ports" // PDLabelVal is PD label value PDLabelVal string = "pd"