Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for receiving grpc_bind_adress on vttestserver #17231

Merged
merged 1 commit into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions go/vt/servenv/grpc_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions go/vt/vttest/local_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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", ""),
Expand Down
50 changes: 31 additions & 19 deletions go/vt/vttest/vtprocess.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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...)
Expand Down Expand Up @@ -199,16 +205,22 @@ func VtcomboProcess(environment Environment, args *Config, mysql MySQLManager) (
if args.VtComboBindAddress != "" {
vtcomboBindAddress = args.VtComboBindAddress
}
grpcBindAddress := "127.0.0.1"
Copy link
Contributor

@mattlord mattlord Jan 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gmpify , @frouioui , and @GuptaManan100
Was this intentional? It doesn't seem related to the feature added, is it? And I think it is causing this issue: #17396

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think this is incorrect that we missed. We shouldn't add 127.0.0.1 as the default, since an empty default means it listens on all the addresses, which is I think what we want.

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()
Expand Down
Loading