-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Skip deleting instance with delete protection during account cleanup #12901
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1000,6 +1000,12 @@ protected boolean cleanupAccount(AccountVO account, long callerUserId, Account c | |
| } | ||
|
|
||
| for (UserVmVO vm : vms) { | ||
| if (vm.isDeleteProtection()) { | ||
| logger.warn("Instance [id = {}, name = {}] has delete protection enabled and cannot be deleted.", | ||
| vm.getUuid(), vm.getName()); | ||
| continue; | ||
| } | ||
|
Comment on lines
+1003
to
+1007
|
||
|
|
||
| if (vm.getState() != VirtualMachine.State.Destroyed && vm.getState() != VirtualMachine.State.Expunging) { | ||
| try { | ||
| _vmMgr.destroyVm(vm.getId(), false); | ||
|
|
||
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.
When a VM has delete protection enabled, this loop now
continues without destroying/expunging it, but it also leavesaccountCleanupNeededunchanged. That means the cleanup can still be marked as complete (needsCleanup=false) even though protected instances remain under a removed account, potentially leaving orphaned VMs/resources with no follow-up cleanup attempts (e.g., in basic/shared-network setups where later network cleanup may still succeed).Consider treating this as an incomplete cleanup: set
accountCleanupNeeded = truewhen delete-protected VMs are found and/or fail the account/domain deletion with a clear error so operators can remove protection first, rather than silently completing cleanup.