From 5fb022a1d8913664e252c4452d70dcc66b539ef4 Mon Sep 17 00:00:00 2001 From: Kornilios Kourtis Date: Thu, 4 Jul 2024 15:18:36 +0200 Subject: [PATCH] tetragon-oci-hook: use grpc.NewClient replace uses of DialContext with NewClient, since the former is deprecated. Signed-off-by: Kornilios Kourtis --- contrib/tetragon-rthooks/cmd/oci-hook/main.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/contrib/tetragon-rthooks/cmd/oci-hook/main.go b/contrib/tetragon-rthooks/cmd/oci-hook/main.go index 281948ee961..f66333f1abe 100644 --- a/contrib/tetragon-rthooks/cmd/oci-hook/main.go +++ b/contrib/tetragon-rthooks/cmd/oci-hook/main.go @@ -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 } @@ -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 }