[pve-devel] [PATCH v4 pve-container 30/33] vm_clone : create ips in ipams

Stefan Hanreich s.hanreich at proxmox.com
Fri Nov 17 12:40:08 CET 2023


From: Alexandre Derumier <aderumier at odiso.com>

also delete ips in case of failure

Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 src/PVE/API2/LXC.pm | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm
index e15de28..ee4fdca 100644
--- a/src/PVE/API2/LXC.pm
+++ b/src/PVE/API2/LXC.pm
@@ -1830,7 +1830,9 @@ __PACKAGE__->register_method({
 		$lock_and_reload->($newid, sub {
 		    my $conf = shift;
 		    my $rootdir = PVE::LXC::mount_all($newid, $storecfg, $conf, 1);
+
 		    eval {
+			PVE::LXC::create_ifaces_ipams_ips($conf, $vmid);
 			my $lxc_setup = PVE::LXC::Setup->new($conf, $rootdir);
 			$lxc_setup->post_clone_hook($conf);
 		    };
@@ -1850,7 +1852,7 @@ __PACKAGE__->register_method({
 	    warn $@ if $@;
 
 	    if ($err) {
-		# Now cleanup the config & disks:
+		# Now cleanup the config & disks & ipam:
 		sleep 1; # some storages like rbd need to wait before release volume - really?
 
 		foreach my $volid (@$newvollist) {
@@ -1860,6 +1862,8 @@ __PACKAGE__->register_method({
 
 		eval {
 		    $lock_and_reload->($newid, sub {
+			my $conf = shift;
+			PVE::LXC::delete_ifaces_ipams_ips($conf, $newid);
 			PVE::LXC::Config->destroy_config($newid);
 			PVE::Firewall::remove_vmfw_conf($newid);
 		    });
-- 
2.39.2





More information about the pve-devel mailing list