Skip to content

Commit

Permalink
Make agent gRPC errors distinguishable (woodpecker-ci#3936)
Browse files Browse the repository at this point in the history
  • Loading branch information
6543 committed Sep 5, 2024
1 parent c10e38b commit 12c2258
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions cmd/agent/core/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ func run(ctx context.Context, c *cli.Command, backends []types.Backend) error {

var transport grpc.DialOption
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")}))
} else {
transport = grpc.WithTransportCredentials(insecure.NewCredentials())
Expand All @@ -125,7 +126,7 @@ func run(ctx context.Context, c *cli.Command, backends []types.Backend) error {
}),
)
if err != nil {
return err
return fmt.Errorf("could not create new gRPC 'channel' for authentication: %w", err)
}
defer authConn.Close()

Expand All @@ -137,7 +138,7 @@ func run(ctx context.Context, c *cli.Command, backends []types.Backend) error {
authClient := agent_rpc.NewAuthGrpcClient(authConn, agentToken, agentConfig.AgentID)
authInterceptor, err := agent_rpc.NewAuthInterceptor(grpcClientCtx, authClient, authInterceptorRefreshInterval) //nolint:contextcheck
if err != nil {
return err
return fmt.Errorf("could not create new auth interceptor: %w", err)
}

conn, err := grpc.NewClient(
Expand All @@ -151,7 +152,7 @@ func run(ctx context.Context, c *cli.Command, backends []types.Backend) error {
grpc.WithStreamInterceptor(authInterceptor.Stream()),
)
if err != nil {
return err
return fmt.Errorf("could not create new gRPC 'channel' for normal orchestration: %w", err)
}
defer conn.Close()

Expand Down

0 comments on commit 12c2258

Please sign in to comment.