Skip to content

Conversation

DaanHoogland
Copy link
Contributor

Description

This PR cleans up the StoragePoolAutomationImpl class to reduce its two big methods and reuse some code.

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)
  • 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
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

How did you try to break this feature and the system with this change?

@DaanHoogland
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

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

Copy link

codecov bot commented Oct 3, 2025

Codecov Report

❌ Patch coverage is 0% with 151 lines in your changes missing coverage. Please review.
✅ Project coverage is 16.17%. Comparing base (36cfd76) to head (66d0ba5).
⚠️ Report is 16 commits behind head on 4.20.

Files with missing lines Patch % Lines
...a/com/cloud/storage/StoragePoolAutomationImpl.java 0.00% 151 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##               4.20   #11789   +/-   ##
=========================================
  Coverage     16.17%   16.17%           
  Complexity    13296    13296           
=========================================
  Files          5656     5656           
  Lines        498219   498239   +20     
  Branches      60451    60446    -5     
=========================================
+ Hits          80579    80584    +5     
- Misses       408672   408684   +12     
- Partials       8968     8971    +3     
Flag Coverage Δ
uitests 4.00% <ø> (-0.01%) ⬇️
unittests 17.02% <0.00%> (+<0.01%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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

@blueorangutan
Copy link

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

@DaanHoogland
Copy link
Contributor Author

@blueorangutan test

@blueorangutan
Copy link

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

@blueorangutan
Copy link

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

Test Result Time (s) Test File
test_13_retrieve_vr_default_files Error 1.11 test_diagnostics.py
test_14_retrieve_vr_one_file Error 1.13 test_diagnostics.py
test_15_retrieve_ssvm_default_files Error 1.13 test_diagnostics.py
test_16_retrieve_ssvm_single_file Error 1.14 test_diagnostics.py
test_17_retrieve_cpvm_default_files Error 1.13 test_diagnostics.py
test_18_retrieve_cpvm_single_file Error 1.12 test_diagnostics.py

@DaanHoogland DaanHoogland changed the title refactor storapool automation refactor storepool automation Oct 6, 2025
@blueorangutan
Copy link

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

Test Result Time (s) Test File
test_08_arping_in_ssvm Failure 5.24 test_diagnostics.py
test_13_retrieve_vr_default_files Error 1.12 test_diagnostics.py
test_14_retrieve_vr_one_file Error 1.14 test_diagnostics.py
test_15_retrieve_ssvm_default_files Error 1.13 test_diagnostics.py
test_16_retrieve_ssvm_single_file Error 1.12 test_diagnostics.py
test_17_retrieve_cpvm_default_files Error 1.13 test_diagnostics.py
test_18_retrieve_cpvm_single_file Error 1.16 test_diagnostics.py
test_05_create_template_with_no_checksum Error 65.71 test_templates.py
ContextSuite context=TestRVPCSite2SiteVpn>:setup Error 0.00 test_vpc_vpn.py
ContextSuite context=TestVPCSite2SiteVPNMultipleOptions>:setup Error 0.00 test_vpc_vpn.py
ContextSuite context=TestVpcRemoteAccessVpn>:setup Error 0.00 test_vpc_vpn.py
ContextSuite context=TestVpcSite2SiteVpn>:setup Error 0.00 test_vpc_vpn.py
ContextSuite context=TestVPCRedundancy>:setup Error 0.00 test_vpc_redundant.py
ContextSuite context=TestVPCNics>:setup Error 0.00 test_vpc_router_nics.py

Copy link
Contributor

@JoaoJandre JoaoJandre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clgtm, did not test it.

@DaanHoogland DaanHoogland requested a review from Copilot October 8, 2025 13:25
@DaanHoogland DaanHoogland added this to the 4.20.2 milestone Oct 8, 2025
Copy link
Contributor

@Copilot Copilot AI left a 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 StoragePoolAutomationImpl class by breaking down its two large methods (maintain and cancelMaintain) into smaller, more focused helper methods and consolidating duplicated code.

Key changes:

  • Extracted multiple helper methods from the large maintain and cancelMaintain methods
  • Consolidated VM handling logic into reusable methods
  • Removed unused imports and injected dependencies

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +315 to +317
if (!(storagePool.getParent().equals(pool.getParent()) || !pool.getParent().equals(storagePool.getId())) &&
(storagePool.getStatus() == StoragePoolStatus.PrepareForMaintenance)) {
throw new CloudRuntimeException(String.format("Only one storage pool in a cluster can be in PrepareForMaintenance mode, %s is already in PrepareForMaintenance mode ", storagePool));
Copy link
Preview

Copilot AI Oct 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The boolean logic in this condition is complex and hard to understand. Consider breaking it down into named boolean variables or simplifying the logic for better readability.

Suggested change
if (!(storagePool.getParent().equals(pool.getParent()) || !pool.getParent().equals(storagePool.getId())) &&
(storagePool.getStatus() == StoragePoolStatus.PrepareForMaintenance)) {
throw new CloudRuntimeException(String.format("Only one storage pool in a cluster can be in PrepareForMaintenance mode, %s is already in PrepareForMaintenance mode ", storagePool));
boolean sameParent = storagePool.getParent().equals(pool.getParent());
boolean poolIsParentOfStoragePool = pool.getParent().equals(storagePool.getId());
boolean isOtherPoolInMaintenance = storagePool.getStatus() == StoragePoolStatus.PrepareForMaintenance;
// Only one storage pool in a cluster can be in PrepareForMaintenance mode
if (!(sameParent || !poolIsParentOfStoragePool) && isOtherPoolInMaintenance) {
throw new CloudRuntimeException(String.format("Only one storage pool in a cluster can be in PrepareForMaintenance mode, %s is already in PrepareForMaintenance mode ", storagePool));

Copilot uses AI. Check for mistakes.

Comment on lines +323 to +325
* // check if the vm has a root volume. If not, remove the item from the queue, the vm should be
* // started only when it has at least one root volume attached to it
* // don't allow to start vm that doesn't have a root volume
Copy link
Preview

Copilot AI Oct 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The JavaDoc comment is malformed. It should use proper JavaDoc format instead of starting each line with * //. These appear to be regular comments that should either be removed or converted to proper JavaDoc.

Suggested change
* // check if the vm has a root volume. If not, remove the item from the queue, the vm should be
* // started only when it has at least one root volume attached to it
* // don't allow to start vm that doesn't have a root volume
* Checks if the VM has a root volume. If not, removes the item from the queue.
* The VM should be started only when it has at least one root volume attached to it.
* Do not allow starting a VM that does not have a root volume.

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants