Skip to content

Fix block commit wait when using libvirt events - #13914

Open
JoaoJandre wants to merge 2 commits into
apache:mainfrom
scclouds:fix-block-commit
Open

JoaoJandre wants to merge 2 commits into
apache:mainfrom
scclouds:fix-block-commit

Conversation

@JoaoJandre

Copy link
Copy Markdown
Contributor

Description

There is a bug in the VM volume block-commit process that affects the KBOSS backup, volume snapshot, and VM snapshot processes, where if the waiting process finishes without Libvirt throwing an event, ACS assumes the process finished successfully.

This PR fixes this situation, so that the process is only considered successful when the correct event is thrown by Libvirt.

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?

In the agent.properties file, I changed libvirt.events.enabled to true and qcow2.delta.merge.timeout to 1.
I took a (non-incremental) volume snapshot of a VM and while the snapshot was being copied to the secondary storage, I wrote 1GB of data into the volume, so that the block commit would not be instantaneous.

  • Before the patch, ACS considered that the block commit was a success (even though it was still being done)
  • After the patch, an error is thrown, as expected.

@codecov

codecov Bot commented Aug 18, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 37.03704% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 19.65%. Comparing base (64178ea) to head (1a893ea).

Files with missing lines Patch % Lines
...d/hypervisor/kvm/resource/BlockCommitListener.java 0.00% 16 Missing ⚠️
...ervisor/kvm/resource/LibvirtComputingResource.java 90.90% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##               main   #13914   +/-   ##
=========================================
  Coverage     19.65%   19.65%           
- Complexity    19798    19800    +2     
=========================================
  Files          6368     6368           
  Lines        574943   574961   +18     
  Branches      70355    70355           
=========================================
+ Hits         113015   113029   +14     
- Misses       449658   449661    +3     
- Partials      12270    12271    +1     
Flag Coverage Δ
uitests 3.41% <ø> (ø)
unittests 20.93% <37.03%> (+<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.

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.

Copilot review overview

🟡 Changes recommended

Events are not correlated to the target disk, and the central no-event behavior lacks regression coverage.

Review effort: Balanced
Findings: 1 High severity · 1 Medium severity

Open (2)
What changed in this PR

Fixes block-commit completion handling by requiring the corresponding Libvirt event before reporting success.

Changes:

  • Waits for block-job events within the remaining merge timeout.
  • Uses a semaphore to signal terminal block-commit events.
  • Updates merge tests for the listener API.
File Description
BlockCommitListener.java Adds event waiting and timeout handling.
LibvirtComputingResource.java Passes remaining timeout to the listener.
LibvirtComputingResourceTest.java Updates listener mocks for the new method signature.

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

switch (status) {
case COMPLETED:
result = null;
semaphore.release();
ThreadContext.get(Mockito.anyString())).thenReturn("logid");
Mockito.doNothing().when(domainMock).addBlockJobListener(Mockito.any());
Mockito.doReturn(blockCommitListenerMock).when(libvirtComputingResourceSpy).getBlockCommitListener(Mockito.any());
Mockito.doReturn(null).when(blockCommitListenerMock).getResult(anyInt());
@weizhouapache

Copy link
Copy Markdown
Member

@JoaoJandre
could you address copilot's comments ?


checkBlockCommitProgress(vm, diskLabel, vmName, snapshotName, topFilePath, baseFilePath);
remainingTimeout = checkBlockCommitProgress(vm, diskLabel, vmName, snapshotName, topFilePath, baseFilePath);
mergeResult = blockCommitListener.getResult(remainingTimeout);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

what happens if the job finishes on the last poll? the wait left is 0 here, so an event that shows up a moment late gets reported as a failed commit

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

Status: Ready

Development

Successfully merging this pull request may close these issues.

6 participants