Skip to content

server: fix NPE when migrate vm away with volumes - #13131

Merged
weizhouapache merged 1 commit into
apache:4.20from
weizhouapache:4.20-fix-vm-migrate-away-custom-offering
Jun 13, 2026
Merged

server: fix NPE when migrate vm away with volumes#13131
weizhouapache merged 1 commit into
apache:4.20from
weizhouapache:4.20-fix-vm-migrate-away-custom-offering

Conversation

@weizhouapache

Copy link
Copy Markdown
Member

Description

This PR fixes#13130

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?

@weizhouapacheweizhouapache changed the title fix 13130server: fix NPE when migrate vm away with volumesMay 8, 2026
@weizhouapacheweizhouapache added this to the 4.20.4 milestone May 8, 2026
@codecov

codecovBot commented May 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 16.26%. Comparing base (a7c2a05) to head (ad56bf7).
⚠️ Report is 8 commits behind head on 4.20.

Files with missing linesPatch %Lines
...n/java/com/cloud/resource/ResourceManagerImpl.java0.00%1 Missing ⚠️
Additional details and impacted files
@@ Coverage Diff @@## 4.20 #13131 +/- ##
============================================
- Coverage 16.27% 16.26% -0.01% + Complexity 13440 13438 -2 
============================================
Files 5665 5665 Lines 500555 500555 Branches 60789 60789 ============================================
- Hits 81445 81438 -7 - Misses 410004 410012 +8 + Partials 9106 9105 -1 
FlagCoverage Δ
uitests4.15% <ø> (ø)
unittests17.12% <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 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.

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

Pull request overview

Fixes a NullPointerException during host maintenance VM migration when the VM uses a customized/dynamic compute offering (where service_offering.cpu/ram_size may be NULL) by fetching the VM-specific computed service offering.

Changes:

  • Use the ServiceOfferingDao.findById(vmId, offeringId) overload when migrating a VM away with volumes so dynamic offering values are populated from user_vm_details.

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

Comment on lines 1466 to 1468
final DataCenterDeployment plan = new DataCenterDeployment(host.getDataCenterId(), host.getPodId(), host.getClusterId(), null, null, null);
ServiceOfferingVO offeringVO = serviceOfferingDao.findById(vm.getServiceOfferingId());
ServiceOfferingVO offeringVO = serviceOfferingDao.findById(vm.getId(), vm.getServiceOfferingId());
final VirtualMachineProfile profile = new VirtualMachineProfileImpl(vm, null, offeringVO, null, null);

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

@weizhouapache

Copy link
Copy Markdown
MemberAuthor

@blueorangutan package

@weizhouapache
weizhouapache marked this pull request as ready for review May 18, 2026 10:44
@blueorangutan

Copy link
Copy Markdown

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

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

@weizhouapache

Copy link
Copy Markdown
MemberAuthor

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

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

@blueorangutan

Copy link
Copy Markdown

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

TestResultTime (s)Test File
ContextSuite context=TestSharedFSLifecycle>:setupError0.00test_sharedfs_lifecycle.py
test_10_attachAndDetach_isoFailure606.88test_vm_life_cycle.py
test_01_create_vm_snapshotsFailure603.70test_vm_snapshots.py
test_02_revert_vm_snapshotsFailure600.60test_vm_snapshots.py
test_03_delete_vm_snapshotsFailure0.02test_vm_snapshots.py
test_01_create_volumeFailure608.20test_volumes.py
test_01_root_volume_encryptionFailure714.98test_volumes.py
test_02_data_volume_encryptionFailure664.89test_volumes.py
test_03_root_and_data_volume_encryptionFailure688.15test_volumes.py
test_02_attach_volumeFailure1263.82test_volumes.py
test_02_attach_volumeFailure1263.83test_volumes.py
test_03_download_attached_volumeFailure662.09test_volumes.py
test_04_delete_attached_volumeFailure660.02test_volumes.py
test_05_detach_volumeFailure754.24test_volumes.py
test_06_download_detached_volumeFailure842.40test_volumes.py
test_07_resize_failFailure657.10test_volumes.py
test_08_resize_volumeFailure662.19test_volumes.py
test_09_delete_detached_volumeFailure661.27test_volumes.py
test_10_list_volumesFailure657.04test_volumes.py
test_11_attach_volume_with_unstarted_vmFailure757.60test_volumes.py
test_12_resize_volume_with_only_size_parameterFailure661.04test_volumes.py
test_13_migrate_volume_and_change_offeringFailure790.33test_volumes.py
test_14_delete_volume_delete_protectionFailure660.15test_volumes.py

@winterhazelwinterhazel self-assigned this Jun 11, 2026

@winterhazelwinterhazel left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks ok. I validated manually that the reported issue does not happen anymore.

@winterhazel

Copy link
Copy Markdown
Member

@weizhouapache can we attempt one more CI run here?

@weizhouapache

Copy link
Copy Markdown
MemberAuthor

Looks ok. I validated manually that the reported issue does not happen anymore.

Great, thanks for testing

@weizhouapache

Copy link
Copy Markdown
MemberAuthor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

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

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

@weizhouapache

Copy link
Copy Markdown
MemberAuthor

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

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

@blueorangutan

Copy link
Copy Markdown

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

TestResultTime (s)Test File
test_01_vpc_site2site_vpn_multiple_optionsFailure674.99test_vpc_vpn.py

@weizhouapache
weizhouapache merged commit 0bbea20 into apache:4.20Jun 13, 2026
44 of 47 checks passed
@DaanHoogland
DaanHoogland deleted the 4.20-fix-vm-migrate-away-custom-offering branch June 14, 2026 17:14
Sign up for freeto 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.

PrepareHostForMaintenance throws NPE when vm has custom restrained service offering

5 participants

@weizhouapache@blueorangutan@winterhazel@sureshanaparti