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

Set namespace for template server in agent #10757

Merged
merged 2 commits into from
Jan 25, 2021
Merged

Conversation

vishalnayak
Copy link
Member

@vishalnayak vishalnayak commented Jan 25, 2021

Fixes #10602

@vercel
Copy link

vercel bot commented Jan 25, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployments, click below or on the icon next to each commit.

vault-storybook – ./ui

🔍 Inspect: https://vercel.com/hashicorp/vault-storybook/m2kgvmbhz
✅ Preview: Canceled

[Deployment for 8f86d61 canceled]

@vishalnayak vishalnayak added this to the 1.6.2 milestone Jan 25, 2021
@calvn
Copy link
Member

calvn commented Jan 25, 2021

You might also want to include the CL entry in this PR :)

@@ -371,6 +371,7 @@ func (c *AgentCommand) Run(args []string) int {
// Check if a default namespace has been set
mountPath := config.AutoAuth.Method.MountPath
if cns := config.AutoAuth.Method.Namespace; cns != "" {
namespace = cns
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder if we should incorporate the logic for EnvVaultNamespace here? It's confusing to rely on the code in consult-template that consults the env when we don't specify a namespace explicitly. Especially since we do look at the env to set mountPath.

Copy link
Member Author

Choose a reason for hiding this comment

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

The EnvVaultNamespace logic here seems like it is only applicable to the auth subsystem of agent, and it seems like a sane thing to do. It is possible that we can refactor this to better manage the code, but I am feeling reluctant to touch it at this point in the release cycle.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It looks like by setting namespace = cns, if there is an env var set, the templating code will ignore it.

@ncabatoff
Copy link
Collaborator

Did you test to validate that #8534 is still fixed with this change?

@ncabatoff
Copy link
Collaborator

We could've maybe avoided this regression if we'd adopted #9777 and used it to write automated tests against this part of the code. It's not too late (well, it is for 1.6.2, but going forward...)

@ncabatoff
Copy link
Collaborator

We could've maybe avoided this regression if we'd adopted #9777 and used it to write automated tests against this part of the code. It's not too late (well, it is for 1.6.2, but going forward...)

Actually maybe not, it looks like the problematic area is outside the scope of what I tackled in that PR. Nonetheless, it'd be nice to see more of agent's Run method moved into more testable places.

@vishalnayak
Copy link
Member Author

Yes, I have verified that #8534 fix isn't broken. Used the script here to do it: https://github.com/hashicorp/vault-tools/blob/master/users/vishal/agent/agent_auto_auth_namespace.sh

@vercel vercel bot temporarily deployed to Preview – vault January 25, 2021 22:19 Inactive
@vercel vercel bot temporarily deployed to Preview – vault-storybook January 25, 2021 22:19 Inactive
@vishalnayak vishalnayak merged commit eb9351b into master Jan 25, 2021
@vishalnayak vishalnayak deleted the fix-agent-template-ns branch January 25, 2021 22:37
@calvn
Copy link
Member

calvn commented Jan 26, 2021

@ncabatoff FWIW I plan on re-visiting #9777 shortly.

vishalnayak added a commit that referenced this pull request Jan 26, 2021
* Set namespace for template server in agent

* cl++
vishalnayak added a commit that referenced this pull request Jan 26, 2021
* Add list peers to DR secondaries (#10746)

* Fix build (#10749)

* Move the declaration to a OSS build tag file to not have it collide w… (#10750)

* Move the declaration to a OSS build tag file to not have it collide with ent declarations

* Add comment

* Remove comment to trigger ci

* Fix remove peers check (#10758)

* Remove peer DR op token check only on secondaries (#10765)

* Set namespace for template server in agent (#10757)

* Set namespace for template server in agent

* cl++
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Vault agent not setting namespace correctly for requests
4 participants