cloudstack icon indicating copy to clipboard operation
cloudstack copied to clipboard

Refactor: Replace sleep() with wait()

Open sroopsai opened this issue 8 months ago • 37 comments

Description

This PR fixes #10486 .

Types of changes

  • [ ] Breaking change (fix or feature that would cause existing functionality to change)
  • [ ] New feature (non-breaking change which adds functionality)
  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [x] Enhancement (improves an existing feature and functionality)
  • [ ] Cleanup (Code refactoring and cleanup, that may add test cases)
  • [ ] build/CI
  • [ ] test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • [ ] Major
  • [x] Minor

Bug Severity

  • [ ] BLOCKER
  • [ ] Critical
  • [ ] Major
  • [ ] Minor
  • [x] Trivial

sroopsai avatar Mar 05 '25 11:03 sroopsai

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) Here are some useful points:

  • In case of a new feature add useful documentation (raise doc PR at https://github.com/apache/cloudstack-documentation)
  • Be patient and persistent. It might take some time to get a review or get the final approval from the committers.
  • Pay attention to the quality of your code, ensure tests are passing and your PR doesn't have conflicts.
  • Please follow ASF Code of Conduct for all communication including (but not limited to) comments on Pull Requests, Issues, Mailing list and Slack.
  • Be sure to read the CloudStack Coding Conventions. Apache CloudStack is a community-driven project and together we are making it better 🚀. In case of doubts contact the developers at: Mailing List: [email protected] (https://cloudstack.apache.org/mailing-lists.html) Slack: https://apachecloudstack.slack.com/

boring-cyborg[bot] avatar Mar 05 '25 11:03 boring-cyborg[bot]

thanks @sroopsai , let's test this.

DaanHoogland avatar Mar 06 '25 10:03 DaanHoogland

@blueorangutan package

DaanHoogland avatar Mar 06 '25 10:03 DaanHoogland

@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.

blueorangutan avatar Mar 06 '25 10:03 blueorangutan

Codecov Report

Attention: Patch coverage is 0% with 13 lines in your changes missing coverage. Please review.

Project coverage is 16.60%. Comparing base (28e2411) to head (2658f94). Report is 31 commits behind head on main.

Files with missing lines Patch % Lines
...tils/src/main/java/com/cloud/utils/ThreadUtil.java 0.00% 12 Missing :warning:
...va/com/cloud/agent/manager/DirectAgentAttache.java 0.00% 1 Missing :warning:
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     
Flag Coverage Δ
uitests 3.93% <ø> (ø)
unittests 17.49% <0.00%> (-0.01%) :arrow_down:

Flags with carried forward coverage won't be shown. Click here to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov[bot] avatar Mar 06 '25 10:03 codecov[bot]

Packaging result [SF]: ✔️ el8 ✔️ el9 ✖️ debian ✔️ suse15. SL-JID 12680

blueorangutan avatar Mar 06 '25 11:03 blueorangutan

@blueorangutan test

DaanHoogland avatar Mar 06 '25 12:03 DaanHoogland

@DaanHoogland a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests

blueorangutan avatar Mar 06 '25 12:03 blueorangutan

[SF] Trillian test result (tid-12599) Environment: kvm-ol8 (x2), Advanced Networking with Mgmt server ol8 Total time taken: 56751 seconds Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr10504-t12599-kvm-ol8.zip Smoke tests completed. 135 look OK, 1 have errors, 5 did not run Only failed and skipped tests results shown below:

Test Result Time (s) Test File
ContextSuite context=TestSharedNetworkWithConfigDrive>:setup Error 1518.92 test_network.py
all_test_vpc_vpn Skipped --- test_vpc_vpn.py
all_test_webhook_delivery Skipped --- test_webhook_delivery.py
all_test_webhook_lifecycle Skipped --- test_webhook_lifecycle.py
all_test_host_maintenance Skipped --- test_host_maintenance.py
all_test_hostha_kvm Skipped --- test_hostha_kvm.py

blueorangutan avatar Mar 07 '25 04:03 blueorangutan

[SF] Trillian Build Failed (tid-12615)

blueorangutan avatar Mar 07 '25 13:03 blueorangutan

[SF] Trillian test result (tid-12623) Environment: kvm-ol9 (x2), Advanced Networking with Mgmt server ol9 Total time taken: 60312 seconds Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr10504-t12623-kvm-ol9.zip Smoke tests completed. 139 look OK, 2 have errors, 0 did not run Only failed and skipped tests results shown below:

Test Result Time (s) Test File
ContextSuite context=TestClusterDRS>:setup Error 0.00 test_cluster_drs.py
ContextSuite context=TestSharedNetworkWithConfigDrive>:setup Error 1520.31 test_network.py

blueorangutan avatar Mar 10 '25 12:03 blueorangutan

@blueorangutan test ol8 vmware-70u3

weizhouapache avatar Mar 10 '25 12:03 weizhouapache

@weizhouapache a [SL] Trillian-Jenkins test job (ol8 mgmt + vmware-70u3) has been kicked to run smoke tests

blueorangutan avatar Mar 10 '25 12:03 blueorangutan

[SF] Trillian test result (tid-12635) Environment: vmware-70u3 (x2), Advanced Networking with Mgmt server ol8 Total time taken: 64123 seconds Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr10504-t12635-vmware-70u3.zip Smoke tests completed. 134 look OK, 7 have errors, 0 did not run Only failed and skipped tests results shown below:

Test Result Time (s) Test File
test_01_events_resource Error 319.55 test_events_resource.py
test_01_events_resource Error 319.56 test_events_resource.py
test_deploy_more_vms_than_limit_allows Error 153.47 test_deploy_vms_in_parallel.py
test_01_prepare_and_cancel_maintenance Error 0.09 test_ms_maintenance_and_safe_shutdown.py
test_04_deploy_vm_for_other_user_and_test_vm_operations Error 129.84 test_network_permissions.py
ContextSuite context=TestSharedNetworkWithConfigDrive>:setup Error 1524.67 test_network.py
test_02_restore_vm_with_disk_offering Error 53.05 test_restore_vm.py
test_03_restore_vm_with_disk_offering_custom_size Error 57.28 test_restore_vm.py
test_02_restore_vm_strict_tags_failure Error 57.52 test_vm_strict_host_tags.py

blueorangutan avatar Mar 11 '25 07:03 blueorangutan

@blueorangutan package

sureshanaparti avatar Jun 05 '25 08:06 sureshanaparti

Thank You for the suggestions @DaanHoogland

  1. The other locations where sleep() is being called is in non-synchronised blocks, I think it is not good idea to replace those sleep() calls with wait(). But in this case sleep() is inside a synchronised block, there is no problem here. If you want I can write a utility method wrapping wait() call inside a try/catch block and use this method here and maybe use the method in future for sleep() calls (if written in synchronised blocks).

sroopsai avatar Jun 11 '25 15:06 sroopsai

Thank You for the suggestions @DaanHoogland

  1. The other locations where sleep() is being called is in non-synchronised blocks, I think it is not good idea to replace those sleep() calls with wait(). But in this case sleep() is inside a synchronised block, there is no problem here. If you want I can write a utility method wrapping wait() call inside a try/catch block and use this method here and maybe use the method in future for sleep() calls (if written in synchronised blocks).

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.

DaanHoogland avatar Jun 12 '25 06:06 DaanHoogland

@blueorangutan package

DaanHoogland avatar Jun 12 '25 06:06 DaanHoogland

@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.

blueorangutan avatar Jun 12 '25 06:06 blueorangutan

Packaging result [SF]: ✖️ el8 ✖️ el9 ✔️ debian ✖️ suse15. SL-JID 13734

blueorangutan avatar Jun 12 '25 08:06 blueorangutan

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 13753

blueorangutan avatar Jun 12 '25 13:06 blueorangutan

This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch.

github-actions[bot] avatar Jun 13 '25 13:06 github-actions[bot]

@blueorangutan package

DaanHoogland avatar Jun 13 '25 18:06 DaanHoogland

@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.

blueorangutan avatar Jun 13 '25 18:06 blueorangutan

Packaging result [SF]: ✖️ el8 ✖️ el9 ✖️ debian ✖️ suse15. SL-JID 13769

blueorangutan avatar Jun 13 '25 19:06 blueorangutan

@blueorangutan package

DaanHoogland avatar Jun 14 '25 09:06 DaanHoogland

@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.

blueorangutan avatar Jun 14 '25 09:06 blueorangutan

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 13779

blueorangutan avatar Jun 14 '25 10:06 blueorangutan

@blueorangutan package

DaanHoogland avatar Jun 16 '25 07:06 DaanHoogland

@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.

blueorangutan avatar Jun 16 '25 07:06 blueorangutan