diff --git a/cmd/tetra/common/client.go b/cmd/tetra/common/client.go index 447b8ac51e8..7ae5d28629d 100644 --- a/cmd/tetra/common/client.go +++ b/cmd/tetra/common/client.go @@ -7,7 +7,6 @@ import ( "context" "os/signal" "syscall" - "time" "github.com/cilium/tetragon/api/v1/tetragon" "github.com/cilium/tetragon/pkg/logger" @@ -20,7 +19,7 @@ func CliRunErr(fn func(ctx context.Context, cli tetragon.FineGuidanceSensorsClie ctx, cancel := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) defer cancel() - connCtx, connCancel := context.WithTimeout(ctx, 10*time.Second) + connCtx, connCancel := context.WithTimeout(ctx, viper.GetDuration(KeyTimeout)) defer connCancel() conn, err := grpc.DialContext(connCtx, viper.GetString(KeyServerAddress), grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithBlock()) if err != nil { diff --git a/cmd/tetra/common/flags.go b/cmd/tetra/common/flags.go index 178972230d6..4aedd327081 100644 --- a/cmd/tetra/common/flags.go +++ b/cmd/tetra/common/flags.go @@ -8,4 +8,5 @@ const ( KeyDebug = "debug" // bool KeyOutput = "output" // string KeyServerAddress = "server-address" // string + KeyTimeout = "timeout" // duration ) diff --git a/cmd/tetra/main.go b/cmd/tetra/main.go index d3c7c2758e5..7decf19c838 100644 --- a/cmd/tetra/main.go +++ b/cmd/tetra/main.go @@ -5,6 +5,7 @@ package main import ( "fmt" "os" + "time" "github.com/cilium/tetragon/cmd/tetra/common" "github.com/cilium/tetragon/pkg/logger" @@ -42,6 +43,7 @@ func new() *cobra.Command { flags := rootCmd.PersistentFlags() flags.BoolP(common.KeyDebug, "d", false, "Enable debug messages") flags.String(common.KeyServerAddress, "localhost:54321", "gRPC server address") + flags.Duration(common.KeyTimeout, 10*time.Second, "Connection timeout") viper.BindPFlags(flags) return rootCmd }