Skip to content

Fix NPE during VM IP fetch for shared networks #11389

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

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?

Copy link

codecov bot commented Aug 4, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 3.63%. Comparing base (86827f8) to head (79e9bac).
⚠️ Report is 83 commits behind head on main.

❗ There is a different number of reports uploaded between BASE (86827f8) and HEAD (79e9bac). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (86827f8) HEAD (79e9bac)
unittests 1 0
Additional details and impacted files
@@              Coverage Diff              @@
##               main   #11389       +/-   ##
=============================================
- Coverage     17.17%    3.63%   -13.54%     
=============================================
  Files          5869      441     -5428     
  Lines        521590    36966   -484624     
  Branches      63485     6772    -56713     
=============================================
- Hits          89562     1345    -88217     
+ Misses       421962    35460   -386502     
+ Partials      10066      161     -9905     
Flag Coverage Δ
uitests 3.63% <ø> (-0.13%) ⬇️
unittests ?

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

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

@@ -672,7 +672,7 @@ public void setKubernetesServiceHelpers(final List<KubernetesServiceHelper> kube
"Wait Interval (in seconds) for shared network vm dhcp ip addr fetch for next iteration ", true);

private static final ConfigKey<Integer> VmIpFetchTrialMax = new ConfigKey<Integer>("Advanced", Integer.class, "externaldhcp.vmip.max.retry", "10",
"The max number of retrieval times for shared entwork vm dhcp ip fetch, in case of failures", true);
"The max number of retrieval times for shared network vm dhcp ip fetch, in case of failures", true);
Copy link
Preview

Copilot AI Aug 4, 2025

Choose a reason for hiding this comment

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

Good fix for the typo correction from 'entwork' to 'network'.

Copilot uses AI. Check for mistakes.

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants