Skip to content

Conversation

@sureshanaparti
Copy link
Contributor

Description

This PR fixes NPE during VM IP fetch for shared networks.

Noticed several exceptions in smoke tests logs, for NPE during VmIpFetchTask.

2025-08-02 23:14:58,430 ERROR [c.c.v.U.VmIpFetchTask] (UserVm-ipfetch-3:[ctx-19c7c71d]) (logid:4400b66b) Caught the Exception in VmIpFetchTask java.lang.NullPointerException: Cannot invoke "com.cloud.vm.NicVO.getNetworkId()" because "nicVo" is null
        at com.cloud.vm.UserVmManagerImpl$VmIpFetchTask.runInContext(UserVmManagerImpl.java:2721)
        at org.apache.cloudstack.managed.context.ManagedContextRunnable$1.run(ManagedContextRunnable.java:49)
        at org.apache.cloudstack.managed.context.impl.DefaultManagedContext$1.call(DefaultManagedContext.java:56)
        at org.apache.cloudstack.managed.context.impl.DefaultManagedContext.callWithContext(DefaultManagedContext.java:103)
        at org.apache.cloudstack.managed.context.impl.DefaultManagedContext.runWithContext(DefaultManagedContext.java:53)
        at org.apache.cloudstack.managed.context.ManagedContextRunnable.run(ManagedContextRunnable.java:46)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
        at java.base/java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305)
        at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
        at java.base/java.lang.Thread.run(Thread.java:840) 

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

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

How did you try to break this feature and the system with this change?

@codecov
Copy link

codecov bot commented Aug 4, 2025

Codecov Report

❌ Patch coverage is 0% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 16.17%. Comparing base (38006b2) to head (6b11fa1).
⚠️ Report is 5 commits behind head on 4.20.

Files with missing lines Patch % Lines
.../src/main/java/com/cloud/vm/UserVmManagerImpl.java 0.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##               4.20   #11389   +/-   ##
=========================================
  Coverage     16.17%   16.17%           
- Complexity    13297    13299    +2     
=========================================
  Files          5656     5656           
  Lines        498136   498139    +3     
  Branches      60432    60433    +1     
=========================================
+ Hits          80583    80585    +2     
  Misses       408585   408585           
- Partials       8968     8969    +1     
Flag Coverage Δ
uitests 4.00% <ø> (ø)
unittests 17.03% <0.00%> (+<0.01%) ⬆️

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

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

@sureshanaparti
Copy link
Contributor Author

@blueorangutan package

@sureshanaparti sureshanaparti requested a review from Copilot August 4, 2025 11:15
@blueorangutan
Copy link

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

Copy link
Contributor

Copilot AI left a 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 fixes a NullPointerException that occurs during VM IP fetching for shared networks. The exception was happening when the VmIpFetchTask tried to access the network ID from a null NIC object.

  • Adds null check validation for VM, VM instance, and NIC objects before proceeding with IP fetch operations
  • Fixes a typo in a configuration description ("entwork" → "network")
  • Updates logging to use parameterized format instead of string concatenation
Comments suppressed due to low confidence (1)

server/src/main/java/com/cloud/vm/UserVmManagerImpl.java:721

  • This null check is good and addresses the NPE issue, but it should be placed before line 2720 where nicVo.getNetworkId() was originally called to fully prevent the exception described in the PR.
    }

@blueorangutan
Copy link

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

@sureshanaparti
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

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

@blueorangutan
Copy link

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

@sureshanaparti sureshanaparti marked this pull request as ready for review September 11, 2025 11:26
@sureshanaparti sureshanaparti force-pushed the NPE-during-VmIpFetchTask branch from 79e9bac to 5df24f5 Compare September 11, 2025 11:26
@sureshanaparti
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

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

@github-actions
Copy link

This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch.

@sureshanaparti sureshanaparti changed the base branch from main to 4.20 September 11, 2025 12:09
@sureshanaparti
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

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

@blueorangutan
Copy link

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

@blueorangutan
Copy link

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

@weizhouapache weizhouapache added this to the 4.20.2 milestone Sep 12, 2025
@weizhouapache
Copy link
Member

@blueorangutan package

Copy link
Member

@weizhouapache weizhouapache left a comment

Choose a reason for hiding this comment

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

code lgtm

@blueorangutan
Copy link

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

@blueorangutan
Copy link

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

@weizhouapache
Copy link
Member

@blueorangutan test

@blueorangutan
Copy link

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

@weizhouapache weizhouapache self-assigned this Sep 12, 2025
@weizhouapache
Copy link
Member

verified OK

tested with the steps below

  • deploy a vm, stop it
  • create a shared network without services (offering is "Offering for QuickCloud with no services")
  • start the vm
  • add the vm to the new network
  • after 5 minutes, remove the vm from the network

without this PR

2025-09-12 10:45:41,936 ERROR [c.c.v.U.VmIpFetchTask] (UserVm-ipfetch-3:[ctx-78f60c21]) (logid:efb0935b) Caught the Exception in VmIpFetchTask java.lang.NullPointerException: Cannot invoke "com.cloud.vm.NicVO.getNetworkId()" because "nicVo" is null

with this PR

2025-09-12 12:24:30,120 WARN  [c.c.v.U.VmIpFetchTask] (UserVm-ipfetch-2:[ctx-c41dea2f]) (logid:2abe4fd9) Couldn't fetch ip addr, Vm 8 or nic 55 doesn't exists

@blueorangutan
Copy link

[SF] Trillian test result (tid-14308)
Environment: kvm-ol8 (x2), zone: Advanced Networking with Mgmt server ol8
Total time taken: 52431 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr11389-t14308-kvm-ol8.zip
Smoke tests completed. 141 look OK, 0 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File

Copy link
Member

@vishesh92 vishesh92 left a comment

Choose a reason for hiding this comment

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

clgtm

@weizhouapache
Copy link
Member

thanks @sureshanaparti @vishesh92

merging

@weizhouapache weizhouapache merged commit cd69f2c into apache:4.20 Sep 15, 2025
41 of 43 checks passed
@DaanHoogland DaanHoogland deleted the NPE-during-VmIpFetchTask branch September 15, 2025 10:22
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.

4 participants