Skip to content

Fix block commit wait when using libvirt events - #13914

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

JoaoJandre wants to merge 3 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 23.80952% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 20.67%. Comparing base (64178ea) to head (dfcc1d0).
⚠️ Report is 233 commits behind head on main.

Files with missing lines Patch % Lines
...d/hypervisor/kvm/resource/BlockCommitListener.java 0.00% 16 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #13914      +/-   ##
============================================
+ Coverage     19.65%   20.67%   +1.01%     
- Complexity    19798    21722    +1924     
============================================
  Files          6368     6492     +124     
  Lines        574943   590746   +15803     
  Branches      70355    72448    +2093     
============================================
+ Hits         113015   122108    +9093     
- Misses       449658   455364    +5706     
- Partials      12270    13274    +1004     
Flag Coverage Δ
uitests 3.88% <ø> (+0.46%) ⬆️
unittests 21.97% <23.80%> (+1.04%) ⬆️

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.

@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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@Damans227 If I understood your comment correctly, it should be fixed now. Now we get the result after removing the blockCommitListener, so it is impossible for us to get a failed result and for the listener to process the event after.

@JoaoJandre

Copy link
Copy Markdown
Contributor Author

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@JoaoJandre a [SL] Jenkins job has been kicked to build packages. It will be bundled with no 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 19781

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.

7 participants