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

vault: fix namespace reset for clients with unset namespace #23491

Merged
merged 1 commit into from
Jul 3, 2024

Conversation

tgross
Copy link
Member

@tgross tgross commented Jul 2, 2024

The Vault "logical" API doesn't allow configuring the namespace on a per-request basis. Instead, it's set on the client. Our vaultclient wrapper locks access to the API client and sets the namespace (and token, if applicable) for each request, and then resets the namespace and unlocks the API client.

The logic for resetting the namespace incorrectly assumed that if the Nomad agent's Vault configuration didn't set the namespace that it was canonicalized to the non-empty string "default". This results in the API client's namespace getting "stuck" whenever a job uses a non-default namespace if the configuration value is empty. Update the logic to always go back to the Nomad agent's configuration, rather than accepting the "previous" namespace from the caller.

This changeset also removes some long-dead code in the Vault client wrapper.

Fixes: #22230
Ref: https://hashicorp.atlassian.net/browse/NET-10207

The Vault "logical" API doesn't allow configuring the namespace on a per-request
basis. Instead, it's set on the client. Our `vaultclient` wrapper locks access
to the API client and sets the namespace (and token, if applicable) for each
request, and then resets the namespace and unlocks the API client.

The logic for resetting the namespace incorrectly assumed that if the Vault
configuration didn't set the namespace that it was canonicalized to the
non-empty string `"default"`. This results in the API client's namespace getting
"stuck" whenever a job uses a non-default namespace if the configuration value
is empty. Update the logic to always go back to the configuration, rather than
accepting the "previous" namespace from the caller.

This changeset also removes some long-dead code in the Vault client wrapper.

Fixes: #22230
Ref: https://hashicorp.atlassian.net/browse/NET-10207
@tgross tgross force-pushed the NET-10207-vault-client-namespace-reset branch from e6f89be to c039137 Compare July 2, 2024 19:47
@tgross tgross marked this pull request as ready for review July 2, 2024 19:47
Copy link
Contributor

@pkazmierczak pkazmierczak left a comment

Choose a reason for hiding this comment

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

LGTM!

@tgross tgross merged commit 18fdda6 into main Jul 3, 2024
19 checks passed
@tgross tgross deleted the NET-10207-vault-client-namespace-reset branch July 3, 2024 14:13
Copy link

I'm going to lock this pull request because it has been closed for 120 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 Dec 31, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
backport/ent/1.7.x+ent Changes are backported to 1.7.x+ent backport/1.8.x backport to 1.8.x release line theme/enterprise Issues related to Enterprise features theme/vault type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Nomad client's Vault client gets stuck on the wrong Vault namespace
2 participants