Skip to content

fix(vault): exit token renewal when setup fails - #7940

Open
archy-rock3t-cloud wants to merge 1 commit into
kedacore:mainfrom
sophotechlabs:fix/vault-renew-token-panic
Open

fix(vault): exit token renewal when setup fails#7940
archy-rock3t-cloud wants to merge 1 commit into
kedacore:mainfrom
sophotechlabs:fix/vault-renew-token-panic

Conversation

@archy-rock3t-cloud

@archy-rock3t-cloud archy-rock3t-cloud commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

renewToken called Renew() on a nil watcher after RenewSelf failed, panicking the operator.

  • Return on setup errors.
  • Stop() closes stopCh rather than sending.
  • Set vh.client before the goroutine.

Checklist

Fixes #7939

@archy-rock3t-cloud
archy-rock3t-cloud requested a review from a team as a code owner July 28, 2026 12:06
@snyk-io

snyk-io Bot commented Jul 28, 2026

Copy link
Copy Markdown

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@keda-automation
keda-automation requested a review from a team July 28, 2026 12:06
@github-actions

Copy link
Copy Markdown

Thank you for your contribution! 🙏

Please understand that we will do our best to review your PR and give you feedback as soon as possible, but please bear with us if it takes a little longer as expected.

While you are waiting, make sure to:

  • Add an entry in our changelog in alphabetical order and link related issue
  • Update the documentation, if needed
  • Add unit & e2e tests for your changes
  • GitHub checks are passing
  • Is the DCO check failing? Here is how you can fix DCO issues

Once the initial tests are successful, a KEDA member will ensure that the e2e tests are run. Once the e2e tests have been successfully completed, the PR may be merged at a later date. Please be patient.

Learn more about our contribution guide.

Comment thread CHANGELOG.md Outdated
@keda-automation
keda-automation requested a review from a team July 28, 2026 13:12
@rickbrouwer

Copy link
Copy Markdown
Member

Thanks. Is it possible to add an unit test for this?

@archy-rock3t-cloud
archy-rock3t-cloud force-pushed the fix/vault-renew-token-panic branch 2 times, most recently from d73e76a to 5900d5b Compare July 28, 2026 15:36
Comment thread pkg/scaling/resolver/hashicorpvault_handler_test.go Outdated
@archy-rock3t-cloud
archy-rock3t-cloud force-pushed the fix/vault-renew-token-panic branch from 5900d5b to 8eac163 Compare July 28, 2026 15:54
@archy-rock3t-cloud

Copy link
Copy Markdown
Contributor Author

@rickbrouwer sure, updated

@rickbrouwer

Copy link
Copy Markdown
Member

It isn't really affected by this PR, but maybe we can take it into account. But with the early return, a failed RenewSelf now means the token is never renewed again for the lifetime of this handler, while the operator keeps running until the token expires. Would it make sense to make that explicit in the log message, so the eventual 403s on secret resolution are easier to trace back? "failed to create the payload" does not really describe the failure. Would something like "Vault renew token: failed to renew the token, renewal is disabled for this handler" be clearer? Wdyt?

@wozniakjan

wozniakjan commented Jul 30, 2026

Copy link
Copy Markdown
Member

/run-e2e vault
Update: You can check the progress here

passed tests: 3
Execution of tests/secret-providers/azure_keyvault/azure_keyvault_test.go, has passed after "one" attempts
Execution of tests/secret-providers/azure_keyvault_workload_identity/azure_keyvault_workload_identity_test.go, has passed after "one" attempts
Execution of tests/secret-providers/hashicorp_vault/hashicorp_vault_test.go, has passed after "two" attempts
failed tests: 0

@wozniakjan

Copy link
Copy Markdown
Member

Would something like "Vault renew token: failed to renew the token, renewal is disabled for this handler" be clearer? Wdyt?

checking the error messages, I agree they are a bit confusing, but since they have been that way for a long time, I'm ok addressing those separately

means the token is never renewed again for the lifetime of this handle

wondering if it's possible to run the renewal in a forever async loop like it's done for the elastic forecast scaler?

func (s *elasticForecastScaler) forecastRenewal(ctx context.Context) {

@keda-automation
keda-automation requested a review from a team July 31, 2026 10:21
Signed-off-by: Artem Muterko <artem@sopho.tech>
@archy-rock3t-cloud
archy-rock3t-cloud force-pushed the fix/vault-renew-token-panic branch from 69eb94e to b253f20 Compare July 31, 2026 10:31
@dttung2905

dttung2905 commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

/run-e2e vault
Update: You can check the progress here

⚠️ infrastructure failure: the e2e run did not complete normally

setup / teardown failures: 1
setup failed (tests/utils/setup_test.go): TestSetupArgoRollouts
passed tests: 0
failed tests: 0

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.

HashiCorp Vault token renewal panics and crashes the operator when the token cannot be renewed

4 participants