public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH container 1/2] fix: clean up config when invalid ostemplate is given
@ 2022-11-17  9:39 Daniel Tschlatscher
  2022-11-17  9:39 ` [pve-devel] [PATCH container 2/2] fix: also remove firewall config after failed restore Daniel Tschlatscher
  2022-11-17 12:45 ` [pve-devel] [PATCH container 1/2] fix: clean up config when invalid ostemplate is given Thomas Lamprecht
  0 siblings, 2 replies; 3+ messages in thread
From: Daniel Tschlatscher @ 2022-11-17  9:39 UTC (permalink / raw)
  To: pve-devel

Before, if an invalid/non-existant ostemplate parameter was passed,
the task would abort, but would leave an empty config file behind.
This also applies to errors for invalid mount point configurations.
In both cases, the empty config will now be removed.

Signed-off-by: Daniel Tschlatscher <d.tschlatscher@proxmox.com>
---
 src/PVE/API2/LXC.pm | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm
index 79aecaa..7cc64af 100644
--- a/src/PVE/API2/LXC.pm
+++ b/src/PVE/API2/LXC.pm
@@ -443,7 +443,14 @@ __PACKAGE__->register_method({
 		    }
 		}
 	    };
-	    die "$emsg $@" if $@;
+
+	    if (my $reason = $@) {
+		if (!$same_container_exists) {
+		    eval { PVE::LXC::Config->destroy_config($vmid) };
+		    $remove_lock = 0;
+		}
+		die "$emsg $reason";
+	    }
 
 	    # up until here we did not modify the container, besides the lock
 	    $remove_lock = 0;
-- 
2.30.2





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-11-17 12:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-17  9:39 [pve-devel] [PATCH container 1/2] fix: clean up config when invalid ostemplate is given Daniel Tschlatscher
2022-11-17  9:39 ` [pve-devel] [PATCH container 2/2] fix: also remove firewall config after failed restore Daniel Tschlatscher
2022-11-17 12:45 ` [pve-devel] [PATCH container 1/2] fix: clean up config when invalid ostemplate is given Thomas Lamprecht

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal