Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Start shared native provider using a magic cookie #275

Merged
merged 2 commits into from
Apr 21, 2022

Conversation

ulucinar
Copy link
Collaborator

@ulucinar ulucinar commented Apr 20, 2022

Description of your changes

It turns out that we cannot run the Terraform GCP provider as a shared server like we do for the AWS and Azure providers (by invoking the plugin binary with certain command-line options). We have identified another way in which we set a cookie in the native provider's environment to keep it running as a shared server. This PR switches to this method in the SharedProvider implementation.

I have:

  • Read and followed Crossplane's contribution process.
  • Run make reviewable to ensure this PR is ready for review.
  • Added backport release-x.y labels to auto-backport this PR if necessary.

How has this code been tested

Signed-off-by: Alper Rifat Ulucinar <ulucinar@users.noreply.github.com>
Copy link
Member

@muvaf muvaf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We went over the PR offline and this method seems to work for all but with more granular configuration. Thanks for digging and coming up with a solution that works for all the three!

// NewSharedProvider instantiates a SharedProvider with an
// OS executor using the supplied logger
func NewSharedProvider(l logging.Logger, nativeProviderPath string, opts ...SharedGRPCRunnerOption) *SharedProvider {
func NewSharedProvider(l logging.Logger, nativeProviderPath, nativeProviderName string, protocolVersion int, opts ...SharedGRPCRunnerOption) *SharedProvider {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We talked about this offline and it seems protocolVersion is not easily found by users and it's 5 for all the big three. So, having this value as default and overridden optionally similar to magic cookie could make it easier for folks to use this method.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @muvaf! We now default to 5 as the gRPC protocol version.

fmtSetEnv = "%s=%s"
envReattachConfig = "TF_REATTACH_PROVIDERS"
envMagicCookie = "TF_PLUGIN_MAGIC_COOKIE"
defaultMagicCookie = "d602bf8f470bc67ca7faa0386276bbdd4330efaf76d1a219cb4d6991ca9872b2"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a comment about how we found this value?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

…er to 5

Signed-off-by: Alper Rifat Ulucinar <ulucinar@users.noreply.github.com>
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.

2 participants