From 61be78ff10cb00a3100d66bd1c2b2455e9a9c514 Mon Sep 17 00:00:00 2001 From: Caio Almeida Date: Thu, 12 Dec 2024 20:20:47 -0300 Subject: [PATCH] chore: supporting the listen-address parameter Signed-off-by: Caio Almeida --- CONTRIBUTING.md | 7 ++++--- cmd/db-manager/v1beta1/main.go | 8 +++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 705aba59e6c..7d027ffe1c7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -88,9 +88,10 @@ Below is a list of command-line flags accepted by Katib controller: Below is a list of command-line flags accepted by Katib DB Manager: -| Name | Type | Default | Description | -| --------------- | ------------- | ------- | ------------------------------------------------------- | -| connect-timeout | time.Duration | 60s | Timeout before calling error during database connection | +| Name | Type | Default | Description | +| --------------- | ------------- | -------------| ------------------------------------------------------------------- | +| connect-timeout | time.Duration | 60s | Timeout before calling error during database connection | +| listen-address | string | 0.0.0.0:6789 | The network interface or IP address to receive incoming connections | ## Katib admission webhooks diff --git a/cmd/db-manager/v1beta1/main.go b/cmd/db-manager/v1beta1/main.go index 17f949f0690..50c904b0b41 100644 --- a/cmd/db-manager/v1beta1/main.go +++ b/cmd/db-manager/v1beta1/main.go @@ -35,7 +35,7 @@ import ( ) const ( - port = "0.0.0.0:6789" + defaultListenAddress = "0.0.0.0:6789" defaultConnectTimeout = time.Second * 60 ) @@ -90,7 +90,9 @@ func (s *server) Check(ctx context.Context, in *health_pb.HealthCheckRequest) (* func main() { var connectTimeout time.Duration + var listenAddress string flag.DurationVar(&connectTimeout, "connect-timeout", defaultConnectTimeout, "Timeout before calling error during database connection. (e.g. 120s)") + flag.StringVar(&listenAddress, "listen-address", defaultListenAddress, "The network interface or IP address to receive incoming connections. (e.g. 0.0.0.0:6789)") flag.Parse() var err error @@ -104,13 +106,13 @@ func main() { klog.Fatalf("Failed to open db connection: %v", err) } dbIf.DBInit() - listener, err := net.Listen("tcp", port) + listener, err := net.Listen("tcp", listenAddress) if err != nil { klog.Fatalf("Failed to listen: %v", err) } size := 1<<31 - 1 - klog.Infof("Start Katib manager: %s", port) + klog.Infof("Start Katib manager: %s", listenAddress) s := grpc.NewServer(grpc.MaxRecvMsgSize(size), grpc.MaxSendMsgSize(size)) api_pb.RegisterDBManagerServer(s, &server{}) health_pb.RegisterHealthServer(s, &server{})