Skip to content

Fix NPE during VM setup for pvlan#12781

Merged
weizhouapache merged 2 commits intoapache:4.22from
shapeblue:npe-fix-during-setup-pvlan
Apr 1, 2026
Merged

Fix NPE during VM setup for pvlan#12781
weizhouapache merged 2 commits intoapache:4.22from
shapeblue:npe-fix-during-setup-pvlan

Conversation

@sureshanaparti
Copy link
Copy Markdown
Contributor

Description

This PR fixes NPE issue during VM setup for pvlan.

ERROR [c.c.v.VmWorkJobDispatcher] (Work-Job-Executor-5:[ctx-36c8ede2, job-51933/job-51934]) (logid:aad07025) Unable to complete AsyncJob {"accountId":2,"cmd":"com.cloud.vm.VmWorkMigrate","cmdInfo":"rO0ABXNyABpjb20uY2xvdWQudm0uVm1Xb3JrTWlncmF0ZRdxQXtPtzYqAgAGSgAJc3JjSG9zdElkTAAJY2x1c3RlcklkdAAQTGphdmEvbGFuZy9Mb25nO0wABmhvc3RJZHEAfgABTAAFcG9kSWRxAH4AAUwAB3N0b3JhZ2V0AA9MamF2YS91dGlsL01hcDtMAAZ6b25lSWRxAH4AAXhyABNjb20uY2xvdWQudm0uVm1Xb3Jrn5m2VvAlZ2sCAARKAAlhY2NvdW50SWRKAAZ1c2VySWRKAAR2bUlkTAALaGFuZGxlck5hbWV0ABJMamF2YS9sYW5nL1N0cmluZzt4cAAAAAAAAAACAAAAAAAAAFMAAAAAAAAAMHQAGVZpcnR1YWxNYWNoaW5lTWFuYWdlckltcGwAAAAAAAAAEXNyAA5qYXZhLmxhbmcuTG9uZzuL5JDMjyPfAgABSgAFdmFsdWV4cgAQamF2YS5sYW5nLk51bWJlcoaslR0LlOCLAgAAeHAAAAAAAAAAA3NxAH4ABwAAAAAAAAATc3EAfgAHAAAAAAAAAAFwcQB-AAs","cmdVersion":0,"completeMsid":null,"created":"Mon Feb 16 15:40:04 EST 2026","id":51934,"initMsid":90520733277145,"instanceId":null,"instanceType":null,"lastPolled":null,"lastUpdated":null,"processStatus":0,"removed":null,"result":null,"resultCode":0,"status":"IN_PROGRESS","userId":83,"uuid":"c3826ec3-3793-453c-bd0b-a79cbfbda7fe"}, job origin: 51933 java.lang.NullPointerException: Cannot invoke "java.net.URI.getScheme()" because the return value of "com.cloud.vm.NicProfile.getBroadCastUri()" is null at com.cloud.vm.UserVmManagerImpl.setupVmForPvlan(UserVmManagerImpl.java:5390) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:569) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:215) at jdk.proxy3/jdk.proxy3.$Proxy219.setupVmForPvlan(Unknown Source) at org.apache.cloudstack.engine.orchestration.NetworkOrchestrator.prepareNicForMigration(NetworkOrchestrator.java:2278) at com.cloud.vm.VirtualMachineManagerImpl.migrate(VirtualMachineManagerImpl.java:3100) at com.cloud.vm.VirtualMachineManagerImpl.orchestrateMigrate(VirtualMachineManagerImpl.java:3052) at com.cloud.vm.VirtualMachineManagerImpl.orchestrateMigrate(VirtualMachineManagerImpl.java:5978)

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?

@sureshanaparti
Copy link
Copy Markdown
Contributor Author

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

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 10, 2026

Codecov Report

❌ Patch coverage is 0% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 17.61%. Comparing base (7aa0558) to head (ba8fb7b).
⚠️ Report is 22 commits behind head on 4.22.

Files with missing lines Patch % Lines
.../src/main/java/com/cloud/vm/UserVmManagerImpl.java 0.00% 14 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               4.22   #12781      +/-   ##
============================================
- Coverage     17.61%   17.61%   -0.01%     
+ Complexity    15664    15662       -2     
============================================
  Files          5917     5917              
  Lines        531402   531413      +11     
  Branches      64971    64974       +3     
============================================
- Hits          93596    93585      -11     
- Misses       427252   427273      +21     
- Partials      10554    10555       +1     
Flag Coverage Δ
uitests 3.70% <ø> (ø)
unittests 18.68% <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.

Copy link
Copy Markdown
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

Fixes a NullPointerException during VM pvlan setup by guarding against missing NIC broadcast URI (and missing host).

Changes:

  • Add null checks for NicProfile / getBroadCastUri() before accessing URI scheme.
  • Compare pvlan scheme safely using a local scheme variable and constant-first equals.
  • Add a host existence check (with a warning) before issuing the pvlan setup command.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread server/src/main/java/com/cloud/vm/UserVmManagerImpl.java Outdated
Comment thread server/src/main/java/com/cloud/vm/UserVmManagerImpl.java Outdated
Comment thread server/src/main/java/com/cloud/vm/UserVmManagerImpl.java Outdated
@blueorangutan
Copy link
Copy Markdown

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

@sureshanaparti sureshanaparti marked this pull request as ready for review March 11, 2026 09:07
@sureshanaparti
Copy link
Copy Markdown
Contributor Author

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

@blueorangutan
Copy link
Copy Markdown

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

@sureshanaparti
Copy link
Copy Markdown
Contributor Author

@blueorangutan test

@blueorangutan
Copy link
Copy Markdown

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

Copy link
Copy Markdown
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

Copy link
Copy Markdown
Contributor

@DaanHoogland DaanHoogland left a comment

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

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

Test Result Time (s) Test File
ContextSuite context=TestListIdsParams>:teardown Error 1.15 test_list_ids_parameter.py
test_01_snapshot_root_disk Error 3.73 test_snapshots.py
test_02_list_snapshots_with_removed_data_store Error 47.64 test_snapshots.py
test_02_list_snapshots_with_removed_data_store Error 47.65 test_snapshots.py
ContextSuite context=TestSnapshotStandaloneBackup>:teardown Error 27.61 test_snapshots.py
test_01_snapshot_usage Error 36.00 test_usage.py
test_01_vpn_usage Error 1.09 test_usage.py

@daviftorres
Copy link
Copy Markdown
Contributor

Dear @sureshanaparti , what is the issue number that this PR relates to?

@DaanHoogland
Copy link
Copy Markdown
Contributor

Dear @sureshanaparti , what is the issue number that this PR relates to?

@daviftorres , I don’t think there is an issue number linked as @sureshanaparti immediately started fixing an issue he saw. We can link any candidate issues retrospectively though.

@davift
Copy link
Copy Markdown

davift commented Mar 21, 2026

Dear @sureshanaparti , what is the issue number that this PR relates to?

@daviftorres , I don’t think there is an issue number linked as @sureshanaparti immediately started fixing an issue he saw. We can link any candidate issues retrospectively though.

Dear @DaanHoogland,

Panic shared this PR with me as a reference to a known issue we are experiencing in our production environment. However, the PR description does not clearly explain what problem it is resolving.

That’s why I opened the issue, to get more clarity and additional context.

@DaanHoogland
Copy link
Copy Markdown
Contributor

Panic shared this PR with me as a reference to a known issue we are experiencing in our production environment. However, the PR description does not clearly explain what problem it is resolving.

That’s why I opened the issue, to get more clarity and additional context.

Which issue # @davift ?

@davift
Copy link
Copy Markdown

davift commented Mar 26, 2026

Panic shared this PR with me as a reference to a known issue we are experiencing in our production environment. However, the PR description does not clearly explain what problem it is resolving.
That’s why I opened the issue, to get more clarity and additional context.

Which issue # @davift ?

Andrija Panic helped me on a ticket through ShapeBlue and he pointed that this PR fixed the issue we have encountered. But I cannot make my own assessment of the case based on the PR description.

@DaanHoogland
Copy link
Copy Markdown
Contributor

Panic shared this PR with me as a reference to a known issue we are experiencing in our production environment. However, the PR description does not clearly explain what problem it is resolving.
That’s why I opened the issue, to get more clarity and additional context.

Which issue # @davift ?

Andrija Panic helped me on a ticket through ShapeBlue and he pointed that this PR fixed the issue we have encountered. But I cannot make my own assessment of the case based on the PR description.

aha, Shapeblue does not publish customer issues (as I imagine others do not either). So for all sakes of argument there is no issue. They do often anonymise and create shadow issues for those and then we can refer them here, but we cannot link to “non-existent” issues.

Copy link
Copy Markdown
Contributor

@Pearl1594 Pearl1594 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 - tested it, works as expected.

@weizhouapache weizhouapache merged commit e10c066 into apache:4.22 Apr 1, 2026
18 of 26 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in Apache CloudStack 4.22.1 Apr 1, 2026
@DaanHoogland DaanHoogland deleted the npe-fix-during-setup-pvlan branch April 1, 2026 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

9 participants