public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Daniel Tschlatscher <d.tschlatscher@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH container 1/2] fix: clean up config when invalid ostemplate is given
Date: Thu, 17 Nov 2022 10:39:31 +0100	[thread overview]
Message-ID: <20221117093932.343751-1-d.tschlatscher@proxmox.com> (raw)

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





             reply	other threads:[~2022-11-17  9:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-17  9:39 Daniel Tschlatscher [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221117093932.343751-1-d.tschlatscher@proxmox.com \
    --to=d.tschlatscher@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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