Repository navigation
Fetch a new access token after a 401 from Venafi Cloud - #853
Open
wallrj-cyberark wants to merge 1 commit into
Open
wallrj-cyberark wants to merge 1 commit into
wallrj-cyberark wants to merge 1 commit into
Conversation
- The Venafi Cloud client cached its access token until shortly before it expired, and reused it even after the server rejected it with 401. - When a cluster moves to another sub-TSG, the old token is no longer accepted. The agent then failed every upload until the token expired. - Drop the cached token on a 401, so the next retry fetches a new one. Co-authored-by: Georgi Yanev <georgi.yanev@cyberark.com> Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Richard Wall <richard.wall@cyberark.com>
wallrj-cyberark
marked this pull request as ready for review
November 17, 2026 13:29
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The agent caches its Venafi Cloud access token until about a minute before it expires. It kept reusing that token even after the server rejected it with 401. This PR drops the cached token on a 401, so the next retry fetches a new one.
Why now?
The server is about to start answering 401 when a token is for the wrong sub-TSG. This happens when a cluster moves to another sub-TSG while the agent holds a token for the old one. Today an agent in that state fails every upload until its token expires, which can take about 15 minutes. With this change it recovers on the next retry, 30 seconds later.
Older agents still recover on their own once the token expires, so upgrading is not required.
Testing
TestVenafiCloudClient_ReauthenticatesOn401checks that a 401 on upload causes a second token request, and that the next upload succeeds.Test runs
go test ./pkg/client/ -racepasses, withKUBEBUILDER_ASSETSset for the VenafiConnection tests.[with Claude]