Skip to content

Commit

Permalink
tetragon-oci-hook: use grpc.NewClient
Browse files Browse the repository at this point in the history
replace uses of DialContext with NewClient, since the former is
deprecated.

Signed-off-by: Kornilios Kourtis <[email protected]>
  • Loading branch information
kkourt committed Jul 5, 2024
1 parent 36166c8 commit 986019b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions contrib/tetragon-rthooks/cmd/oci-hook/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,16 @@ func hookRequest(req *tetragon.RuntimeHookRequest) error {
ctx, cancel := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
defer cancel()

connCtx, connCancel := context.WithTimeout(ctx, cliConf.GrpcTimeout)
defer connCancel()
conn, err := grpc.DialContext(connCtx, cliConf.AgentAddr, grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithBlock())
conn, err := grpc.NewClient(cliConf.AgentAddr, grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
return fmt.Errorf("connecting to agent (%s) failed: %s", err, cliConf.AgentAddr)
}
defer conn.Close()

connCtx, connCancel := context.WithTimeout(ctx, cliConf.GrpcTimeout)
defer connCancel()
client := tetragon.NewFineGuidanceSensorsClient(conn)
_, err = client.RuntimeHook(ctx, req)
_, err = client.RuntimeHook(connCtx, req)
if err != nil {
return err
}
Expand Down Expand Up @@ -381,16 +381,16 @@ func serverVersion(log *slog.Logger) (string, error) {
ctx, cancel := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
defer cancel()

connCtx, connCancel := context.WithTimeout(ctx, cliConf.GrpcTimeout)
defer connCancel()
conn, err := grpc.DialContext(connCtx, cliConf.AgentAddr, grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithBlock())
conn, err := grpc.NewClient(cliConf.AgentAddr, grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
return "", fmt.Errorf("connecting to agent (%s) failed: %s", err, cliConf.AgentAddr)
}
defer conn.Close()

connCtx, connCancel := context.WithTimeout(ctx, cliConf.GrpcTimeout)
defer connCancel()
client := tetragon.NewFineGuidanceSensorsClient(conn)
res, err := client.GetVersion(ctx, req)
res, err := client.GetVersion(connCtx, req)
if err != nil {
return "", err
}
Expand Down
2 changes: 1 addition & 1 deletion docs/content/en/docs/installation/runtime-hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ Output should be something like:

Install the new configuration file and restart containerd
```shell
cp /tmp/new-config.toml /etc/containerd/config.toml
minikube cp /tmp/new-config.toml /etc/containerd/config.toml
ssh sudo systemctl restart containerd
```

Expand Down

0 comments on commit 986019b

Please sign in to comment.