-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Version protocol switch #3833
Version protocol switch #3833
Conversation
helper/pluginutil/runner.go
Outdated
@@ -70,6 +71,7 @@ func (r *PluginRunner) runCommon(ctx context.Context, wrapper RunnerUtil, plugin | |||
if wrapper.MlockEnabled() { | |||
cmd.Env = append(cmd.Env, fmt.Sprintf("%s=%s", PluginMlockEnabled, "true")) | |||
} | |||
cmd.Env = append(cmd.Env, fmt.Sprintf("%s=%s", PluginVaultVersionEnv, version.GetVersion().VersionNumber())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
version.GetVersion().VersionNumber()
would return "(version unknown)" if if Version == "unknown" && VersionPrerelease == "unknown"
is satisfied. The check on https://github.com/hashicorp/vault/pull/3833/files#diff-cedffd7b22c2dfe1ab831e6c9f38e45dR19 would need to be changed to check for that instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the "unknown" check below not sufficient?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
version.GetVersion().VersionNumber()
would never return the string "unknown" (it returns "(version unknown)") so verString != "unknown"
will always be true, even when the version is unknown.
helper/pluginutil/version.go
Outdated
return constraint.Check(ver) | ||
} | ||
|
||
return false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should default to using/supporting gRPC instead of the other way around.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case if the version is unknown (e.g. from a master build that didn't inherit version from a git tag), it will end up will using netrpc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I see why you're doing this (to maintain backward compatibility in the case PluginVaultVersionEnv is not provided due to older versions of the plugin). Maybe if verString == ""
should be its own check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately we can't because older versions of vault won't be setting the ENV variable. If the variable is empty we can't use gRPC
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right so check for verString == ""
early and short-circuit by returning false. We can then return true here and in the error cases.
true, | ||
}, | ||
{ | ||
"", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shows up somewhat weird on the test output, wondering if it's worth adding a name
field for this
=== RUN TestGRPCSupport
=== RUN TestGRPCSupport/0.8.3
=== RUN TestGRPCSupport/0.9.2
=== RUN TestGRPCSupport/0.9.2+ent
=== RUN TestGRPCSupport/0.9.2-beta
=== RUN TestGRPCSupport/unknown
=== RUN TestGRPCSupport/#00
--- PASS: TestGRPCSupport (0.00s)
--- PASS: TestGRPCSupport/0.8.3 (0.00s)
--- PASS: TestGRPCSupport/0.9.2 (0.00s)
--- PASS: TestGRPCSupport/0.9.2+ent (0.00s)
--- PASS: TestGRPCSupport/0.9.2-beta (0.00s)
--- PASS: TestGRPCSupport/unknown (0.00s)
--- PASS: TestGRPCSupport/#00 (0.00s)
PASS
ok github.com/hashicorp/vault/helper/pluginutil 0.014s
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
No description provided.