-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Refactor: Replace sleep() with wait() #10504
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: main
Are you sure you want to change the base?
Conversation
Congratulations on your first Pull Request and welcome to the Apache CloudStack community! If you have any issues or are unsure about any anything please check our Contribution Guide (https://github.com/apache/cloudstack/blob/main/CONTRIBUTING.md)
|
thanks @sroopsai , let's test this. |
@blueorangutan package |
@DaanHoogland 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 ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #10504 +/- ##
============================================
- Coverage 16.60% 16.60% -0.01%
Complexity 13925 13925
============================================
Files 5730 5731 +1
Lines 508082 508236 +154
Branches 61770 61789 +19
============================================
+ Hits 84386 84388 +2
- Misses 414260 414413 +153
+ Partials 9436 9435 -1
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:
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✖️ debian ✔️ suse15. SL-JID 12680 |
@blueorangutan test |
@DaanHoogland a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests |
[SF] Trillian test result (tid-12599)
|
[SF] Trillian Build Failed (tid-12615) |
[SF] Trillian test result (tid-12623)
|
@blueorangutan test ol8 vmware-70u3 |
@weizhouapache a [SL] Trillian-Jenkins test job (ol8 mgmt + vmware-70u3) has been kicked to run smoke tests |
[SF] Trillian test result (tid-12635)
|
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.
clgtm
@blueorangutan package |
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 refactors the retry loop in runInContext
to use wait()
instead of Thread.sleep()
, allowing the lock on the current instance to be released during each retry interval.
- Replaced
Thread.sleep(...)
withwait(...)
inside the synchronized retry loop. - Kept the retry logic and timeout calculation identical.
Comments suppressed due to low confidence (1)
engine/orchestration/src/main/java/com/cloud/agent/manager/DirectAgentAttache.java:168
- Switching from
Thread.sleep()
towait()
releases the monitor lock, altering concurrency semantics. Verify that other threads should be allowed to enter synchronized methods on this instance during the wait.
wait(1000 * _HostPingRetryTimer.value());
@@ -165,7 +165,7 @@ protected synchronized void runInContext() { | |||
PingCommand cmd = resource.getCurrentStatus(_id); | |||
int retried = 0; | |||
while (cmd == null && ++retried <= _HostPingRetryCount.value()) { | |||
Thread.sleep(1000*_HostPingRetryTimer.value()); | |||
wait(1000 * _HostPingRetryTimer.value()); |
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.
Missing InterruptedException handling: wait(...)
throws InterruptedException. Surround this call with a try/catch or declare the exception to prevent compilation errors.
wait(1000 * _HostPingRetryTimer.value()); | |
try { | |
wait(1000 * _HostPingRetryTimer.value()); | |
} catch (InterruptedException e) { | |
logger.warn("PingTask interrupted while waiting to retry ping [id: {}, uuid: {}, name: {}]", _id, _uuid, _name, e); | |
Thread.currentThread().interrupt(); // Restore the interrupted status | |
break; | |
} |
Copilot uses AI. Check for mistakes.
engine/orchestration/src/main/java/com/cloud/agent/manager/DirectAgentAttache.java
Outdated
Show resolved
Hide resolved
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.
your code looks good @sroopsai , two remarks
- the co-pilot’s suggestion seem sensible (even when looking excessive)
- I think we can de with a utility that embeds the try/rethrow to use in other locations that use
sleep()
now as well.
note this is not a -1, just a question/suggestion to improve.
Thank You for the suggestions @DaanHoogland
|
that makes sense @sroopsai , A utility method that takes a timeout value and a set of log parameters would be great. Either in this PR or in a aseparate one. |
@blueorangutan package |
@DaanHoogland 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. |
Packaging result [SF]: ✖️ el8 ✖️ el9 ✔️ debian ✖️ suse15. SL-JID 13734 |
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 13753 |
This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch. |
@blueorangutan package |
@DaanHoogland 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. |
Packaging result [SF]: ✖️ el8 ✖️ el9 ✖️ debian ✖️ suse15. SL-JID 13769 |
engine/orchestration/src/main/java/com/cloud/agent/manager/DirectAgentAttache.java
Show resolved
Hide resolved
@blueorangutan package |
@DaanHoogland 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. |
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 13779 |
@blueorangutan package |
@DaanHoogland 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. |
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 13787 |
@blueorangutan test |
@DaanHoogland a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests |
[SF] Trillian test result (tid-13538)
|
@blueorangutan test ol8 vmware-70u3 |
@DaanHoogland a [SL] Trillian-Jenkins test job (ol8 mgmt + vmware-70u3) has been kicked to run smoke tests |
[SF] Trillian test result (tid-13539)
|
Description
This PR fixes #10486 .
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity