You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by "MitchDrage (via GitHub)" <gi...@apache.org> on 2026/09/25 13:00:20 UTC

[PR] Fix listPublicIpAddresses NPE on shared networks with a VR [cloudstack]

MitchDrage opened a new pull request, #14249:
URL: https://github.com/apache/cloudstack/pull/14249

   ### Description
   
   Fixes an intermittent NullPointerException in listPublicIpAddresses when a shared network has a VR.
   
   For shared network IPs, `showVmInfoForSharedNetworks()` looks up the NIC by IP and network. For the VR's IP there are two NICs, the real one and the VR's placeholder NIC (null instance_id), and the lookup returns one of them at random. When it gets the placeholder, the router branch added in #10458 calls `getInstanceId()` and throws.
   
   This switches it to the existing `findNonPlaceHolderByIp4AddressAndNetworkId()`. I've also set `issystem` to true in the router branch again. 4.20 set it for router IPs, #10458 changed it so that `issystem` ended up as false so I've switched it back to true. With it set to false, the UI offers Release IP on the VR's address which it shouldn't do.
   
   4.20 isn't affected.
   
   Fixes: #14248
   
   ### Types of changes
   
   - [ ] Breaking change (fix or feature that would cause existing functionality to change)
   - [ ] New feature (non-breaking change which adds functionality)
   - [x] 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
   
   #### Bug Severity
   
   - [ ] BLOCKER
   - [ ] Critical
   - [ ] Major
   - [x] Minor
   - [ ] Trivial
   
   ### Screenshots (if appropriate):
   
   ### How Has This Been Tested?
   
   Added a unit test to ApiResponseHelperTest.
   
   In the simulator, with a shared network on `DefaultSharedNetworkOffering` and one VM, about half of the `listPublicIpAddresses forvirtualnetwork=false` calls failed before the change. After it, none did, and the VR's IP shows the router with issystem=true.
   
   We were hitting this on 4.22.1.0 in production too.
   
   
   #### How did you try to break this feature and the system with this change?
   
   Tried releasing the VR's IP afterwards. It's still refused, as it should be.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix listPublicIpAddresses NPE on shared networks with a VR [cloudstack]

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #14249:
URL: https://github.com/apache/cloudstack/pull/14249#issuecomment-6361656609

   Packaging result [SF]: ✖️ el8 ✖️ el9  ✖️ debian ✖️ suse15. SL-JID 19700


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix listPublicIpAddresses NPE on shared networks with a VR [cloudstack]

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #14249:
URL: https://github.com/apache/cloudstack/pull/14249#issuecomment-5957190065

   ## [Codecov](https://app.codecov.io/gh/apache/cloudstack/pull/14249?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :white_check_mark: All modified and coverable lines are covered by tests.
   :white_check_mark: Project coverage is 4.02%. Comparing base ([`f23766d`](https://app.codecov.io/gh/apache/cloudstack/commit/f23766d7c33b32a30caeb2d2b04039d0c6b24f13?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`f91a730`](https://app.codecov.io/gh/apache/cloudstack/commit/f91a7308e2febb75af8c688b64e059e5d250a262?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   :warning: Report is 6 commits behind head on 4.22.
   > :exclamation:  There is a different number of reports uploaded between BASE (f23766d) and HEAD (f91a730). Click for more details.
   > 
   > <details><summary>HEAD has 1 upload less than BASE</summary>
   >
   >| Flag | BASE (f23766d) | HEAD (f91a730) |
   >|------|------|------|
   >|unittests|1|0|
   ></details>
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@              Coverage Diff              @@
   ##               4.22   #14249       +/-   ##
   =============================================
   - Coverage     17.99%    4.02%   -13.98%     
   =============================================
     Files          5935      449     -5486     
     Lines        535706    38239   -497467     
     Branches      65596     7082    -58514     
   =============================================
   - Hits          96425     1538    -94887     
   + Misses       428292    36489   -391803     
   + Partials      10989      212    -10777     
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/cloudstack/pull/14249/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [uitests](https://app.codecov.io/gh/apache/cloudstack/pull/14249/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `4.02% <ø> (ø)` | |
   | [unittests](https://app.codecov.io/gh/apache/cloudstack/pull/14249/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
   </details>
   
   [:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/cloudstack/pull/14249?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix listPublicIpAddresses NPE on shared networks with a VR [cloudstack]

Posted by "Damans227 (via GitHub)" <gi...@apache.org>.
Damans227 commented on code in PR #14249:
URL: https://github.com/apache/cloudstack/pull/14249#discussion_r4175885514


##########
server/src/main/java/com/cloud/api/ApiResponseHelper.java:
##########
@@ -1235,9 +1235,9 @@ private void setVpcIdInResponse(Long vpcId, Consumer<String> vpcUuidSetter, Cons
         }
     }
 
-    private void showVmInfoForSharedNetworks(boolean forVirtualNetworks, IpAddress ipAddr, IPAddressResponse ipResponse) {
+    protected void showVmInfoForSharedNetworks(boolean forVirtualNetworks, IpAddress ipAddr, IPAddressResponse ipResponse) {
         if (!forVirtualNetworks) {
-            NicVO nic = ApiDBUtils.findByIp4AddressAndNetworkId(ipAddr.getAddress().toString(), ipAddr.getNetworkId());
+            NicVO nic = ApiDBUtils.findNonPlaceHolderByIp4AddressAndNetworkId(ipAddr.getAddress().toString(), ipAddr.getNetworkId());

Review Comment:
   what happens once the router is destroyed and only the placeholder is left? looks like the ip would stop showing as a system ip and the ui would offer release on it again



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix listPublicIpAddresses NPE on shared networks with a VR [cloudstack]

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #14249:
URL: https://github.com/apache/cloudstack/pull/14249#issuecomment-6380971910

   <b>[SF] Trillian test result (tid-17232)</b>
   Environment: kvm-ol8 (x2), zone: Advanced Networking with Mgmt server ol8
   Total time taken: 53907 seconds
   Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr14249-t17232-kvm-ol8.zip
   Smoke tests completed. 149 look OK, 0 have errors, 0 did not run
   Only failed and skipped tests results shown below:
   
   
   Test | Result | Time (s) | Test File
   --- | --- | --- | ---
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix listPublicIpAddresses NPE on shared networks with a VR [cloudstack]

Posted by "MitchDrage (via GitHub)" <gi...@apache.org>.
MitchDrage commented on code in PR #14249:
URL: https://github.com/apache/cloudstack/pull/14249#discussion_r4176235916


##########
server/src/main/java/com/cloud/api/ApiResponseHelper.java:
##########
@@ -1235,9 +1235,9 @@ private void setVpcIdInResponse(Long vpcId, Consumer<String> vpcUuidSetter, Cons
         }
     }
 
-    private void showVmInfoForSharedNetworks(boolean forVirtualNetworks, IpAddress ipAddr, IPAddressResponse ipResponse) {
+    protected void showVmInfoForSharedNetworks(boolean forVirtualNetworks, IpAddress ipAddr, IPAddressResponse ipResponse) {
         if (!forVirtualNetworks) {
-            NicVO nic = ApiDBUtils.findByIp4AddressAndNetworkId(ipAddr.getAddress().toString(), ipAddr.getNetworkId());
+            NicVO nic = ApiDBUtils.findNonPlaceHolderByIp4AddressAndNetworkId(ipAddr.getAddress().toString(), ipAddr.getNetworkId());

Review Comment:
   Good pickup. Yes, that was a miss on my part.
   I've reverted the lines that you highlighted and handled that case in the router branch, with a test for when only the placeholder is left.
   Also added some comments for posterity, as the DB lookup can return either the router's NIC or its placeholder.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix listPublicIpAddresses NPE on shared networks with a VR [cloudstack]

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #14249:
URL: https://github.com/apache/cloudstack/pull/14249#issuecomment-6363860812

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


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix listPublicIpAddresses NPE on shared networks with a VR [cloudstack]

Posted by "sureshanaparti (via GitHub)" <gi...@apache.org>.
sureshanaparti commented on PR #14249:
URL: https://github.com/apache/cloudstack/pull/14249#issuecomment-6361098620

   @blueorangutan package


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix listPublicIpAddresses NPE on shared networks with a VR [cloudstack]

Posted by "MitchDrage (via GitHub)" <gi...@apache.org>.
MitchDrage commented on PR #14249:
URL: https://github.com/apache/cloudstack/pull/14249#issuecomment-6048615282

   @vladimirpetrov @sureshanaparti could this go into the 4.22.2 milestone? It's a bug fix against 4.22.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix listPublicIpAddresses NPE on shared networks with a VR [cloudstack]

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #14249:
URL: https://github.com/apache/cloudstack/pull/14249#issuecomment-6361118889

   @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.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix listPublicIpAddresses NPE on shared networks with a VR [cloudstack]

Posted by "Damans227 (via GitHub)" <gi...@apache.org>.
Damans227 commented on code in PR #14249:
URL: https://github.com/apache/cloudstack/pull/14249#discussion_r4197999395


##########
server/src/main/java/com/cloud/api/ApiResponseHelper.java:
##########
@@ -1235,9 +1235,9 @@ private void setVpcIdInResponse(Long vpcId, Consumer<String> vpcUuidSetter, Cons
         }
     }
 
-    private void showVmInfoForSharedNetworks(boolean forVirtualNetworks, IpAddress ipAddr, IPAddressResponse ipResponse) {
+    protected void showVmInfoForSharedNetworks(boolean forVirtualNetworks, IpAddress ipAddr, IPAddressResponse ipResponse) {
         if (!forVirtualNetworks) {
-            NicVO nic = ApiDBUtils.findByIp4AddressAndNetworkId(ipAddr.getAddress().toString(), ipAddr.getNetworkId());
+            NicVO nic = ApiDBUtils.findNonPlaceHolderByIp4AddressAndNetworkId(ipAddr.getAddress().toString(), ipAddr.getNetworkId());

Review Comment:
   that covers it, marking it as a system ip before the placeholder check keeps release hidden after the router is gone



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix listPublicIpAddresses NPE on shared networks with a VR [cloudstack]

Posted by "sureshanaparti (via GitHub)" <gi...@apache.org>.
sureshanaparti merged PR #14249:
URL: https://github.com/apache/cloudstack/pull/14249


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix listPublicIpAddresses NPE on shared networks with a VR [cloudstack]

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #14249:
URL: https://github.com/apache/cloudstack/pull/14249#issuecomment-6367272749

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


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix listPublicIpAddresses NPE on shared networks with a VR [cloudstack]

Posted by "vladimirpetrov (via GitHub)" <gi...@apache.org>.
vladimirpetrov commented on PR #14249:
URL: https://github.com/apache/cloudstack/pull/14249#issuecomment-6367259678

   @blueorangutan test


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org