Skip to content

KVM VM migration log refactor - #14224

Open
erikbocks wants to merge 4 commits into
apache:mainfrom
scclouds:kvm-vm-migration-log-refactor
Open

erikbocks wants to merge 4 commits into
apache:mainfrom
scclouds:kvm-vm-migration-log-refactor

Conversation

@erikbocks

Copy link
Copy Markdown
Collaborator

Description

This PR focuses on improving the consistency and clarity of logging of the KVM VM migration process. The changes aim to improve the traceability of the process, by adding more context for the logs, helping future troubleshooting processes. It also standardizes log messages to use parametrized logging, instead of string concatenation.

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

Screenshots (if appropriate):

How Has This Been Tested?

The code was compiled with Maven and installed to my local environment. Then, I migrated a VM from one of my hosts to another and verified that the new logs were displayed correctly.

@codecov

codecov Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 13.33333% with 26 lines in your changes missing coverage. Please review.
✅ Project coverage is 20.21%. Comparing base (602d9ec) to head (4322354).
⚠️ Report is 9 commits behind head on main.

Files with missing lines Patch % Lines
...resource/wrapper/LibvirtMigrateCommandWrapper.java 14.28% 24 Missing ⚠️
...n/java/com/cloud/vm/VirtualMachineManagerImpl.java 0.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #14224      +/-   ##
============================================
+ Coverage     19.91%   20.21%   +0.29%     
- Complexity    20200    20749     +549     
============================================
  Files          6373     6426      +53     
  Lines        577230   580177    +2947     
  Branches      70696    71028     +332     
============================================
+ Hits         114974   117294    +2320     
- Misses       449690   450170     +480     
- Partials      12566    12713     +147     
Flag Coverage Δ
uitests 3.69% <ø> (-0.03%) ⬇️
unittests 21.51% <13.33%> (+0.32%) ⬆️

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.

Copilot AI 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.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

Review effort: Lite
Findings: 7 Medium severity · 3 Low severity

Open (10)
What changed in this PR

Refactors KVM VM migration logging to be more consistent and contextual, primarily by switching to parameterized logging and standardizing messages for troubleshooting.

Changes:

  • Replaced String.format/string concatenation with parameterized logging across KVM migration flow.
  • Expanded log context (destination host, XML retrieval flag, job stats) for better traceability.
  • Tweaked log levels/messages around migration timeouts and exception handling.
File Description
plugins/​hypervisors/​kvm/​src/​main/​java/​com/​cloud/​hypervisor/​kvm/​resource/​wrapper/​LibvirtMigrateCommandWrapper.java Standardizes and enriches migration logs; adjusts log levels and message structure.
engine/​orchestration/​src/​main/​java/​com/​cloud/​vm/​VirtualMachineManagerImpl.java Fixes/standardizes config-drive detach logging and improves message quality.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@erikbocks erikbocks changed the title Kvm vm migration log refactor KVM VM migration log refactor Oct 13, 2026
Copilot AI lite review requested due to automatic review settings October 13, 2026 13:32
@Damans227

Copy link
Copy Markdown
Collaborator

thanks @erikbocks, log changes look right. LGTM

Copilot AI 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.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

4 open findings
10 resolved since last review

🧠 Review effort: Lite

Comment thread engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java Outdated
Copilot AI lite review requested due to automatic review settings October 13, 2026 13:57

Copilot AI 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.

logger.error("TIme out occurred while exeuting command AttachOrDettachConfigDrive {}", e.getMessage(), e);

}
logger.error("Timeout occurred while executing command AttachOrDettachConfigDrive for VM {} on source host {}", vm.getInstanceName(), srcHost.getId(), e); }
logger.info("VM domain state when trying to pause VM for migration: {}.", state);
} catch (final LibvirtException e) {
logger.info("Couldn't get VM domain state after " + sleeptime + "ms: " + e.getMessage());
logger.info("Could not get VM domain state after {}ms: {}.", sleeptime, e.getMessage());
}

private void logMigrationFailure(String vmName, String destinationIp, Exception exception) {
logger.error("Could not migrate domain [{}] to host [{}].", vmName, destinationIp, exception);

This branch has not been deployed

No deployments
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.

3 participants