-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
fix: TokenRefreshInterceptor throws when running incluster #3445
Conversation
Token refresh after failed authentication was unsuccessful since TokenRefreshInterceptor was looking for reloading kubeconfig file even when running in incluster mode. This change removes kubeconfig handling from TokenRefreshInterceptor and re-uses the logic in autoconfig instead, which is prepared for both in/out-of cluster use cases. Signed-off-by: Tero Saarni <tero.saarni@est.tech>
I've done some manual testing with token renewal as well. The procedure is documented here. It seems OIDC path was never covered by a test case. Since I touched that line, SonarCloud alerted about it here. Should this PR introduce OIDC renewal test case? |
Yeah, Would be nice if you can write a test to cover this :-) . I don't mind it having in this PR |
@rohanKanojia OK, I'll check if I can figure out an approach to test that part as well. By the way, some checks seem bit flaky, is that to be expected? They seemed unrelated to the change. |
You're right. I've restarted them for now. Somehow these failures only seem to happen on Github Actions. |
I've now added a test case |
Kudos, SonarCloud Quality Gate passed! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code changes seem good - if I understand correctly, we get an unauthorized response, then it won't assume kubeconfig exists and look to the AuthProvider if possible.
Yes when we get unauthorized, the logic in
|
Is it possible to re-trigger failed tests to get a clean run? I think those are flakes. |
One more observation: My PR continues using the approach from existing implementation where reloading is based on Looking at other implementations kubernetes-client/java#967 reloads if 60 seconds has passed from previous reload. It seems to me this is not as straightforward to implement with Why would one use time based reloading? To help transitioning to expiring tokens, KEP 1205 describes that tokens include |
I think we discussed this in some other issue. I would only go for time based reloading if the expiration date is something known (e.g. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thx!
Description
Token refresh was unsuccessful after failed authentication when running incluster. The reason was that TokenRefreshInterceptor was expecting kubeconfig file to exists, even though in incluster mode it does not exist.
Fixes #3312
Signed-off-by: Tero Saarni tero.saarni@est.tech
Type of change
test, version modification, documentation, etc.)
Checklist