Skip to content

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

Draft
weizhouapache wants to merge 1 commit intoapache:4.20from
weizhouapache:4.20-fix-vm-migrate-away-custom-offering
Draft

server: fix NPE when migrate vm away with volumes#13131
weizhouapache wants to merge 1 commit intoapache: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?

@weizhouapache weizhouapache changed the title fix 13130 server: fix NPE when migrate vm away with volumes May 8, 2026
@weizhouapache weizhouapache added this to the 4.20.4 milestone May 8, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 8, 2026

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

Files with missing lines Patch % Lines
...n/java/com/cloud/resource/ResourceManagerImpl.java 0.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     
Flag Coverage Δ
uitests 4.15% <ø> (ø)
unittests 17.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 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 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);
Copy link
Copy Markdown
Contributor

@sureshanaparti sureshanaparti left a comment

Choose a reason for hiding this comment

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

clgtm

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.

PrepareHostForMaintenance throws NPE when vm has custom restrained service offering

3 participants