[pve-devel] [PATCH V2 pve-manager 8/8] fix #3711: enable removing container with non existent storage

Stefan Hrdlicka s.hrdlicka at proxmox.com
Mon Sep 12 17:25:07 CEST 2022


Add a checkbox to the remove dialog of LXC containers and VMs to force
deleting a container/VM if the storage it uses has been removed.

Signed-off-by: Stefan Hrdlicka <s.hrdlicka at proxmox.com>
---
 www/manager6/lxc/Config.js              |  1 +
 www/manager6/qemu/Config.js             |  1 +
 www/manager6/window/SafeDestroyGuest.js | 34 +++++++++++++++++++++++++
 3 files changed, 36 insertions(+)

diff --git a/www/manager6/lxc/Config.js b/www/manager6/lxc/Config.js
index 89b59c9b..3a0acc0a 100644
--- a/www/manager6/lxc/Config.js
+++ b/www/manager6/lxc/Config.js
@@ -154,6 +154,7 @@ Ext.define('PVE.lxc.Config', {
 			    url: base_url,
 			    item: { type: 'CT', id: vmid },
 			    taskName: 'vzdestroy',
+			    showForceRemoveMissingStorage: true,
 			}).show();
 		    },
 		    iconCls: 'fa fa-trash-o',
diff --git a/www/manager6/qemu/Config.js b/www/manager6/qemu/Config.js
index 9fe933df..150835ed 100644
--- a/www/manager6/qemu/Config.js
+++ b/www/manager6/qemu/Config.js
@@ -129,6 +129,7 @@ Ext.define('PVE.qemu.Config', {
 			    url: base_url,
 			    item: { type: 'VM', id: vmid },
 			    taskName: 'qmdestroy',
+			    showForceRemoveMissingStorage: true,
 			}).show();
 		    },
 		    iconCls: 'fa fa-trash-o',
diff --git a/www/manager6/window/SafeDestroyGuest.js b/www/manager6/window/SafeDestroyGuest.js
index 3328293a..6cffa2bb 100644
--- a/www/manager6/window/SafeDestroyGuest.js
+++ b/www/manager6/window/SafeDestroyGuest.js
@@ -28,8 +28,37 @@ Ext.define('PVE.window.SafeDestroyGuest', {
 		'data-qtip': gettext('Scan all enabled storages for unreferenced disks and delete them.'),
 	    },
 	},
+	{
+	    xtype: 'proxmoxcheckbox',
+	    name: 'forceStorageRemove',
+	    reference: 'forceRemoveMissingStorage',
+	    boxLabel: gettext('Ignore missing/unavailable storage.'),
+	    checked: false,
+	    submitValue: false,
+	    hidden: true,
+	    autoEl: {
+		tag: 'div',
+		'data-qtip': gettext('Force remove container when storage is unavailable. ' +
+		    'The disk is not cleaned if storage still exists.'),
+	    },
+	},
     ],
 
+    config: {
+        showForceRemoveMissingStorage: false,
+    },
+
+    initComponent: function() {
+	let me = this;
+
+	me.callParent();
+
+	if (me.showForceRemoveMissingStorage) {
+	    let frms = me.lookupReference('forceRemoveMissingStorage');
+	    frms.hidden = !me.showForceRemoveMissingStorage;
+	}
+    },
+
     note: gettext('Referenced disks will always be destroyed.'),
 
     getParams: function() {
@@ -41,6 +70,11 @@ Ext.define('PVE.window.SafeDestroyGuest', {
 	const destroyUnreferencedCheckbox = me.lookupReference('destroyUnreferencedCheckbox');
 	me.params["destroy-unreferenced-disks"] = destroyUnreferencedCheckbox.checked ? 1 : 0;
 
+	if (me.showForceRemoveMissingStorage) {
+	    const forceRemoveMissingStorage = me.lookupReference('forceRemoveMissingStorage');
+	    me.params['ignore-storage-errors'] = forceRemoveMissingStorage.checked ? 1 : 0;
+	}
+
 	return me.callParent();
     },
 });
-- 
2.30.2






More information about the pve-devel mailing list