-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Fix delete snapshot policy expunged volume #12474
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
base: 4.22
Are you sure you want to change the base?
Fix delete snapshot policy expunged volume #12474
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests.
Additional details and impacted files@@ Coverage Diff @@
## 4.22 #12474 +/- ##
=============================================
- Coverage 17.56% 3.60% -13.96%
=============================================
Files 5910 445 -5465
Lines 529128 37634 -491494
Branches 64636 6948 -57688
=============================================
- Hits 92931 1356 -91575
+ Misses 425740 36112 -389628
+ Partials 10457 166 -10291
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@Damans227 Check if it's possible to remove all snapshot policies of expunged / non-existing volumes during the upgrade (as one-time task as these are not applicable any more, and not relevant to show them in the UI). I think, it's better to remove all the snapshot policies associated with the volume during expunge volume itself, and refer them with findByIdIncluding Removed() wherever the snapshot policy is referred for the existing snapshots for the expunged volumes. |
@sureshanaparti So, the policies are already deleted during volume destroy - VolumeServiceImpl.destroyVolume() calls snapshotMgr.deletePoliciesForVolume(). The issue seems to me is when an orphaned policy exists due to an edge case (eg: failures, etc.). To reproduce the issue, I had to manually insert a record in DB to simulate an orphan policy. This fix allows handling those orphans created via UI/ API. Example:
An upgrade script to clean existing orphans is a good idea. Lemme know if I shall further investigate that? |
|
@Damans227 destroy volume can be recovered, so better delete these policies while expunging the volume. also, check if you can keep the delete policies and remove volume in a transaction on destroy / expunge volume. check if such orphans can be cleaned during ms start (maybe here - Line 1210 in 036489b
|
@sureshanaparti I see what you mean. I'll move policy deletion from destroy to expunge and add orphan cleanup on MS startup. |
|
@blueorangutan package |
|
@Damans227 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. |
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 16472 |
|
[SF] Trillian Build Failed (tid-15241) |
|
[SF] Trillian Build Failed (tid-15246) |
But env built successfully. That's odd. Jenkins needs investigation. |
@sureshanaparti I tested the changes - created a VM with snapshot policy, destroyed it, then expunged it. Policy was deleted on expunge. The Jenkins env is available if you want to review/test the changes. The blueorangutan message above is misleading, so please ignore that. |
Pearl1594
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested the logic for deleting snapshot policy of an expunged volume - did so by
- Creating a snapshot policy for a root disk of a vm
- Expunged the VM
- Re-added the snapshot policy -to simulate orphaned policy
- attempted deletion - successfully deleted.
server/src/main/java/com/cloud/storage/snapshot/SnapshotManagerImpl.java
Outdated
Show resolved
Hide resolved
…nged state or null
Pearl1594
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code LGTM. Verified fix.
DaanHoogland
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clgtm
|
@blueorangutan package |
|
@DaanHoogland 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. |

Description
Fixes: #12441
deleteSnapshotPolicies()usesfindById()which fails for expunged volumes. Changed tofindByIdIncludingRemoved()to allow deleting orphaned policies.Types of changes
Feature/Enhancement Scale or Bug Severity
Bug Severity
How Has This Been Tested?
deleteSnapshotPolicies()