-
Notifications
You must be signed in to change notification settings - Fork 1.3k
PowerFlex/ScaleIO client initialization, authentication and command execution improvements #12391
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
base: 4.22
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -92,7 +92,7 @@ public class ScaleIOGatewayClientImpl implements ScaleIOGatewayClient { | |||||||||||||||
|
|
||||||||||||||||
| private String username; | ||||||||||||||||
| private String password; | ||||||||||||||||
| private String sessionKey = null; | ||||||||||||||||
| private String sessionKey; | ||||||||||||||||
|
|
||||||||||||||||
| // The session token is valid for 8 hours from the time it was created, unless there has been no activity for 10 minutes | ||||||||||||||||
| // Reference: https://cpsdocs.dellemc.com/bundle/PF_REST_API_RG/page/GUID-92430F19-9F44-42B6-B898-87D5307AE59B.html | ||||||||||||||||
|
|
@@ -102,7 +102,7 @@ public class ScaleIOGatewayClientImpl implements ScaleIOGatewayClient { | |||||||||||||||
| private static final long MAX_IDLE_TIME_IN_MILLISECS = MAX_IDLE_TIME_IN_MINS * 60 * 1000; | ||||||||||||||||
| private static final long BUFFER_TIME_IN_MILLISECS = 30 * 1000; // keep 30 secs buffer before the expiration (to avoid any last-minute operations) | ||||||||||||||||
|
|
||||||||||||||||
| private boolean authenticating = false; | ||||||||||||||||
| private volatile boolean authenticating = false; | ||||||||||||||||
| private long createTime = 0; | ||||||||||||||||
| private long lastUsedTime = 0; | ||||||||||||||||
|
|
||||||||||||||||
|
|
@@ -142,7 +142,6 @@ public ScaleIOGatewayClientImpl(final String url, final String username, final S | |||||||||||||||
| this.username = username; | ||||||||||||||||
| this.password = password; | ||||||||||||||||
|
|
||||||||||||||||
| authenticate(); | ||||||||||||||||
| logger.debug("API client for the PowerFlex gateway " + apiURI.getHost() + " is created successfully, with max connections: " | ||||||||||||||||
| + maxConnections + " and timeout: " + timeout + " secs"); | ||||||||||||||||
| } | ||||||||||||||||
|
|
@@ -181,7 +180,7 @@ private synchronized void authenticate() { | |||||||||||||||
| long now = System.currentTimeMillis(); | ||||||||||||||||
| createTime = lastUsedTime = now; | ||||||||||||||||
| } catch (final IOException e) { | ||||||||||||||||
| logger.error("Failed to authenticate PowerFlex API Gateway " + apiURI.getHost() + " due to: " + e.getMessage() + getConnectionManagerStats()); | ||||||||||||||||
| logger.error("Failed to authenticate PowerFlex API Gateway " + apiURI.getHost() + " due to: " + e.getMessage() + getConnectionManagerStats(), e); | ||||||||||||||||
| throw new CloudRuntimeException("Failed to authenticate PowerFlex API Gateway " + apiURI.getHost() + " due to: " + e.getMessage()); | ||||||||||||||||
| } finally { | ||||||||||||||||
| authenticating = false; | ||||||||||||||||
|
|
@@ -199,6 +198,10 @@ private synchronized void renewClientSessionOnExpiry() { | |||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| private boolean isSessionExpired() { | ||||||||||||||||
| if (sessionKey == null) { | ||||||||||||||||
| logger.debug("Session never created for the Gateway " + apiURI.getHost()); | ||||||||||||||||
| return true; | ||||||||||||||||
| } | ||||||||||||||||
| long now = System.currentTimeMillis() + BUFFER_TIME_IN_MILLISECS; | ||||||||||||||||
| if ((now - createTime) > MAX_VALID_SESSION_TIME_IN_MILLISECS) { | ||||||||||||||||
| logger.debug("Session expired for the Gateway " + apiURI.getHost() + ", token is invalid after " + MAX_VALID_SESSION_TIME_IN_HRS | ||||||||||||||||
|
|
@@ -281,7 +284,11 @@ private <T> T get(final String path, final Class<T> type, final boolean renewAnd | |||||||||||||||
| HttpResponse response = null; | ||||||||||||||||
| boolean responseConsumed = false; | ||||||||||||||||
| try { | ||||||||||||||||
| while (authenticating); // wait for authentication request (if any) to complete (and to pick the new session key) | ||||||||||||||||
| while (authenticating) { // wait for authentication request (if any) | ||||||||||||||||
| // to complete (and to pick the new session key) | ||||||||||||||||
| Thread.yield(); | ||||||||||||||||
|
||||||||||||||||
| Thread.yield(); | |
| try { | |
| Thread.sleep(10L); | |
| } catch (InterruptedException ie) { | |
| Thread.currentThread().interrupt(); | |
| break; | |
| } |
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 documentation comment is misleading. It states "Use ConfigKey#valueInScope(Scope, Long) instead" which suggests this method is deprecated, but there is no @deprecated annotation. If this is a deprecated method meant to guide users to the preferred API, it should have the @deprecated annotation. If it's just a convenience method, the documentation should clarify that rather than suggesting users should use a different method.