-
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?
PowerFlex/ScaleIO client initialization, authentication and command execution improvements #12391
Conversation
…xecution improvements
|
@blueorangutan package |
|
@sureshanaparti a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## 4.22 #12391 +/- ##
============================================
- Coverage 17.59% 17.59% -0.01%
- Complexity 15598 15600 +2
============================================
Files 5910 5910
Lines 529692 529710 +18
Branches 64716 64713 -3
============================================
+ Hits 93202 93205 +3
- Misses 425998 426015 +17
+ Partials 10492 10490 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Pull request overview
This PR enhances PowerFlex/ScaleIO client initialization, authentication, and command execution by implementing lazy authentication, improving busy-wait handling, and adding default command timeouts. The changes address potential deadlock scenarios and ensure commands complete within asynchronous timeout limits.
Key Changes:
- Deferred client authentication from constructor to first API call with proper session expiry detection
- Added 5-minute default timeout for PowerFlex command execution to fit within async command timeouts
- Improved connection pool synchronization to prevent concurrent client initialization
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| ScaleIOGatewayClientImpl.java | Removed eager authentication from constructor, added volatile flag and busy-wait with Thread.yield(), enhanced session expiry checks |
| ScaleIOGatewayClientConnectionPool.java | Improved synchronization with explicit lock object, refactored client creation with Optional, added debug logging |
| ScaleIOUtil.java | Added DEFAULT_TIMEOUT_MS constant, updated all command executions to use timeout, added --file parameter to query commands, simplified removeMdms error handling |
| ScaleIOSDCManagerImpl.java | Fixed canUnprepareSDC logic to return false when multiple pools share same SDC, improved isHostSdcConnected loop structure and logging |
| ScaleIOPrimaryDataStoreDriver.java | Removed throws Exception declarations from method signatures |
| ScaleIOGatewayClientImplTest.java | Moved authentication verifications after API calls to align with lazy authentication |
| ScaleIOStoragePoolTest.java | Updated mocks to include timeout parameter in Script.runSimpleBashScript calls |
| ScaleIOStorageAdaptorTest.java | Updated mocks to include timeout parameter and --file parameter in commands |
| ConfigKey.java | Added valueInDomain convenience method |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| logger.debug("Final attempt succeeded the SDC {} of the pool {} to connect", sdcId, dataStore); | ||
| } else { | ||
| logger.debug("Final attempt failed the SDC {} of the pool {} to connect", sdcId, dataStore); |
Copilot
AI
Jan 8, 2026
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 error message contains grammatical issues. "Final attempt succeeded the SDC" should be "Final attempt succeeded for the SDC" or "Final attempt to connect the SDC succeeded". Similarly, "Final attempt failed the SDC" should be "Final attempt failed for the SDC" or "Final attempt to connect the SDC failed".
| logger.debug("Final attempt succeeded the SDC {} of the pool {} to connect", sdcId, dataStore); | |
| } else { | |
| logger.debug("Final attempt failed the SDC {} of the pool {} to connect", sdcId, dataStore); | |
| logger.debug("Final attempt to connect the SDC {} of the pool {} succeeded", sdcId, dataStore); | |
| } else { | |
| logger.debug("Final attempt to connect the SDC {} of the pool {} failed", sdcId, dataStore); |
...e/volume/scaleio/src/main/java/org/apache/cloudstack/storage/datastore/util/ScaleIOUtil.java
Show resolved
Hide resolved
| 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(); |
Copilot
AI
Jan 8, 2026
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 busy-wait loop with Thread.yield() can cause excessive CPU usage when waiting for authentication to complete. Thread.yield() is a hint to the scheduler but provides no guaranteed waiting period, so the loop may spin very rapidly consuming CPU cycles. Consider using a small Thread.sleep() instead, or better yet, using proper synchronization primitives like CountDownLatch or wait/notify to eliminate busy-waiting entirely.
| Thread.yield(); | |
| try { | |
| Thread.sleep(10L); | |
| } catch (InterruptedException ie) { | |
| Thread.currentThread().interrupt(); | |
| break; | |
| } |
...o/src/main/java/org/apache/cloudstack/storage/datastore/client/ScaleIOGatewayClientImpl.java
Show resolved
Hide resolved
| /** | ||
| * Use {@link ConfigKey#valueInScope(Scope, Long)} instead. | ||
| */ | ||
| public T valueInDomain(Long domainId) { | ||
| return valueInScope(Scope.Domain, domainId); | ||
| } |
Copilot
AI
Jan 8, 2026
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.
|
|
||
| wireMockRule.verify(getRequestedFor(urlEqualTo("/api/login")) | ||
| .withBasicAuth(new BasicCredentials(username, password))); |
Copilot
AI
Jan 8, 2026
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 verification call at lines 129-130 is unreachable code. Since the test expects a CloudRuntimeException to be thrown at line 127, execution will not reach the verification statement. This verification should be removed as it serves no purpose and creates misleading test code.
| wireMockRule.verify(getRequestedFor(urlEqualTo("/api/login")) | |
| .withBasicAuth(new BasicCredentials(username, password))); |
|
|
||
| wireMockRule.verify(getRequestedFor(urlEqualTo("/api/login")) | ||
| .withBasicAuth(new BasicCredentials(username, password))); |
Copilot
AI
Jan 8, 2026
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 verification call at lines 146-147 is unreachable code. Since the test expects a ServerApiException to be thrown at line 144, execution will not reach the verification statement. This verification should be removed as it serves no purpose and creates misleading test code.
| wireMockRule.verify(getRequestedFor(urlEqualTo("/api/login")) | |
| .withBasicAuth(new BasicCredentials(username, password))); |
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 16303 |
Description
This PR improves PowerFlex/ScaleIO client initialization , authentication and command execution.
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
How Has This Been Tested?
How did you try to break this feature and the system with this change?