-
Notifications
You must be signed in to change notification settings - Fork 126
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
SNOW-833537 Refactor auth to make it ready for retries #836
Conversation
@@ -440,6 +378,101 @@ func authenticate( | |||
return &respd.Data, nil | |||
} | |||
|
|||
func tryAuth( |
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.
This function builds auth request data - for instance creates JWT token. We can retry this function invocation for specific error codes which will cause token recreation (with new expiration).
475033e
to
3ed8953
Compare
Hi @sfc-gh-pfus, To do that, we could bring the retry logic in retryHTTP.execute() to higher layer (like what you did in auth.go), and simply make retryHTTP.execute() to retry in the shorter interval (10 seconds by default). But in this way we would have the existing retry logic implemented in two places and have to change both of them in case we need further change on retry in the future. |
Hi @sfc-gh-ext-simba-hx , thank you very much for such deep explanation! I'm not keen to change retry behaviour on this low level, as there are two drawbacks:
I think, that having my solution - another level of retrying is a lesser of two evils. What do you think? |
Hi @sfc-gh-pfus |
Thanks @sfc-gh-ext-simba-hx for answering!
So current issue covers the situation:
Can you confirm my understanding so far? If I understand everything correctly, I can recommend the following points:
What do you think about my proposal? |
@sfc-gh-pfus |
I was thinking to add a go routine timer inside retry.go execute() so the select case will notify when the JWT renew time is up (every 10s) and renew the token before the next POST request (of course this will be restricted to JWT auth request). It will look like the following:
I was just playing the above code in a simple test app and haven't tested in the driver yet so not sure if this will work or not. But I'm not sure if a separate http.Client is needed. Did I simplify the problem too much? Also is it too risky to do this in retry.go? Please let me know your thoughts. Thanks, |
Hi @sfc-gh-ext-simba-jl ! Good to have someone also working on this :)
I started working on this yesterday afternoon and looks promising. Today I have busy time, but I hope I will post first version so you could take a look and we could decide if it's good enough. What do you think? Did I convince you? :) |
Fixed in other PRs. |
Description
Please explain the changes you made here.
Checklist
make fmt
to fix inconsistent formatsmake lint
to get lint errors and fix all of them