]> git.proxmox.com Git - pve-container.git/commitdiff
destroy_config: die if unlink fails
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 28 Jan 2019 07:06:47 +0000 (08:06 +0100)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Tue, 29 Jan 2019 10:36:10 +0000 (11:36 +0100)
We use this in two places, in the cleanup path of the create/restore
API path and indirectly through PVE::LXC::destroy_lxc_container, once
again in the restore code path of the create API call, to cleanup a
CT before overwriting it with a backup if the force flag ist set. The
second time in the destroy CT API call, both times a hard error in a
erroneous cleanup is wanted.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/PVE/API2/LXC.pm
src/PVE/LXC.pm

index 2ab98da776ad1e875aceaf3bc75a167c57683c63..d0e82ee0799668391981546d9a5ab0abea0a2037 100644 (file)
@@ -430,7 +430,8 @@ __PACKAGE__->register_method({
            };
            if (my $err = $@) {
                PVE::LXC::destroy_disks($storage_cfg, $vollist);
-               PVE::LXC::destroy_config($vmid);
+               eval { PVE::LXC::destroy_config($vmid) };
+               warn $@ if $@;
                die $err;
            }
            PVE::AccessControl::add_vm_to_pool($vmid, $pool) if $pool;
index ab15ec09fb3a3fb1e859cb705375ef4bb42b279a..450a4e55ffa81c77d72513d66e905033ba16a0fe 100644 (file)
@@ -54,7 +54,8 @@ sub config_list {
 sub destroy_config {
     my ($vmid) = @_;
 
-    unlink PVE::LXC::Config->config_file($vmid, $nodename);
+    my $config_fn = PVE::LXC::Config->config_file($vmid, $nodename);
+    unlink $config_fn or die "failed to remove config file: $!\n";
 }
 
 # container status helpers