Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provider gRPC client logging causes failures. #7156

Closed
liamawhite opened this issue May 27, 2021 · 5 comments · Fixed by #7891
Closed

Provider gRPC client logging causes failures. #7156

liamawhite opened this issue May 27, 2021 · 5 comments · Fixed by #7891
Assignees
Labels
kind/question Questions about existing features needs-repro Needs repro steps before it can be triaged or fixed resolution/fixed This issue was fixed

Comments

@liamawhite
Copy link
Contributor

liamawhite commented May 27, 2021

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.

@liamawhite liamawhite added the kind/bug Some behavior is incorrect or out of spec label May 27, 2021
@lukehoban lukehoban added resolution/by-design This issue won't be fixed because the functionality is working as designed and removed kind/bug Some behavior is incorrect or out of spec labels May 29, 2021
@lukehoban
Copy link
Member

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.

Yes - a requirement for a Pulumi plugin is that the first output to stdout is the port to use to connect to its gRPC server. That is part of the contract of what it means to be a Pulumi Plugin. You will need to ensure that you don't log anything to stdout ahead of that.

@liamawhite
Copy link
Contributor Author

liamawhite commented May 29, 2021

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

@lukehoban
Copy link
Member

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

I just tried out cloning https://github.com/pulumi/pulumi-provider-boilerplate, updating go.mod to use github.com/pulumi/pulumi/pkg/v3 v3.3.1, building the provider, and then running an example using the provider, and I am not seeing this issue. Do you have repro steps for what additional changes you are making that might potentially impact this?

@lukehoban lukehoban reopened this Jun 2, 2021
@lukehoban lukehoban self-assigned this Jun 2, 2021
@lukehoban lukehoban added kind/question Questions about existing features needs-repro Needs repro steps before it can be triaged or fixed and removed resolution/by-design This issue won't be fixed because the functionality is working as designed labels Jun 2, 2021
@liamawhite
Copy link
Contributor Author

I did some more investigating and after deleting my go mod cache and re-downloading everything it appears to not be an issue. I have no idea what was causing it.

@liamawhite
Copy link
Contributor Author

I noticed this hadn't actually gone away (we just hadn't rebuilt it recently). Having rebuilt without the logging changed I mentioned it still occurs. I have opened up a PR to solve the issue.

@liamawhite liamawhite reopened this Sep 2, 2021
lukehoban pushed a commit that referenced this issue Oct 6, 2021
Resolves #7156

Signed-off-by: Liam White <liam@tetrate.io>
@pulumi-bot pulumi-bot added the resolution/fixed This issue was fixed label Oct 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/question Questions about existing features needs-repro Needs repro steps before it can be triaged or fixed resolution/fixed This issue was fixed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants