[pve-devel] [PATCH pve-container 4/6] vm_clone : create ips in ipams
Alexandre Derumier
aderumier at odiso.com
Wed Nov 15 15:22:04 CET 2023
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 ccacbd2..f18d23b 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