diff --git a/go/vt/servenv/grpc_server.go b/go/vt/servenv/grpc_server.go index 96fe3c25ea9..8d30ee6d253 100644 --- a/go/vt/servenv/grpc_server.go +++ b/go/vt/servenv/grpc_server.go @@ -169,6 +169,11 @@ func GRPCPort() int { return gRPCPort } +// GRPCPort returns the value of the `--grpc_bind_address` flag. +func GRPCBindAddress() string { + return gRPCBindAddress +} + // isGRPCEnabled returns true if gRPC server is set func isGRPCEnabled() bool { if gRPCPort != 0 { diff --git a/go/vt/vttest/local_cluster.go b/go/vt/vttest/local_cluster.go index 576a78bb761..fa7e40feb12 100644 --- a/go/vt/vttest/local_cluster.go +++ b/go/vt/vttest/local_cluster.go @@ -660,6 +660,7 @@ func (db *LocalCluster) JSONConfig() any { config := map[string]any{ "bind_address": db.vt.BindAddress, "port": db.vt.Port, + "grpc_bind_address": db.vt.BindAddressGprc, "socket": db.mysql.UnixSocket(), "vtcombo_mysql_port": db.Env.PortForProtocol("vtcombo_mysql_port", ""), "mysql": db.Env.PortForProtocol("mysql", ""), diff --git a/go/vt/vttest/vtprocess.go b/go/vt/vttest/vtprocess.go index 3f34994bb75..6371811a60e 100644 --- a/go/vt/vttest/vtprocess.go +++ b/go/vt/vttest/vtprocess.go @@ -44,16 +44,17 @@ type HealthChecker func(addr string) bool // It can be spawned manually or through one of the available // helper methods. type VtProcess struct { - Name string - Directory string - LogDirectory string - Binary string - ExtraArgs []string - Env []string - BindAddress string - Port int - PortGrpc int - HealthCheck HealthChecker + Name string + Directory string + LogDirectory string + Binary string + ExtraArgs []string + Env []string + BindAddress string + BindAddressGprc string + Port int + PortGrpc int + HealthCheck HealthChecker proc *exec.Cmd exit chan error @@ -139,6 +140,11 @@ func (vtp *VtProcess) WaitStart() (err error) { vtp.proc.Args = append(vtp.proc.Args, fmt.Sprintf("%d", vtp.PortGrpc)) } + if vtp.BindAddressGprc != "" { + vtp.proc.Args = append(vtp.proc.Args, "--grpc_bind_address") + vtp.proc.Args = append(vtp.proc.Args, vtp.BindAddressGprc) + } + vtp.proc.Args = append(vtp.proc.Args, vtp.ExtraArgs...) vtp.proc.Env = append(vtp.proc.Env, os.Environ()...) vtp.proc.Env = append(vtp.proc.Env, vtp.Env...) @@ -199,16 +205,22 @@ func VtcomboProcess(environment Environment, args *Config, mysql MySQLManager) ( if args.VtComboBindAddress != "" { vtcomboBindAddress = args.VtComboBindAddress } + grpcBindAddress := "127.0.0.1" + if servenv.GRPCBindAddress() != "" { + grpcBindAddress = servenv.GRPCBindAddress() + } + vt := &VtProcess{ - Name: "vtcombo", - Directory: environment.Directory(), - LogDirectory: environment.LogDirectory(), - Binary: environment.BinaryPath("vtcombo"), - BindAddress: vtcomboBindAddress, - Port: environment.PortForProtocol("vtcombo", ""), - PortGrpc: environment.PortForProtocol("vtcombo", "grpc"), - HealthCheck: environment.ProcessHealthCheck("vtcombo"), - Env: environment.EnvVars(), + Name: "vtcombo", + Directory: environment.Directory(), + LogDirectory: environment.LogDirectory(), + Binary: environment.BinaryPath("vtcombo"), + BindAddress: vtcomboBindAddress, + BindAddressGprc: grpcBindAddress, + Port: environment.PortForProtocol("vtcombo", ""), + PortGrpc: environment.PortForProtocol("vtcombo", "grpc"), + HealthCheck: environment.ProcessHealthCheck("vtcombo"), + Env: environment.EnvVars(), } user, pass := mysql.Auth()