Nit: destroy template: add early check for linked clones of volumes Am 20.05.25 um 11:08 schrieb Michael Köppl: > This behavior matches the behavior already implemented for VMs and > prevents partial storage deletion if a container template has a linked > clone. In such cases, the destruction of the container template will > now fail, informing the user that the base volume is still in use by > the linked clone. > > Originally-by: Stefan Hrdlicka <s.hrdli...@proxmox.com> > Signed-off-by: Michael Köppl <m.koe...@proxmox.com>
With the comments addressed, consider this: Reviewed-by: Fiona Ebner <f.eb...@proxmox.com> > --- > src/PVE/LXC.pm | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > > diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm > index 6a1ce92..7bc566a 100644 > --- a/src/PVE/LXC.pm > +++ b/src/PVE/LXC.pm > @@ -945,6 +945,18 @@ sub destroy_lxc_container { > my ($storage_cfg, $vmid, $conf, $replacement_conf, $purge_unreferenced) > = @_; > > my $volids = {}; > + > + if ($conf->{template}) { > + PVE::LXC::Config->foreach_volume_full($conf, {include_unused => 1}, sub > { Style nit: usually, spaces are used after/before the curly braces for such in-line hashes like: { include_unused => 1 } > + my ($ms, $mountpoint) = @_; > + my $volid = $mountpoint->{volume}; > + return if !$volid || PVE::LXC::Config->classify_mountpoint($volid) > ne 'volume'; > + my $result = eval { > PVE::Storage::volume_is_base_and_used($storage_cfg, $volid) }; > + die "failed to delete volume '$volid': $@\n" if $@; s/failed to delete/failed to check for linked clones of/ No need for "\n" at the end, we expect $@ to already contain it. > + die "base volume '$volid' is still in use by linked clone\n" if > $result; > + }); > + } > + > my $remove_volume = sub { > my ($ms, $mountpoint) = @_; > _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel