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: support allowing tokens to expire without refresh #19691

Merged
merged 4 commits into from Jan 10, 2024

Conversation

tgross
Copy link
Member

@tgross tgross commented Jan 9, 2024

Some users with batch workloads or short-lived prestart tasks want to derive a Vaul token, use it, and then allow it to expire without requiring a constant refresh. Add the vault.allow_token_expiration field, which works only with the Workload Identity workflow and not the legacy workflow.

When set to true, this disables the client's renewal loop in the vault_hook. When Vault revokes the token lease, the token will no longer be valid. The client will also now automatically detect if the Vault auth configuration does not allow renewals and will disable the renewal loop automatically.

Note this should only be used when a secret is requested from Vault once at the start of a task or in a short-lived prestart task. Long-running tasks should never set allow_token_expiration=true if they obtain Vault secrets via template blocks, as the Vault token will expire and the template runner will continue to make failing requests to Vault until the vault_retry attempts are exhausted.

Fixes: #8690

Some users with batch workloads or short-lived prestart tasks want to derive a
Vaul token, use it, and then allow it to expire without requiring a constant
refresh. Add the `vault.allow_token_expiration` field, which works only with the
Workload Identity workflow and not the legacy workflow.

When set to true, this disables the client's renewal loop in the
`vault_hook`. When Vault revokes the token lease, the token will no longer be
valid. The client will also now automatically detect if the Vault auth
configuration does not allow renewals and will disable the renewal loop
automatically.

Note this should only be used when a secret is requested from Vault once at the
start of a task or in a short-lived prestart task. Long-running tasks should
never set `allow_token_expiration=true` if they obtain Vault secrets via
`template` blocks, as the Vault token will expire and the template runner will
continue to make failing requests to Vault until the `vault_retry` attempts are
exhausted.

Fixes: #8690
Copy link
Contributor

@lgfa29 lgfa29 left a comment

Choose a reason for hiding this comment

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

I think the boolean value is wrong when the token is not renewable, but otherwise LGTM!

It could also be useful to add a note about batch tokens to https://developer.hashicorp.com/nomad/docs/integrations/vault/acl.

website/content/docs/job-specification/vault.mdx Outdated Show resolved Hide resolved
client/allocrunner/taskrunner/vault_hook.go Outdated Show resolved Hide resolved
@tgross tgross merged commit 0935f44 into main Jan 10, 2024
21 checks passed
@tgross tgross deleted the disable-vault-refresh branch January 10, 2024 19:49
@tgross tgross added the backport/1.7.x backport to 1.7.x release line label Jan 10, 2024
nvanthao pushed a commit to nvanthao/nomad that referenced this pull request Mar 1, 2024
…9691)

Some users with batch workloads or short-lived prestart tasks want to derive a
Vaul token, use it, and then allow it to expire without requiring a constant
refresh. Add the `vault.allow_token_expiration` field, which works only with the
Workload Identity workflow and not the legacy workflow.

When set to true, this disables the client's renewal loop in the
`vault_hook`. When Vault revokes the token lease, the token will no longer be
valid. The client will also now automatically detect if the Vault auth
configuration does not allow renewals and will disable the renewal loop
automatically.

Note this should only be used when a secret is requested from Vault once at the
start of a task or in a short-lived prestart task. Long-running tasks should
never set `allow_token_expiration=true` if they obtain Vault secrets via
`template` blocks, as the Vault token will expire and the template runner will
continue to make failing requests to Vault until the `vault_retry` attempts are
exhausted.

Fixes: hashicorp#8690
nvanthao pushed a commit to nvanthao/nomad that referenced this pull request Mar 1, 2024
…9691)

Some users with batch workloads or short-lived prestart tasks want to derive a
Vaul token, use it, and then allow it to expire without requiring a constant
refresh. Add the `vault.allow_token_expiration` field, which works only with the
Workload Identity workflow and not the legacy workflow.

When set to true, this disables the client's renewal loop in the
`vault_hook`. When Vault revokes the token lease, the token will no longer be
valid. The client will also now automatically detect if the Vault auth
configuration does not allow renewals and will disable the renewal loop
automatically.

Note this should only be used when a secret is requested from Vault once at the
start of a task or in a short-lived prestart task. Long-running tasks should
never set `allow_token_expiration=true` if they obtain Vault secrets via
`template` blocks, as the Vault token will expire and the template runner will
continue to make failing requests to Vault until the `vault_retry` attempts are
exhausted.

Fixes: hashicorp#8690
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add an option to disable client Vault token renewal
2 participants