Skip to content

Fix listPublicIpAddresses NPE on shared networks with a VR - #14249

Merged
sureshanaparti merged 2 commits into
apache:4.22from
MitchDrage:listpublicip-placeholder-npe
Oct 26, 2026
Merged

sureshanaparti merged 2 commits into
apache:4.22from
MitchDrage:listpublicip-placeholder-npe

Conversation

@MitchDrage

@MitchDrage MitchDrage commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

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)
  • 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
  • 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.

@JoaoJandre JoaoJandre left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

CLGTM, did not test it

@codecov

codecov Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 64.28571% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 18.00%. Comparing base (f23766d) to head (d4fcd0f).
⚠️ Report is 47 commits behind head on 4.22.

Files with missing lines Patch % Lines
server/src/main/java/com/cloud/api/ApiDBUtils.java 0.00% 3 Missing ⚠️
...src/main/java/com/cloud/api/ApiResponseHelper.java 81.81% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##               4.22   #14249   +/-   ##
=========================================
  Coverage     17.99%   18.00%           
- Complexity    16215    16219    +4     
=========================================
  Files          5935     5936    +1     
  Lines        535706   535724   +18     
  Branches      65596    65598    +2     
=========================================
+ Hits          96425    96446   +21     
+ Misses       428292   428286    -6     
- Partials      10989    10992    +3     
Flag Coverage Δ
uitests 4.02% <ø> (ø)
unittests 19.07% <64.28%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 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.

Comment thread server/src/main/java/com/cloud/api/ApiResponseHelper.java Outdated
@MitchDrage
MitchDrage requested a review from Damans227 October 4, 2026 05:14

@Damans227 Damans227 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

thanks @MitchDrage, the placeholder only case is covered now. LGTM.

@MitchDrage

Copy link
Copy Markdown
Contributor Author

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

@sureshanaparti

Copy link
Copy Markdown
Contributor

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

@sureshanaparti sureshanaparti left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

clgtm

@blueorangutan

Copy link
Copy Markdown

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

@blueorangutan

Copy link
Copy Markdown

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

@vladimirpetrov vladimirpetrov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM based on the following tests:

  • VR running: repeated list calls never fail
  • VR destroyed, only the placeholder left
  • Other triggers: stop, reboot, restart with cleanup
  • updateIpAddress on the VR IP (another caller of the same response code)

@vladimirpetrov

Copy link
Copy Markdown
Contributor

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

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

@blueorangutan

blueorangutan commented Oct 24, 2026 •

Copy link
Copy Markdown

[SF] Trillian test result (tid-17232)
Environment: kvm-ol8 (x2), zone: Advanced Networking with Mgmt server ol8
Total time taken: 53907 seconds
Marvin logs: [archive removed]
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

@sureshanaparti
sureshanaparti merged commit b92ab08 into apache:4.22 Oct 26, 2026
26 checks passed
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.

listPublicIpAddresses NullPointerException on shared networks with a VR (4.22)

8 participants