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

Automatic token refresh does not work. Need to update vendored version of rusty #57

Open
jwatson-gcu opened this issue Sep 17, 2021 · 0 comments

Comments

@jwatson-gcu
Copy link

I have experienced that when the auth token expires in a long running application, the SDK does not retry the failed operation after token refresh. Instead, after refreshing the token, it returns the error from the original failed attempt.

I did some digging and it turns out that the root cause is actually an off-by-one error the vendored version of resty v2.2.0. This bug was fixed in v2.3.0.

The max retries are set in pkg/client/group_mgmt_client.go

const (
...
	maxLoginRetries   = 1
...
)

and used https://github.com/hpe-storage/nimble-golang-sdk/blob/master/pkg/client/group_mgmt_client.go#L130

// NewClient instantiates a new client to communicate with the Nimble group
func NewClient(ipAddress, username, password, apiVersion string, waitOnJobs, isTenant bool, tlsConfig *tls.Config) (*GroupMgmtClient, error) {
...
	// Add a retry condition to perform a relogin if the session has expired
	groupMgmtClient.Client.
		AddRetryCondition(
...
		).SetRetryCount(maxLoginRetries)  <<<<-------
...
}

The bug in resty counts the original request as one of the retry attempts, so that a RetryCount of 1 will only make the first request and upon retry it exits because it has exhausted the RetryCount.

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

No branches or pull requests

1 participant