Skip to content

Commit

Permalink
cluster: fix port conflict check for tiflash instances (#1805)
Browse files Browse the repository at this point in the history
  • Loading branch information
AstroProfundis authored Mar 23, 2022
1 parent 62dc752 commit 3e08e7a
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/cluster/spec/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,9 @@ func (s *Specification) portConflictsDetect() error {
"WebPort",
"TCPPort",
"HTTPPort",
"FlashServicePort",
"FlashProxyPort",
"FlashProxyStatusPort",
"ClusterPort",
"NgPort",
}
Expand Down
52 changes: 52 additions & 0 deletions pkg/cluster/spec/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(`
Expand Down

0 comments on commit 3e08e7a

Please sign in to comment.