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

Make plugin-specific env take precedence over sys env #25128

Merged
merged 6 commits into from
Feb 2, 2024

Conversation

tomhjp
Copy link
Contributor

@tomhjp tomhjp commented Jan 30, 2024

Unless SkipHostEnv is set, go-plugin layers os.Environ() over the top of any environment provided in the ClientConfig's command: https://github.com/hashicorp/go-plugin/blob/586d14f3dcef1eb42bfb7da4c7af102ec6638668/client.go#L657

While it's too big of a breaking change to switch that behaviour in go-plugin, for Vault it seems pretty obvious that users would expect the env they specify for plugins to take precedence over the system env. For example, if most of Vault should use one proxy via HTTP_PROXY, but one plugin needs to use a different proxy, it should be possible to override the base setting when registering the plugin.

I've added a flag to opt out of the behaviour change though, and also implemented log warnings to help any users concerned about unexpected changes in behaviour.

@tomhjp tomhjp added this to the 1.16.0-rc1 milestone Jan 30, 2024
@tomhjp tomhjp force-pushed the vault-23513/plugin-specific-env-override-sys branch from 02c7ee3 to f480a7a Compare January 30, 2024 14:27
@github-actions github-actions bot added the hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed label Jan 30, 2024
Copy link

Build Results:
All builds succeeded! ✅

Copy link

github-actions bot commented Jan 30, 2024

CI Results:
All Go tests succeeded! ✅

Copy link
Contributor

@austingebauer austingebauer left a comment

Choose a reason for hiding this comment

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

Change seems reasonable to me 👍

// go-plugin so always set SkipHostEnv and replicate the legacy behavior
// ourselves if user opts in.
if legacy, _ := strconv.ParseBool(os.Getenv(PluginUseLegacyEnvLayering)); legacy {
// Env vars are layered as follows, with later entries overriding
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

vault/plugincatalog/plugin_catalog.go Outdated Show resolved Hide resolved
@@ -69,6 +70,115 @@ func testPluginCatalog(t *testing.T) *PluginCatalog {
return pluginCatalog
}

type warningCountLogger struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

Neat pattern to test on the logs!

tomhjp and others added 3 commits January 30, 2024 17:30
Co-authored-by: Austin Gebauer <34121980+austingebauer@users.noreply.github.com>
@tomhjp tomhjp merged commit d8f3285 into main Feb 2, 2024
110 checks passed
@tomhjp tomhjp deleted the vault-23513/plugin-specific-env-override-sys branch February 2, 2024 11:20
@tomhjp
Copy link
Contributor Author

tomhjp commented Feb 2, 2024

Thanks!

Monkeychip pushed a commit that referenced this pull request Feb 5, 2024
* Make plugin-specific env take precedence over sys env
* Expand the existing plugin env integration test

---------

Co-authored-by: Austin Gebauer <34121980+austingebauer@users.noreply.github.com>
Monkeychip pushed a commit that referenced this pull request Feb 7, 2024
* Make plugin-specific env take precedence over sys env
* Expand the existing plugin env integration test

---------

Co-authored-by: Austin Gebauer <34121980+austingebauer@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants