-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Autoscale VM load balancing rules code improvements #12446
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 4.20
Are you sure you want to change the base?
Autoscale VM load balancing rules code improvements #12446
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 4.20 #12446 +/- ##
=========================================
Coverage 16.23% 16.23%
Complexity 13380 13380
=========================================
Files 5657 5657
Lines 498996 499007 +11
Branches 60566 60560 -6
=========================================
+ Hits 81011 81025 +14
+ Misses 408951 408946 -5
- Partials 9034 9036 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@blueorangutan package |
|
@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. |
There was a problem hiding this 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.,
priIp→primaryIp,lstVmId→vmIds,maps→lb2VmMaps)
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());; |
Copilot
AI
Jan 16, 2026
There was a problem hiding this comment.
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.
| lb, lbVmMapToRevoke.getInstanceId(), lbVmMapToRevoke.getInstanceIp());; | |
| lb, lbVmMapToRevoke.getInstanceId(), lbVmMapToRevoke.getInstanceIp()); |
| } | ||
| } | ||
| lstVmId.add(new Long(vmId)); | ||
| vmIds.add(new Long(vmId)); |
Copilot
AI
Jan 16, 2026
There was a problem hiding this comment.
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.
| vmIds.add(new Long(vmId)); | |
| vmIds.add(vmId); |
| continue; | ||
| } | ||
| if(_nicSecondaryIpDao.findByIp4AddressAndNicId(ip,nicInSameNetwork.getId()) == null) { | ||
| if (_nicSecondaryIpDao.findByIp4AddressAndNicId(ip,nicInSameNetwork.getId()) == null) { |
Copilot
AI
Jan 16, 2026
There was a problem hiding this comment.
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.
| if (_nicSecondaryIpDao.findByIp4AddressAndNicId(ip,nicInSameNetwork.getId()) == null) { | |
| if (_nicSecondaryIpDao.findByIp4AddressAndNicId(ip, nicInSameNetwork.getId()) == null) { |
| 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); |
Copilot
AI
Jan 16, 2026
There was a problem hiding this comment.
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.
| 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); |
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 16392 |
Description
This PR improves the code for Autoscale VM load balancing rules.
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
How Has This Been Tested?
How did you try to break this feature and the system with this change?