Skip to content

Autoscale VM load balancing rules code improvements#12446

Open
sureshanaparti wants to merge 3 commits into
apache:4.20from
shapeblue:autoscale-vm-load-balancing-rules-improvements
Open

Autoscale VM load balancing rules code improvements#12446
sureshanaparti wants to merge 3 commits into
apache:4.20from
shapeblue:autoscale-vm-load-balancing-rules-improvements

Conversation

@sureshanaparti
Copy link
Copy Markdown
Contributor

Description

This PR improves the code for Autoscale VM load balancing rules.

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
Copy Markdown

codecov Bot commented Jan 16, 2026

Codecov Report

❌ Patch coverage is 8.79121% with 83 lines in your changes missing coverage. Please review.
✅ Project coverage is 16.26%. Comparing base (5c1f931) to head (a756b10).
⚠️ Report is 124 commits behind head on 4.20.

Files with missing lines Patch % Lines
...loud/network/lb/LoadBalancingRulesManagerImpl.java 5.68% 81 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               4.20   #12446      +/-   ##
============================================
+ Coverage     16.23%   16.26%   +0.03%     
- Complexity    13380    13431      +51     
============================================
  Files          5657     5665       +8     
  Lines        498996   500537    +1541     
  Branches      60566    60785     +219     
============================================
+ Hits          81011    81412     +401     
- Misses       408951   410019    +1068     
- Partials       9034     9106      +72     
Flag Coverage Δ
uitests 4.15% <ø> (+0.12%) ⬆️
unittests 17.11% <8.79%> (+0.02%) ⬆️

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.

@sureshanaparti
Copy link
Copy Markdown
Contributor Author

@blueorangutan package

@blueorangutan
Copy link
Copy Markdown

@sureshanaparti 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
Copy Markdown
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 performs code cleanup and improvements for the Autoscale VM load balancing rules implementation. The changes focus on improving code readability and maintainability through better naming conventions, use of modern Java syntax, and code simplification.

Changes:

  • Renamed DAO field variables to follow proper camelCase naming conventions (_lb2stickinesspoliciesDao_lb2StickinessPoliciesDao, _lb2healthcheckDao_lb2HealthCheckDao)
  • Modernized code by using diamond operators for generic type inference and simplifying conditional logic
  • Fixed spelling errors in code comments ("comparisions" → "comparison", "assoication" → "association")
  • Improved variable naming for better readability (e.g., priIpprimaryIp, lstVmIdvmIds, mapslb2VmMaps)

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
server/src/main/java/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java Renamed DAO fields to proper camelCase, applied diamond operators, improved variable naming, fixed spelling in comments, simplified conditional logic
server/src/test/java/com/cloud/network/lb/UpdateLoadBalancerTest.java Updated test mock setup to reflect renamed DAO fields
server/src/main/java/com/cloud/network/as/AutoScaleManagerImpl.java Improved variable naming from lstVmId to vmIds and applied diamond operator
engine/schema/src/main/java/com/cloud/network/dao/LoadBalancerVMMapDao.java Added blank line for better code formatting
engine/schema/src/main/java/com/cloud/network/dao/LoadBalancerVMMapDaoImpl.java Removed extra blank line for cleaner code formatting

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

_lb2VmMapDao.remove(lb.getId(), lbVmMapToRevoke.getInstanceId(), lbVmMapToRevoke.getInstanceIp(), null);
logger.debug("Load balancer rule {} is removed for Instance {} and IP {}",
lb, lbVmMap.getInstanceId(), lbVmMap.getInstanceIp());;
lb, lbVmMapToRevoke.getInstanceId(), lbVmMapToRevoke.getInstanceIp());;
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

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

Double semicolon at the end of the statement. Remove one semicolon.

Suggested change
lb, lbVmMapToRevoke.getInstanceId(), lbVmMapToRevoke.getInstanceIp());;
lb, lbVmMapToRevoke.getInstanceId(), lbVmMapToRevoke.getInstanceIp());

Copilot uses AI. Check for mistakes.
}
}
lstVmId.add(new Long(vmId));
vmIds.add(new Long(vmId));
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

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

The explicit Long constructor call is unnecessary and deprecated. Use Long.valueOf(vmId) or simply add vmId directly since autoboxing will handle the conversion.

Suggested change
vmIds.add(new Long(vmId));
vmIds.add(vmId);

Copilot uses AI. Check for mistakes.
continue;
}
if(_nicSecondaryIpDao.findByIp4AddressAndNicId(ip,nicInSameNetwork.getId()) == null) {
if (_nicSecondaryIpDao.findByIp4AddressAndNicId(ip,nicInSameNetwork.getId()) == null) {
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

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

Missing space after comma in method call arguments. Add space after the comma for better readability.

Suggested change
if (_nicSecondaryIpDao.findByIp4AddressAndNicId(ip,nicInSameNetwork.getId()) == null) {
if (_nicSecondaryIpDao.findByIp4AddressAndNicId(ip, nicInSameNetwork.getId()) == null) {

Copilot uses AI. Check for mistakes.
map.setRevoke(true);
_lb2VmMapDao.persist(map);
logger.debug("Set load balancer rule for revoke: rule {}, vmId {}, vmip {}", loadBalancer::toString, () -> _vmDao.findById(instanceId), vmIp::toString);
logger.debug("Set load balancer rule for revoke: rule {}, vmId {}, vmIp {}", loadBalancer::toString, () -> _vmDao.findById(instanceId), vmIp::toString);
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

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

Redundant call to 'toString' on a String object.

Suggested change
logger.debug("Set load balancer rule for revoke: rule {}, vmId {}, vmIp {}", loadBalancer::toString, () -> _vmDao.findById(instanceId), vmIp::toString);
logger.debug("Set load balancer rule for revoke: rule {}, vmId {}, vmIp {}", loadBalancer::toString, () -> _vmDao.findById(instanceId), vmIp);

Copilot uses AI. Check for mistakes.
@blueorangutan
Copy link
Copy Markdown

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

@sureshanaparti sureshanaparti marked this pull request as draft January 16, 2026 08:32
Copy link
Copy Markdown
Contributor

@DaanHoogland DaanHoogland left a comment

Choose a reason for hiding this comment

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

co-pilots nitpicking seems to the point but clgtm!

@weizhouapache weizhouapache added this to the 4.20.4 milestone May 7, 2026
Copy link
Copy Markdown
Member

@harikrishna-patnala harikrishna-patnala left a comment

Choose a reason for hiding this comment

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

code LGTM

@sureshanaparti sureshanaparti marked this pull request as ready for review May 18, 2026 07:07
@harikrishna-patnala
Copy link
Copy Markdown
Member

@blueorangutan package

@blueorangutan
Copy link
Copy Markdown

@harikrishna-patnala 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
Copy Markdown

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

Comment thread server/src/main/java/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java Outdated
Comment thread server/src/main/java/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java Outdated
@harikrishna-patnala
Copy link
Copy Markdown
Member

I've addressed your review comments @weizhouapache can you please review again.

Copy link
Copy Markdown
Member

@weizhouapache weizhouapache left a comment

Choose a reason for hiding this comment

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

code lgtm

thanks @harikrishna-patnala for the update

@sureshanaparti
Copy link
Copy Markdown
Contributor Author

@blueorangutan package

@blueorangutan
Copy link
Copy Markdown

@sureshanaparti 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
Copy Markdown

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

@harikrishna-patnala
Copy link
Copy Markdown
Member

@blueorangutan test

@blueorangutan
Copy link
Copy Markdown

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

@blueorangutan
Copy link
Copy Markdown

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

Test Result Time (s) Test File
ContextSuite context=TestSharedFSLifecycle>:setup Error 0.00 test_sharedfs_lifecycle.py
test_10_attachAndDetach_iso Failure 606.95 test_vm_life_cycle.py
test_01_create_vm_snapshots Failure 603.79 test_vm_snapshots.py
test_02_revert_vm_snapshots Failure 600.51 test_vm_snapshots.py
test_03_delete_vm_snapshots Failure 0.02 test_vm_snapshots.py
test_01_create_volume Failure 610.28 test_volumes.py
test_01_root_volume_encryption Failure 717.90 test_volumes.py
test_02_data_volume_encryption Failure 673.53 test_volumes.py
test_03_root_and_data_volume_encryption Failure 688.22 test_volumes.py
test_02_attach_volume Failure 1287.99 test_volumes.py
test_02_attach_volume Failure 1288.02 test_volumes.py
test_03_download_attached_volume Failure 670.47 test_volumes.py
test_04_delete_attached_volume Failure 665.23 test_volumes.py
test_05_detach_volume Failure 844.63 test_volumes.py
test_06_download_detached_volume Failure 881.52 test_volumes.py
test_07_resize_fail Failure 668.91 test_volumes.py
test_08_resize_volume Failure 679.96 test_volumes.py
test_09_delete_detached_volume Failure 666.94 test_volumes.py
test_10_list_volumes Failure 663.15 test_volumes.py
test_11_attach_volume_with_unstarted_vm Failure 762.90 test_volumes.py
test_12_resize_volume_with_only_size_parameter Failure 672.52 test_volumes.py
test_13_migrate_volume_and_change_offering Failure 797.59 test_volumes.py
test_14_delete_volume_delete_protection Failure 664.42 test_volumes.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.

6 participants