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?

Copy link

codecov bot commented Aug 4, 2025

Codecov Report

❌ Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 17.37%. Comparing base (86827f8) to head (79e9bac).
⚠️ Report is 114 commits behind head on main.

Files with missing lines Patch % Lines
.../src/main/java/com/cloud/vm/UserVmManagerImpl.java 0.00% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #11389      +/-   ##
============================================
+ Coverage     17.17%   17.37%   +0.20%     
- Complexity    14985    15220     +235     
============================================
  Files          5869     5885      +16     
  Lines        521590   524878    +3288     
  Branches      63485    64036     +551     
============================================
+ Hits          89562    91199    +1637     
- Misses       421962   423390    +1428     
- Partials      10066    10289     +223     
Flag Coverage Δ
uitests 3.63% <ø> (-0.13%) ⬇️
unittests 18.41% <0.00%> (+0.26%) ⬆️

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