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

Increase plugin grpc message size to 64mb #650

Closed
wants to merge 1 commit into from

Conversation

gavinbunney
Copy link

This increase the plugin server grpc messages size to reflect the same values as the client (hashicorp/terraform#20879).

Without this change, grpc will fail sending messages of larger than 4mb, regardless of the client setting already done in Terraform:

rpc error: code = ResourceExhausted desc = grpc: received message larger than max (5655893 vs. 4194304)

@paultyng
Copy link
Contributor

paultyng commented Dec 4, 2020

This should only be set for the GetSchema call as its done in the client. Not sure if there is some way to do that on the server in gRPC?

@gavinbunney
Copy link
Author

@paultyng AFAICT it's only available on the entire server as it impacts the channel itself, so individual proto handling can't be changed

@paultyng
Copy link
Contributor

paultyng commented Dec 4, 2020

It looks like the default for send is already math.MaxInt32: https://pkg.go.dev/google.golang.org/grpc#MaxSendMsgSize

The only place the Terraform CLI client overrides the 4mb limit is the receive for GetSchema, so I think this is already possible given the default send. All the rest of the client requests use the 4mb limit.

@paultyng
Copy link
Contributor

paultyng commented Dec 4, 2020

@gavinbunney
Copy link
Author

gavinbunney commented Dec 4, 2020

Thanks @paultyng, you're right that the default for send is MaxInt32, however receive is still 4mb. I'm not familiar with the internals of how the terraform <-> provider grpc integration works, in terms of what goes back and forth for the various GetSchema calls.

I've tested this fix in my provider here, without it, in the case of large kubernetes CRDs the grpc message size failure message appears (as reported by users here gavinbunney/terraform-provider-kubectl#59).

Happy to update this PR to only have the change for receive?

@paultyng
Copy link
Contributor

paultyng commented Dec 4, 2020

If non-GetSchema calls with core are going over 4mb, I think that may actually be a bug/oversight on core's part that could be corrected in a future version (cc @jbardin if you have any additional context on this), so making this change here may turn breaking if they "fix the glitch" as it were. Considering this is affected by a string value, its not the GetSchema call but something else in the protocol going over 4mb, so fixing this, while it may work, may eventually just break again.

That being said, I'm not opposed to a more generic hook for you to override gRPC options.

Also, unsure if you are aware, but we've recently releases a lower level SDK (terraform-plugin-go) that allows usage of the "any" type for attributes. Which means instead of sending raw YAML, you could yamldecode this to a structured object, which would eliminate a lot of this size I would imagine, since it would strip whitespace, comments, etc. The Kubernetes Alpha provider among others is moving to this SDK to support the dynamic typing for those kinds of cases, its of course not a simple fix for you, but possibly something to consider longer term perhaps.

@paultyng
Copy link
Contributor

paultyng commented Dec 4, 2020

Another thought I had was having a user roundtrip via the yamlencode/yamldecode to strip comments / whitespace, etc. (or doing this internally in your provider). Doesn't necessarily solve it indefinitely but maybe buys you some time?

@bflad
Copy link
Contributor

bflad commented Feb 4, 2022

Hi @gavinbunney 👋 Thank you for submitting this. The plugin package's underlying gRPC server implementation is being switched over to the terraform-plugin-go tfprotov5/tf5server package in #857 so all the SDKs are consistently implemented. As part of that migration, the gRPC message limit will be 256MB. Hope this helps and thanks again for the contribution.

@bflad bflad closed this Feb 4, 2022
@github-actions
Copy link

github-actions bot commented Mar 7, 2022

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants