Skip to content

User vm manager cleanup#12779

Open
DaanHoogland wants to merge 3 commits into4.22from
UserVmManagerCleanup
Open

User vm manager cleanup#12779
DaanHoogland wants to merge 3 commits into4.22from
UserVmManagerCleanup

Conversation

@DaanHoogland
Copy link
Contributor

Description

This PR cleans static analysis warnings from UserVmManagerImpl and some in dependencies.

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?

@codecov
Copy link

codecov bot commented Mar 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 17.68%. Comparing base (5caf6cd) to head (f237082).
⚠️ Report is 17 commits behind head on 4.22.

Additional details and impacted files
@@             Coverage Diff              @@
##               4.22   #12779      +/-   ##
============================================
+ Coverage     17.60%   17.68%   +0.08%     
- Complexity    15659    15780     +121     
============================================
  Files          5917     5917              
  Lines        531394   535073    +3679     
  Branches      64970    66522    +1552     
============================================
+ Hits          93575    94653    +1078     
- Misses       427269   429785    +2516     
- Partials      10550    10635      +85     
Flag Coverage Δ
uitests 3.68% <ø> (-0.03%) ⬇️
unittests 18.76% <ø> (+0.08%) ⬆️

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.

Copy link
Contributor

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 cleans up static analysis warnings in UserVmManagerImpl and related files, including the service interface and a template interface. The changes address issues like raw types, unnecessary casts, unused variables, inefficient null checks, and missing throw keywords.

Changes:

  • Removed unused imports, fields (statsCollector, vmScheduleManager), unused constants (MAX_HTTP_GET_LENGTH, etc.), and dead code (unused constructors/methods in VmAndCountDetails, getName(), getRandomPrivateTemplateName())
  • Simplified conditionals: replaced == null ? false : value with direct Boolean.parseBoolean, replaced !list.stream().anyMatch(...) with list.stream().noneMatch(...), replaced size() > 0 with !isEmpty(), etc.
  • Fixed multiple bugs: missing throw for InvalidParameterValueException at validation, NPE in error messages using null objects' methods, removed caller parameter from methods where it was unused, improved method signatures to remove unchecked exceptions

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.

File Description
server/src/main/java/com/cloud/vm/UserVmManagerImpl.java Major cleanup: remove unused imports/fields/methods, fix bugs (missing throw, null NPE in error messages), simplify conditionals/collections usage
server/src/test/java/com/cloud/vm/UserVmManagerImplTest.java Update test method calls to match new method signatures (removed caller parameters, replaced 1l with 1L)
api/src/main/java/com/cloud/vm/UserVmService.java Remove StorageUnavailableException from method signatures, remove redundant public modifier from interface method
api/src/main/java/com/cloud/template/VirtualMachineTemplate.java Add generic type parameter to getDetails() return type

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

}
}

private void closeCheckeReservation(List<CheckedReservation> checkedReservations) {
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

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

The method closeCheckeReservation has a typo in its name — it should be closeCheckedReservation. This is an inconsistency that will persist in the codebase and may cause confusion when searching for this method later.

Copilot uses AI. Check for mistakes.
@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.

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
7.4% Coverage on New Code (required ≥ 40%)

See analysis details on SonarQube Cloud

@blueorangutan
Copy link

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

} catch (CloudException e) {
throw new CloudRuntimeException("Unable to contact the agent to stop the Instance " + vm, e);
}
return status;
}

private UserVm rebootVirtualMachine(long userId, long vmId, boolean enterSetup, boolean forced) throws InsufficientCapacityException, ResourceUnavailableException {
private UserVm rebootVirtualMachine(long vmId, boolean enterSetup, boolean forced) throws InsufficientCapacityException, ResourceUnavailableException {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

planning to implement this sonar advice, but would like to have feedback from @abh1sar and @slavkap first on the extensive changes.

@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-15595)
Environment: kvm-ol8 (x2), zone: Advanced Networking with Mgmt server ol8
Total time taken: 52484 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr12779-t15595-kvm-ol8.zip
Smoke tests completed. 146 look OK, 3 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File
ContextSuite context=TestListIdsParams>:teardown Error 1.15 test_list_ids_parameter.py
test_01_snapshot_root_disk Error 5.02 test_snapshots.py
test_02_list_snapshots_with_removed_data_store Error 48.06 test_snapshots.py
test_02_list_snapshots_with_removed_data_store Error 48.06 test_snapshots.py
ContextSuite context=TestSnapshotStandaloneBackup>:teardown Error 26.72 test_snapshots.py
test_01_snapshot_usage Error 24.82 test_usage.py
test_01_vpn_usage Error 1.10 test_usage.py

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