check if a source NAT IP address is needed before assigning one - #12408
check if a source NAT IP address is needed before assigning one#12408DaanHoogland wants to merge 1 commit into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 4.20 #12408 +/- ##
============================================
- Coverage 16.26% 16.26% -0.01%
Complexity 13434 13434
============================================
Files 5667 5667
Lines 500731 500737 +6
Branches 60803 60808 +5
============================================
- Hits 81455 81447 -8
- Misses 410172 410182 +10
- Partials 9104 9108 +4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@blueorangutan package |
|
@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. |
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 16344 |
There was a problem hiding this comment.
Pull request overview
This PR addresses issue #10122 regarding incorrect IP address labeling as "Source NAT" in Routed VPC networks. The main change introduces logic to check if a network is routed before assigning a source NAT IP address, which prevents unnecessary source NAT IP allocation for routed networks where Source NAT service is not applicable.
Changes:
- Adds new
isRouted()method to determine if a network uses routing mode - Updates
assignSourceNatIpAddressToGuestNetwork()to conditionally assign source NAT based on routing mode - Updates
isSourceNatAvailableForNetwork()to treat networks with routing mode as having shared source NAT - Includes extensive code cleanup: removes unused imports and fields, applies diamond operators, and simplifies conditional logic
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@DaanHoogland |
it is not a pure UI issue. The IP address is marked as source NAT in the DB. I am not sure if this addresses all scenarios yet, but it will prevent marking the primary IP for a ROUTED-mode network as source NAT. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 10 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
e8cebc6 to
7274c9e
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| private boolean isRouted(Network guestNetwork) { | ||
| VpcOffering vpcOffer = null; | ||
| NetworkOffering netOffer = _networkOfferingDao.findById(guestNetwork.getNetworkOfferingId()); | ||
| if (netOffer == null) { | ||
| throw new CloudRuntimeException("network without offering found???"); | ||
| } | ||
| if (netOffer.isForVpc() && guestNetwork.getVpcId() != null) { | ||
| VpcVO vpc = _vpcDao.findById(guestNetwork.getVpcId()); | ||
| if (vpc != null) { | ||
| vpcOffer = vpcOfferingDao.findById(vpc.getVpcOfferingId()); | ||
| } | ||
| } | ||
| return netOffer.getRoutingMode() != null || (vpcOffer != null && vpcOffer.getRoutingMode() != null); | ||
| } |
There was a problem hiding this comment.
The new isRouted method lacks test coverage. Since the repository has comprehensive test coverage for IpAddressManagerImpl (see IpAddressManagerTest.java), consider adding unit tests to verify:
- The method correctly identifies routed networks based on NetworkOffering routing mode
- The method correctly identifies routed VPC networks based on VPC offering routing mode
- Edge cases like null VPC or null VPC offering are handled properly
7274c9e to
519b8cf
Compare
ok @DaanHoogland as I understand, what @msinhore wanted is the change of label of public IP. |
isSourceNat is a flag returned to the UI, if we do not change it in the service we have to honour that flag conditionally. Not a very clean solution either and technical debt at the same time. I would suggest we fix it good or not. |
ok. a simple workaround on UI
|
519b8cf to
c38f3cc
Compare
|
@DaanHoogland However, it is not used for Source NAT. Instead, it is used to establish routing between the virtual router and the upstream router. In my opinion, we only need to change the label of Public IP addresses for Routed network or VPC on UI. |

Description
This PR...
Fixes: #10122
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?