Skip to content

Commit

Permalink
playground: fix cannot bind 0.0.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nexustar committed Mar 23, 2022
1 parent 9798f51 commit 22724a9
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion components/playground/instance/tiflash.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ type replicateEnablePlacementRulesConfig struct {

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

// StatusAddrs implements Instance interface.
Expand Down
3 changes: 2 additions & 1 deletion components/playground/instance/tiflash_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,12 @@ quota = "default"
ip = "::/0"
`

func writeTiFlashConfig(w io.Writer, version utils.Version, tcpPort, httpPort, servicePort, metricsPort int, ip, deployDir, clusterManagerPath string, tidbStatusAddrs, endpoints []string) error {
func writeTiFlashConfig(w io.Writer, version utils.Version, tcpPort, httpPort, servicePort, metricsPort int, host, deployDir, clusterManagerPath string, tidbStatusAddrs, endpoints []string) error {
pdAddrs := strings.Join(endpoints, ",")
dataDir := fmt.Sprintf("%s/data", deployDir)
tmpDir := fmt.Sprintf("%s/tmp", deployDir)
logDir := fmt.Sprintf("%s/log", deployDir)
ip := AdvertiseHost(host)
var conf string
if semver.Compare(version.String(), "v5.4.0") >= 0 || version.IsNightly() {
conf = fmt.Sprintf(tiflashConfig, pdAddrs, httpPort, tcpPort,
Expand Down
3 changes: 2 additions & 1 deletion components/playground/instance/tiflash_proxy_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,11 @@ data-dir = "%[6]s"
max-open-files = 256
`

func writeTiFlashProxyConfig(w io.Writer, version utils.Version, ip, deployDir string, servicePort, proxyPort, proxyStatusPort int) error {
func writeTiFlashProxyConfig(w io.Writer, version utils.Version, host, deployDir string, servicePort, proxyPort, proxyStatusPort int) error {
// TODO: support multi-dir
dataDir := fmt.Sprintf("%s/flash", deployDir)
logDir := fmt.Sprintf("%s/log", deployDir)
ip := AdvertiseHost(host)
var statusAddr string
if semver.Compare(version.String(), "v4.0.5") >= 0 || version.IsNightly() {
statusAddr = fmt.Sprintf(`status-addr = "0.0.0.0:%[2]d"
Expand Down
3 changes: 0 additions & 3 deletions components/playground/playground.go
Original file line number Diff line number Diff line change
Expand Up @@ -636,9 +636,6 @@ func (p *Playground) addInstance(componentID string, cfg instance.Config) (ins i
host = cfg.Host
}

// use the advertised host instead of 0.0.0.0
host = instance.AdvertiseHost(host)

switch componentID {
case spec.ComponentPD:
inst := instance.NewPDInstance(cfg.BinPath, dir, host, cfg.ConfigPath, id)
Expand Down

0 comments on commit 22724a9

Please sign in to comment.