profile
viewpoint

Ask questionsProvider gRPC client logging causes failures.

I'm trying to write my own provider using the boilerplate template but I think there is a breaking bug. From what I can tell the provider is expected to output to stdout the port it is listening on, but what appears to happen is that grpc logging beats it to it.

When I run Pulumi up I get:

pulumi:providers:tsb (tsb):
    error: tsb (resource) plugin [/Users/liamwhite/go/bin/pulumi-resource-tsb] wrote a non-numeric port to stdout ('2021-05-27T13:44:04.073942Z	info	[core]parsed scheme: ""'): strconv.Atoi: parsing "2021-05-27T13:44:04.073942Z\tinfo\t[core]parsed scheme: \"\"": invalid syntax

I can fix this by manually configuring the grpc logger to either info log to stderr (or discard).

// NewHostClient dials the target address, connects over gRPC, and returns a client interface.
func NewHostClient(addr string) (*HostClient, error) {
	grpclog.SetLoggerV2(grpclog.NewLoggerV2(os.Stderr, os.Stderr, os.Stderr)) // <-----------
	conn, err := grpc.Dial(
		addr,
		grpc.WithInsecure(),
		grpc.WithUnaryInterceptor(rpcutil.OpenTracingClientInterceptor()),
		rpcutil.GrpcChannelOptions(),
	)
...

The only problem with sending to stderr is that it shows up in diagnostics so it may be preferable to io.Discard instead.

pulumi/pulumi

Answer questions liamawhite

@lukehoban I wasn't logging anything this just happened using the standard boilerplate that imports the Main function @3.3.1.

useful!
source:https://uonfu.com/
answerer
Liam White liamawhite @tetrateio Seattle, WA USA www.linkedin.com/in/liam-white Software Engineer @tetrateio. @istio Maintainer.
Github User Rank List