Skip to content

Commit

Permalink
cmd/tetra: add configurable connection timeout
Browse files Browse the repository at this point in the history
[upstream commit 7f2edda]

Signed-off-by: William Findlay <[email protected]>
  • Loading branch information
willfindlay committed Sep 11, 2023
1 parent aef82e2 commit 8518ffa
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
3 changes: 1 addition & 2 deletions cmd/tetra/common/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"context"
"os/signal"
"syscall"
"time"

"github.com/cilium/tetragon/api/v1/tetragon"
"github.com/cilium/tetragon/pkg/logger"
Expand All @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions cmd/tetra/common/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ const (
KeyDebug = "debug" // bool
KeyOutput = "output" // string
KeyServerAddress = "server-address" // string
KeyTimeout = "timeout" // duration
)
2 changes: 2 additions & 0 deletions cmd/tetra/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package main
import (
"fmt"
"os"
"time"

"github.com/cilium/tetragon/cmd/tetra/common"
"github.com/cilium/tetragon/pkg/logger"
Expand Down Expand Up @@ -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
}

0 comments on commit 8518ffa

Please sign in to comment.