Skip to content

Conversation

@DaanHoogland
Copy link
Contributor

Description

This PR cleans the CapacityManagerImpl class from compiler warning ...

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?

regression testing only

@codecov
Copy link

codecov bot commented Nov 4, 2025

Codecov Report

❌ Patch coverage is 6.25000% with 30 lines in your changes missing coverage. Please review.
✅ Project coverage is 3.58%. Comparing base (3c64847) to head (7a6692d).

Files with missing lines Patch % Lines
...n/java/com/cloud/capacity/CapacityManagerImpl.java 6.25% 30 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff           @@
##            main   #11971   +/-   ##
======================================
  Coverage   3.58%    3.58%           
======================================
  Files        445      445           
  Lines      37552    37552           
  Branches    6914     6914           
======================================
  Hits        1347     1347           
  Misses     36039    36039           
  Partials     166      166           
Flag Coverage Δ
uitests 3.58% <ø> (ø)
unittests 18.52% <6.25%> (?)

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.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Nov 4, 2025

Quality Gate Failed Quality Gate failed

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

See analysis details on SonarQube Cloud

@apache apache deleted a comment from blueorangutan Dec 8, 2025
@apache apache deleted a comment from blueorangutan Dec 8, 2025
@DaanHoogland DaanHoogland force-pushed the cleanupCapacityManager branch from d3ec59b to 7e2c34f Compare December 8, 2025 16:09
@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.

@blueorangutan
Copy link

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

@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

@apache apache deleted a comment from blueorangutan Dec 9, 2025
@DaanHoogland DaanHoogland force-pushed the cleanupCapacityManager branch from 7e2c34f to 7a6692d Compare December 9, 2025 13:07
@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 9, 2025

Quality Gate Failed Quality Gate failed

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

See analysis details on SonarQube Cloud

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 removes compiler warnings from the CapacityManagerImpl class by cleaning up unused imports, removing dead code, eliminating unnecessary variable initializations and boxing/unboxing operations, and adding explicit casts to address lossy conversion warnings.

  • Removed unused imports (StartupRoutingCommand, SearchCriteria)
  • Removed dead code (empty stop() method, unreachable return statement, createCapacityEntry() method)
  • Eliminated unnecessary boxing/unboxing operations (Float to float conversions, removed redundant .intValue()/.longValue() calls)
  • Added explicit (long) casts to fix lossy conversion warnings in floating-point arithmetic
  • Removed redundant local variables and simplified return statements

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

reservedCpu +=
((Integer.parseInt(vmDetails.get(UsageEventVO.DynamicParameters.cpuNumber.name())) * Integer.parseInt(vmDetails.get(UsageEventVO.DynamicParameters.cpuSpeed.name()))) / cpuOvercommitRatio) *
clusterCpuOvercommitRatio;
(long) (((Long.parseLong(vmDetails.get(UsageEventVO.DynamicParameters.cpuNumber.name())) * Integer.parseInt(vmDetails.get(UsageEventVO.DynamicParameters.cpuSpeed.name()))) / cpuOvercommitRatio) *
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

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

Inconsistent parsing method used for cpuNumber parameter. This line uses Long.parseLong() while the similar code at line 713 (for used capacity calculation) uses Integer.parseInt() for the same parameter. For consistency and correctness, both should use the same parsing method, preferably Integer.parseInt() since cpuNumber is used as an integer elsewhere in the code (e.g., lines 721, 765).

Copilot uses AI. Check for mistakes.
reservedCpu +=
((Integer.parseInt(vmDetails.get(UsageEventVO.DynamicParameters.cpuNumber.name())) * so.getSpeed()) / cpuOvercommitRatio) *
clusterCpuOvercommitRatio;
(long) (((Long.parseLong(vmDetails.get(UsageEventVO.DynamicParameters.cpuNumber.name())) * so.getSpeed()) / cpuOvercommitRatio) *
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

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

Inconsistent parsing method used for cpuNumber parameter. This line uses Long.parseLong() while the similar code at line 718 (for used capacity calculation) uses Integer.parseInt() for the same parameter. For consistency and correctness, both should use the same parsing method, preferably Integer.parseInt() since cpuNumber is used as an integer elsewhere in the code (e.g., lines 721, 765).

Copilot uses AI. Check for mistakes.
@apache apache deleted a comment from blueorangutan Dec 9, 2025
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.

2 participants