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 17.51%. Comparing base (5bf869c) to head (a238e94).

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     17.51%   17.51%           
  Complexity    15585    15585           
=========================================
  Files          5914     5914           
  Lines        529867   529802   -65     
  Branches      64722    64713    -9     
=========================================
  Hits          92782    92782           
+ Misses       426635   426570   -65     
  Partials      10450    10450           
Flag Coverage Δ
uitests 3.58% <ø> (ø)
unittests 18.57% <6.25%> (+<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.

@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

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
@blueorangutan
Copy link

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

Test Result Time (s) Test File
test_02_internallb_roundrobin_1RVPC_3VM_HTTP_port80 Failure 112.02 test_internal_lb.py
test_04_rvpc_internallb_haproxy_stats_on_all_interfaces Failure 203.26 test_internal_lb.py
test_uservm_host_control_state Failure 16.84 test_host_control_state.py
ContextSuite context=TestHostControlState>:teardown Error 28.44 test_host_control_state.py
test_03_deploy_and_scale_kubernetes_cluster Failure 45.38 test_kubernetes_clusters.py
test_08_upgrade_kubernetes_ha_cluster Failure 136.69 test_kubernetes_clusters.py
test_10_vpc_tier_kubernetes_cluster Error 65.08 test_kubernetes_clusters.py
test_12_test_deploy_cluster_different_offerings_per_node_type Failure 111.46 test_kubernetes_clusters.py
test_02_native_to_native_vpc_migration Error 58.33 test_migration.py
test_01_non_strict_host_anti_affinity Failure 91.75 test_nonstrict_affinity_group.py
test_02_non_strict_host_affinity Error 33.98 test_nonstrict_affinity_group.py
test_02_L2_persistent_network Failure 1.89 test_persistent_network.py
test_03_deploy_and_destroy_VM_and_verify_network_resources_persist Failure 21.89 test_persistent_network.py
test_01_vpc_privategw_acl Failure 53.55 test_privategw_acl.py
test_02_vpc_privategw_static_routes Failure 105.87 test_privategw_acl.py
test_03_vpc_privategw_restart_vpc_cleanup Error 401.81 test_privategw_acl.py
test_04_rvpc_privategw_static_routes Failure 142.23 test_privategw_acl.py
test_01_single_VPC_iptables_policies Error 53.72 test_routers_iptables_default_policy.py
test_03_create_vpc_with_specified_source_nat_ip_address Error 49.37 test_set_sourcenat.py
test_01_vpn_usage Error 1.10 test_usage.py
test_04_nonsecured_to_secured_vm_migration Error 366.19 test_vm_life_cycle.py
test_hostha_enable_ha_when_host_disabled Error 1.92 test_hostha_kvm.py
test_hostha_enable_ha_when_host_in_maintenance Error 307.08 test_hostha_kvm.py

@DaanHoogland DaanHoogland force-pushed the cleanupCapacityManager branch from 7a6692d to fc5be41 Compare December 10, 2025 15:38
@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 15980

@blueorangutan
Copy link

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

Test Result Time (s) Test File
test_replace_acl_of_network Error 1.47 test_global_acls.py
test_01_host_tags Failure 6.30 test_host_tags.py
test_updating_nics_on_two_shared_networks Error 1.41 test_gateway_on_shared_networks.py
ContextSuite context=TestGatewayOnSharedNetwork>:teardown Error 3.57 test_gateway_on_shared_networks.py
test_02_unsecure_vm_migration Error 409.14 test_vm_life_cycle.py
test_02_unsecure_vm_migration Error 409.14 test_vm_life_cycle.py
test_03_secured_to_nonsecured_vm_migration Error 0.01 test_vm_life_cycle.py
test_04_nonsecured_to_secured_vm_migration Error 0.01 test_vm_life_cycle.py

@blueorangutan
Copy link

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

Test Result Time (s) Test File
test_DeployVmAntiAffinityGroup_in_project Error 64.31 test_affinity_groups_projects.py
test_DeployVmAntiAffinityGroup Error 8.79 test_affinity_groups.py
test_updating_nics_on_two_shared_networks Error 1.67 test_gateway_on_shared_networks.py
ContextSuite context=TestGatewayOnSharedNetwork>:teardown Error 3.89 test_gateway_on_shared_networks.py
ContextSuite context=TestImportAndUnmanageVolumes>:setup Error 0.00 test_import_unmanage_volumes.py
test_03_deploy_and_scale_kubernetes_cluster Failure 34.08 test_kubernetes_clusters.py
test_08_upgrade_kubernetes_ha_cluster Failure 0.10 test_kubernetes_clusters.py
test_12_test_deploy_cluster_different_offerings_per_node_type Failure 67.80 test_kubernetes_clusters.py
test_01_non_strict_host_anti_affinity Failure 67.84 test_nonstrict_affinity_group.py
test_02_non_strict_host_affinity Error 23.56 test_nonstrict_affinity_group.py
ContextSuite context=TestMigrateVMStrictTags>:setup Error 0.00 test_vm_strict_host_tags.py
test_hostha_enable_ha_when_host_in_maintenance Error 302.92 test_hostha_kvm.py

@blueorangutan
Copy link

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

Test Result Time (s) Test File
test_DeployVmAntiAffinityGroup_in_project Error 73.53 test_affinity_groups_projects.py
test_DeployVmAntiAffinityGroup Error 13.90 test_affinity_groups.py
test_replace_acl_of_network Error 57.00 test_global_acls.py
ContextSuite context=TestClusterDRS>:setup Error 0.00 test_cluster_drs.py
test_03_create_vpc_domain_vpc_offering Error 161.66 test_domain_vpc_offerings.py
test_updating_nics_on_two_shared_networks Error 1.71 test_gateway_on_shared_networks.py
ContextSuite context=TestGatewayOnSharedNetwork>:teardown Error 3.92 test_gateway_on_shared_networks.py
test_01_secure_vm_migration Error 133.15 test_vm_life_cycle.py
test_01_secure_vm_migration Error 133.16 test_vm_life_cycle.py
test_hostha_enable_ha_when_host_disabled Error 5.84 test_hostha_kvm.py
test_hostha_enable_ha_when_host_in_maintenance Error 306.07 test_hostha_kvm.py

@DaanHoogland DaanHoogland force-pushed the cleanupCapacityManager branch from fc5be41 to bd7bc6a Compare December 16, 2025 11:52
@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 16054

@blueorangutan
Copy link

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

Test Result Time (s) Test File
test_03_deploy_and_scale_kubernetes_cluster Failure 25.70 test_kubernetes_clusters.py

@DaanHoogland DaanHoogland force-pushed the cleanupCapacityManager branch from bd7bc6a to a238e94 Compare December 23, 2025 20:03
@DaanHoogland
Copy link
Contributor Author

@sureshanaparti @JoaoJandre @harikrishna-patnala can you review?

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

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

See analysis details on SonarQube Cloud

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