Skip to content

Propagate StopAnswer error details up the call chain when stopping a VM#13558

Open
Damans227 wants to merge 1 commit into
apache:4.22from
Damans227:propagate-stopanswer-errors
Open

Propagate StopAnswer error details up the call chain when stopping a VM#13558
Damans227 wants to merge 1 commit into
apache:4.22from
Damans227:propagate-stopanswer-errors

Conversation

@Damans227

Copy link
Copy Markdown
Collaborator

Description

When a hypervisor's StopAnswer for a StopCommand fails, the underlying failure reason is logged locally but never surfaced to the caller. Operators and API callers only ever see a generic "Unable to stop VM" message, with no indication of what actually went wrong on the hypervisor side.

This PR changes sendStop() and cleanup() in VirtualMachineManagerImpl to return a Pair<Boolean, String> (success flag + failure detail) instead of a plain boolean, and threads that detail through to the exceptions raised by callers (advanceStop, migrate, orchestrateMigrateWithStorage, orchestrateMigrateForScale), so the StopAnswer failure reason is now visible in the resulting error message.

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

How Has This Been Tested?

This is a logging/error-message improvement; there's no change to the stop/cleanup control flow itself. Existing unit tests in VirtualMachineManagerImplTest were updated to match the new sendStop() return type, including an assertion on the propagated failure detail. Ran the full VirtualMachineManagerImplTest suite (100 tests) locally, all passing.

How did you try to break this feature and the system with this change?

Verified every caller of sendStop()/cleanup() within VirtualMachineManagerImpl was updated consistently to handle the new return type, including a case where the Migrating state combines the hostId/lastHostId checks into a single sendStop() call, to avoid an unrelated double-invocation.

@codecov

codecov Bot commented Jul 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 21.87500% with 25 lines in your changes missing coverage. Please review.
✅ Project coverage is 19.41%. Comparing base (a951ac6) to head (5fe808e).

Files with missing lines Patch % Lines
...n/java/com/cloud/vm/VirtualMachineManagerImpl.java 21.87% 25 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               4.22   #13558      +/-   ##
============================================
+ Coverage     17.67%   19.41%   +1.74%     
- Complexity    15797    19153    +3356     
============================================
  Files          5923     6284     +361     
  Lines        533349   564865   +31516     
  Branches      65248    68920    +3672     
============================================
+ Hits          94253   109687   +15434     
- Misses       428437   443274   +14837     
- Partials      10659    11904    +1245     
Flag Coverage Δ
uitests 3.46% <ø> (-0.24%) ⬇️
unittests 20.67% <21.87%> (+1.92%) ⬆️

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.

When a hypervisor's StopAnswer for a StopCommand fails, the underlying
failure reason is logged locally but never surfaced to the caller.
Operators and API callers only ever see a generic "Unable to stop VM"
message, with no indication of what actually went wrong on the
hypervisor side.

This changes sendStop() and cleanup() in VirtualMachineManagerImpl to
return a Pair<Boolean, String> (success flag + failure detail) instead
of a plain boolean, and threads that detail through to the exceptions
raised by callers (advanceStop, migrate, orchestrateMigrateWithStorage,
orchestrateMigrateForScale), so the StopAnswer failure reason is now
visible in the resulting error message.
@Damans227 Damans227 force-pushed the propagate-stopanswer-errors branch from 1dfd4ad to 5fe808e Compare July 7, 2026 15:42
@Damans227 Damans227 changed the base branch from main to 4.22 July 7, 2026 15:42
@nvazquez nvazquez added this to the 4.22.2 milestone Jul 7, 2026
@nvazquez

nvazquez commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@nvazquez 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 18491

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.

5 participants