From eeeac68065dc669f0494fbc2fbed394bbfc537ab Mon Sep 17 00:00:00 2001 From: Allen Zhong Date: Tue, 22 Mar 2022 18:50:37 +0800 Subject: [PATCH] cluster: fix port conflict check for tiflash instances --- pkg/cluster/spec/validate.go | 3 ++ pkg/cluster/spec/validate_test.go | 52 +++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/pkg/cluster/spec/validate.go b/pkg/cluster/spec/validate.go index 4c289d4674..32d4058ac3 100644 --- a/pkg/cluster/spec/validate.go +++ b/pkg/cluster/spec/validate.go @@ -624,6 +624,9 @@ func (s *Specification) portConflictsDetect() error { "WebPort", "TCPPort", "HTTPPort", + "FlashServicePort", + "FlashProxyPort", + "FlashProxyStatusPort", "ClusterPort", "NgPort", } diff --git a/pkg/cluster/spec/validate_test.go b/pkg/cluster/spec/validate_test.go index cc6b4db841..0355510467 100644 --- a/pkg/cluster/spec/validate_test.go +++ b/pkg/cluster/spec/validate_test.go @@ -129,6 +129,58 @@ tikv_servers: c.Assert(err, NotNil) c.Assert(err.Error(), Equals, "port conflict for '1234' between 'tidb_servers:172.16.5.138.port' and 'tikv_servers:172.16.5.138.status_port'") + topo = Specification{} + err = yaml.Unmarshal([]byte(` +global: + user: "test1" + ssh_port: 220 + deploy_dir: "test-deploy" + data_dir: "test-data" +tiflash_servers: + - host: 172.16.5.138 + tcp_port: 111 + http_port: 222 + flash_service_port: 1234 + flash_proxy_port: 444 + flash_proxy_status_port: 555 + metrics_port: 666 + - host: 172.16.5.138 + tcp_port: 1111 + http_port: 1222 + flash_service_port: 1333 + flash_proxy_port: 1444 + flash_proxy_status_port: 1234 + metrics_port: 1666 +`), &topo) + c.Assert(err, NotNil) + c.Assert(err.Error(), Equals, "port conflict for '1234' between 'tiflash_servers:172.16.5.138.flash_service_port' and 'tiflash_servers:172.16.5.138.flash_proxy_status_port'") + + topo = Specification{} + err = yaml.Unmarshal([]byte(` +global: + user: "test1" + ssh_port: 220 + deploy_dir: "test-deploy" + data_dir: "test-data" +tiflash_servers: + - host: 172.16.5.138 + tcp_port: 111 + http_port: 222 + flash_service_port: 333 + flash_proxy_port: 1234 + flash_proxy_status_port: 555 + metrics_port: 666 + - host: 172.16.5.138 + tcp_port: 1111 + http_port: 1222 + flash_service_port: 1333 + flash_proxy_port: 1234 + flash_proxy_status_port: 1555 + metrics_port: 1666 +`), &topo) + c.Assert(err, NotNil) + c.Assert(err.Error(), Equals, "port conflict for '1234' between 'tiflash_servers:172.16.5.138.flash_proxy_port' and 'tiflash_servers:172.16.5.138.flash_proxy_port'") + topo = Specification{} // tispark_masters has "omitempty" in its tag value err = yaml.Unmarshal([]byte(`