Make agent gRPC errors distinguishable (#3936)

This commit is contained in:
6543 2024-07-19 07:24:11 +02:00 committed by GitHub
parent c6e04e39ef
commit e76f1408f4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -111,6 +111,7 @@ func run(ctx context.Context, c *cli.Command, backends []types.Backend) error {
var transport grpc.DialOption var transport grpc.DialOption
if c.Bool("grpc-secure") { if c.Bool("grpc-secure") {
log.Trace().Msg("use ssl for grpc")
transport = grpc.WithTransportCredentials(grpc_credentials.NewTLS(&tls.Config{InsecureSkipVerify: c.Bool("grpc-skip-insecure")})) transport = grpc.WithTransportCredentials(grpc_credentials.NewTLS(&tls.Config{InsecureSkipVerify: c.Bool("grpc-skip-insecure")}))
} else { } else {
transport = grpc.WithTransportCredentials(insecure.NewCredentials()) transport = grpc.WithTransportCredentials(insecure.NewCredentials())
@ -125,7 +126,7 @@ func run(ctx context.Context, c *cli.Command, backends []types.Backend) error {
}), }),
) )
if err != nil { if err != nil {
return err return fmt.Errorf("could not create new gRPC 'channel' for authentication: %w", err)
} }
defer authConn.Close() defer authConn.Close()
@ -137,7 +138,7 @@ func run(ctx context.Context, c *cli.Command, backends []types.Backend) error {
authClient := agent_rpc.NewAuthGrpcClient(authConn, agentToken, agentConfig.AgentID) authClient := agent_rpc.NewAuthGrpcClient(authConn, agentToken, agentConfig.AgentID)
authInterceptor, err := agent_rpc.NewAuthInterceptor(grpcClientCtx, authClient, authInterceptorRefreshInterval) //nolint:contextcheck authInterceptor, err := agent_rpc.NewAuthInterceptor(grpcClientCtx, authClient, authInterceptorRefreshInterval) //nolint:contextcheck
if err != nil { if err != nil {
return err return fmt.Errorf("could not create new auth interceptor: %w", err)
} }
conn, err := grpc.NewClient( conn, err := grpc.NewClient(
@ -151,7 +152,7 @@ func run(ctx context.Context, c *cli.Command, backends []types.Backend) error {
grpc.WithStreamInterceptor(authInterceptor.Stream()), grpc.WithStreamInterceptor(authInterceptor.Stream()),
) )
if err != nil { if err != nil {
return err return fmt.Errorf("could not create new gRPC 'channel' for normal orchestration: %w", err)
} }
defer conn.Close() defer conn.Close()