Skip to content

Commit 6c93db7

Browse files
authored
playground: fix cannot bind 0.0.0.0 (#1811)
1 parent cba67ca commit 6c93db7

4 files changed

Lines changed: 5 additions & 6 deletions

File tree

components/playground/instance/tiflash.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ type replicateEnablePlacementRulesConfig struct {
8383

8484
// Addr return the address of tiflash
8585
func (inst *TiFlashInstance) Addr() string {
86-
return fmt.Sprintf("%s:%d", inst.Host, inst.ServicePort)
86+
return fmt.Sprintf("%s:%d", AdvertiseHost(inst.Host), inst.ServicePort)
8787
}
8888

8989
// StatusAddrs implements Instance interface.

components/playground/instance/tiflash_config.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,12 @@ quota = "default"
9797
ip = "::/0"
9898
`
9999

100-
func writeTiFlashConfig(w io.Writer, version utils.Version, tcpPort, httpPort, servicePort, metricsPort int, ip, deployDir, clusterManagerPath string, tidbStatusAddrs, endpoints []string) error {
100+
func writeTiFlashConfig(w io.Writer, version utils.Version, tcpPort, httpPort, servicePort, metricsPort int, host, deployDir, clusterManagerPath string, tidbStatusAddrs, endpoints []string) error {
101101
pdAddrs := strings.Join(endpoints, ",")
102102
dataDir := fmt.Sprintf("%s/data", deployDir)
103103
tmpDir := fmt.Sprintf("%s/tmp", deployDir)
104104
logDir := fmt.Sprintf("%s/log", deployDir)
105+
ip := AdvertiseHost(host)
105106
var conf string
106107
if semver.Compare(version.String(), "v5.4.0") >= 0 || version.IsNightly() {
107108
conf = fmt.Sprintf(tiflashConfig, pdAddrs, httpPort, tcpPort,

components/playground/instance/tiflash_proxy_config.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,11 @@ data-dir = "%[6]s"
4646
max-open-files = 256
4747
`
4848

49-
func writeTiFlashProxyConfig(w io.Writer, version utils.Version, ip, deployDir string, servicePort, proxyPort, proxyStatusPort int) error {
49+
func writeTiFlashProxyConfig(w io.Writer, version utils.Version, host, deployDir string, servicePort, proxyPort, proxyStatusPort int) error {
5050
// TODO: support multi-dir
5151
dataDir := fmt.Sprintf("%s/flash", deployDir)
5252
logDir := fmt.Sprintf("%s/log", deployDir)
53+
ip := AdvertiseHost(host)
5354
var statusAddr string
5455
if semver.Compare(version.String(), "v4.0.5") >= 0 || version.IsNightly() {
5556
statusAddr = fmt.Sprintf(`status-addr = "0.0.0.0:%[2]d"

components/playground/playground.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -636,9 +636,6 @@ func (p *Playground) addInstance(componentID string, cfg instance.Config) (ins i
636636
host = cfg.Host
637637
}
638638

639-
// use the advertised host instead of 0.0.0.0
640-
host = instance.AdvertiseHost(host)
641-
642639
switch componentID {
643640
case spec.ComponentPD:
644641
inst := instance.NewPDInstance(cfg.BinPath, dir, host, cfg.ConfigPath, id)

0 commit comments

Comments
 (0)