Skip to content

Fix KVM incremental snapshot removal when using multiple secondary storages #11180

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

JoaoJandre
Copy link
Contributor

Description

When removing an incremental snapshot (For both KVM and XenServer), it is checked if the snapshot has a child or not. If it has, then the snapshot is not removed from the storage.

For KVM incremental snapshots, snapshots in the same chain may be on different secondary storages (within the same zone).

However, the child search process only considers snapshots from the same secondary storage as theirs. Therefore, if a snapshot has its parent snapshot on a different secondary storage, it will be completely removed, making the snapshot chain inconsistent.

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?

I created 3 snapshots that were stored in the secondary storage sec-nfs1. I then set the storage sec-nfs1 to read-only and created 2 more snapshots, which were stored in the secondary storage sec-nfs2.

Without the changes: when the third snapshot was removed, its state was set to Destroyed, and an error was thrown when trying to restore the fourth snapshot, indicating that the file for the third snapshot no longer existed.

MariaDB [cloud]> select id, store_id, snapshot_id, created, updated, store_role, parent_snapshot_id, install_path, state, kvm_checkpoint_path from snapshot_store_ref;
+-----+----------+-------------+---------------------+---------------------+------------+--------------------+------------------------------------------------------+-----------+--------------------------------------------------------------------------------------------------+
| id  | store_id | snapshot_id | created             | updated             | store_role | parent_snapshot_id | install_path                                         | state     | kvm_checkpoint_path                                                                              |
+-----+----------+-------------+---------------------+---------------------+------------+--------------------+------------------------------------------------------+-----------+--------------------------------------------------------------------------------------------------+
| 153 |        3 |         108 | 2025-05-08 15:00:01 | NULL                | Image      |                  0 | snapshots/2/809/90dbdda6-1c6e-41f6-ba77-3628df6ee7f4 | Ready     | /mnt/b9f36295-3bbe-3c7a-ac0c-778cf3c58994/checkpoints/2/809/90dbdda6-1c6e-41f6-ba77-3628df6ee7f4 |
| 155 |        3 |         109 | 2025-05-08 15:01:11 | NULL                | Image      |                108 | snapshots/2/809/3c70a9d1-0345-493a-bad4-64234e3d209c | Ready     | /mnt/b9f36295-3bbe-3c7a-ac0c-778cf3c58994/checkpoints/2/809/3c70a9d1-0345-493a-bad4-64234e3d209c |
| 157 |        3 |         110 | 2025-05-08 15:01:21 | 2025-05-08 15:06:07 | Image      |                109 | snapshots/2/809/4df03232-2685-4e35-ab15-6948644b33c7 | Destroyed | /mnt/b9f36295-3bbe-3c7a-ac0c-778cf3c58994/checkpoints/2/809/4df03232-2685-4e35-ab15-6948644b33c7 |
| 159 |        4 |         111 | 2025-05-08 15:05:37 | NULL                | Image      |                110 | snapshots/2/809/d7e1a290-2670-46dc-871e-8bf9468161ac | Ready     | /mnt/f0994169-be48-31f0-b7d0-449f54ff0c93/checkpoints/2/809/d7e1a290-2670-46dc-871e-8bf9468161ac |
| 161 |        4 |         112 | 2025-05-08 15:05:49 | NULL                | Image      |                111 | snapshots/2/809/c0d0bb47-847e-41bc-95f9-d39618d87414 | Ready     | /mnt/f0994169-be48-31f0-b7d0-449f54ff0c93/checkpoints/2/809/c0d0bb47-847e-41bc-95f9-d39618d87414 |
+-----+----------+-------------+---------------------+---------------------+------------+--------------------+------------------------------------------------------+-----------+--------------------------------------------------------------------------------------------------+
5 rows in set (0.000 sec)

With the changes: the third snapshot's state was set to Hidden, and it was possible to restore the fourth snapshot.

MariaDB [cloud]> select id, store_id, snapshot_id, created, updated, store_role, parent_snapshot_id, install_path, state, kvm_checkpoint_path from snapshot_store_ref where id > 165;
+-----+----------+-------------+---------------------+---------+------------+--------------------+------------------------------------------------------+--------+--------------------------------------------------------------------------------------------------+
| id  | store_id | snapshot_id | created             | updated | store_role | parent_snapshot_id | install_path                                         | state  | kvm_checkpoint_path                                                                              |
+-----+----------+-------------+---------------------+---------+------------+--------------------+------------------------------------------------------+--------+--------------------------------------------------------------------------------------------------+
| 167 |        3 |         115 | 2025-05-08 16:07:33 | NULL    | Image      |                  0 | snapshots/2/809/6eeeeeb0-0455-4893-9507-4f2a68878ba3 | Ready  | /mnt/b9f36295-3bbe-3c7a-ac0c-778cf3c58994/checkpoints/2/809/6eeeeeb0-0455-4893-9507-4f2a68878ba3 |
| 169 |        3 |         116 | 2025-05-08 16:08:18 | NULL    | Image      |                115 | snapshots/2/809/9cfa65a5-633e-4e66-97fa-399b5536f502 | Ready  | /mnt/b9f36295-3bbe-3c7a-ac0c-778cf3c58994/checkpoints/2/809/9cfa65a5-633e-4e66-97fa-399b5536f502 |
| 171 |        3 |         117 | 2025-05-08 16:11:57 | NULL    | Image      |                116 | snapshots/2/809/f33b702a-0995-4f95-9e8a-f035fe1939d4 | Hidden | /mnt/b9f36295-3bbe-3c7a-ac0c-778cf3c58994/checkpoints/2/809/f33b702a-0995-4f95-9e8a-f035fe1939d4 |
| 173 |        4 |         118 | 2025-05-08 16:13:12 | NULL    | Image      |                117 | snapshots/2/809/4e91f4bb-684c-4beb-8d9a-068ece3a7f08 | Ready  | /mnt/f0994169-be48-31f0-b7d0-449f54ff0c93/checkpoints/2/809/4e91f4bb-684c-4beb-8d9a-068ece3a7f08 |
| 175 |        4 |         119 | 2025-05-08 16:13:18 | NULL    | Image      |                118 | snapshots/2/809/ba61769b-59df-489f-87c1-a6c09a491eb0 | Ready  | /mnt/f0994169-be48-31f0-b7d0-449f54ff0c93/checkpoints/2/809/ba61769b-59df-489f-87c1-a6c09a491eb0 |
+-----+----------+-------------+---------------------+---------+------------+--------------------+------------------------------------------------------+--------+--------------------------------------------------------------------------------------------------+
5 rows in set (0.000 sec)

Copy link

codecov bot commented Jul 11, 2025

Codecov Report

Attention: Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.

Project coverage is 16.57%. Comparing base (8e4fe1c) to head (ad5100d).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...he/cloudstack/storage/snapshot/SnapshotObject.java 0.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #11180      +/-   ##
============================================
- Coverage     16.57%   16.57%   -0.01%     
+ Complexity    13988    13987       -1     
============================================
  Files          5745     5745              
  Lines        510847   510848       +1     
  Branches      62140    62141       +1     
============================================
- Hits          84696    84694       -2     
- Misses       416677   416679       +2     
- Partials       9474     9475       +1     
Flag Coverage Δ
uitests 3.91% <ø> (ø)
unittests 17.47% <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
Contributor

@DaanHoogland DaanHoogland left a comment

Choose a reason for hiding this comment

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

clgtm

Copy link
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.

code lgtm

@sureshanaparti
Copy link
Contributor

@winterhazel @bernardodemarco can you do some testing for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

3 participants