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> --- 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 { + 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 $@; + die "base volume '$volid' is still in use by linked clone\n" if $result; + }); + } + my $remove_volume = sub { my ($ms, $mountpoint) = @_; -- 2.39.5 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel