server: null-check requested IP in assignSourceNatPublicIpAddress - #14025
Open
nagaboinaramgopal wants to merge 1 commit into
Open
server: null-check requested IP in assignSourceNatPublicIpAddress#14025nagaboinaramgopal wants to merge 1 commit into
nagaboinaramgopal wants to merge 1 commit into
Conversation
assignSourceNatPublicIpAddress looked up the requested IP with _ipAddressDao.findByIpAndDcId() and immediately checked ipAddressVO.getState(). findByIpAndDcId returns null when the requested IP is not a known public IP in the zone, so an invalid or unknown requestedIp produced a NullPointerException instead of a meaningful capacity error. Treat a null lookup result like a non-free address and throw InsufficientAddressCapacityException. Adds a regression test with an unknown requested IP (NullPointerException before the fix).
nagaboinaramgopal
force-pushed
the
fix/sourcenat-ip-npe
branch
from
September 3, 2026 17:18
28f0c62 to
87d961b
Compare
Contributor
|
@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. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 4.20 #14025 +/- ##
============================================
+ Coverage 16.34% 19.78% +3.44%
- Complexity 13574 19997 +6423
============================================
Files 5669 6371 +702
Lines 501368 575899 +74531
Branches 60903 70495 +9592
============================================
+ Hits 81964 113962 +31998
- Misses 410219 449508 +39289
- Partials 9185 12429 +3244
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:
|
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 19092 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
assignSourceNatPublicIpAddresslooks up the requested IP withfindByIpAndDcIdand then reads its state:findByIpAndDcIdreturns null when the requested IP is not a known public IP inthe zone, so this throws a NullPointerException instead of a meaningful error.
Fixed by null-checking the result first, so the method throws the intended
InsufficientAddressCapacityExceptionwhen the IP cannot be found.Types of changes
Feature/Enhancement Scale or Bug Severity
Bug Severity
How Has This Been Tested?
Added a unit test that requests a source NAT IP not present in the zone and
asserts an InsufficientAddressCapacityException is thrown instead of an NPE.
Also built the standard packages and deployed on a KVM advanced zone.