and wrap the calls in an eval to preserve original errors causing us to
remove the config in the first place..
also, remove disks before removing the locked config (reverse order of
creation).
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
PVE::Cluster::check_cfs_quorum();
PVE::Cluster::check_cfs_quorum();
my $newconf = {};
my $mountpoints = {};
my $fullclone = {};
my $newconf = {};
my $mountpoints = {};
my $fullclone = {};
my $running;
PVE::LXC::Config->create_and_lock_config($newid, 0);
my $running;
PVE::LXC::Config->create_and_lock_config($newid, 0);
- $conffile = PVE::LXC::Config->config_file($newid);
PVE::LXC::Config->lock_config($vmid, sub {
my $src_conf = PVE::LXC::Config->set_lock($vmid, 'disk');
PVE::LXC::Config->lock_config($vmid, sub {
my $src_conf = PVE::LXC::Config->set_lock($vmid, 'disk');
};
if (my $err = $@) {
eval { PVE::LXC::Config->remove_lock($vmid, 'disk') };
};
if (my $err = $@) {
eval { PVE::LXC::Config->remove_lock($vmid, 'disk') };
- PVE::LXC::Config->lock_config($newid, sub {
- my $conf = PVE::LXC::Config->load_config($newid);
- die "Lost 'create' config lock, aborting.\n"
- if !PVE::LXC::Config->has_lock($conf, 'create');
- unlink($conffile);
- });
- warn $@ if $@;
+ warn "Failed to remove source CT config lock - $@\n" if $@;
+
+ eval {
+ PVE::LXC::Config->lock_config($newid, sub {
+ my $conf = PVE::LXC::Config->load_config($newid);
+ die "Lost 'create' config lock, aborting.\n"
+ if !PVE::LXC::Config->has_lock($conf, 'create');
+ PVE::LXC::Config->destroy_config($newid);
+ });
+ };
+ warn "Failed to remove target CT config - $@\n" if $@;
+
if ($err) {
# Now cleanup the config & disks:
if ($err) {
# Now cleanup the config & disks:
sleep 1; # some storages like rbd need to wait before release volume - really?
foreach my $volid (@$newvollist) {
eval { PVE::Storage::vdisk_free($storecfg, $volid); };
warn $@ if $@;
}
sleep 1; # some storages like rbd need to wait before release volume - really?
foreach my $volid (@$newvollist) {
eval { PVE::Storage::vdisk_free($storecfg, $volid); };
warn $@ if $@;
}
+
+ eval {
+ PVE::LXC::Config->lock_config($newid, sub {
+ my $conf = PVE::LXC::Config->load_config($newid);
+ die "Lost 'create' config lock, aborting.\n"
+ if !PVE::LXC::Config->has_lock($conf, 'create');
+ PVE::LXC::Config->destroy_config($newid);
+ });
+ };
+ warn "Failed to remove target CT config - $@\n" if $@;
+
die "clone failed: $err";
}
die "clone failed: $err";
}