[pve-devel] [PATCH container v2] api: record CT ID as used after a container is destroyed

Aaron Lauterer a.lauterer at proxmox.com
Thu Oct 31 18:27:43 CET 2024


This is missing a

use PVE::UsedVmidList;

at the top of the file. Otherwise running

pct destroy {vmid}

will result in the following error:

Undefined subroutine &PVE::UsedVmidList::add_vmid called at 
/usr/share/perl5/PVE/API2/LXC.pm line 799.

This doesn't seem to be necessary in the qemu-server repo, but I did not 
investigate further how pulling in dependencies works there.


On  2024-10-04  07:07, Severen Redwood wrote:
> After a container is destroyed, record that its ID has been used via the
> `PVE::UsedVmidList` module so that the `/cluster/nextids` endpoint can
> later optionally avoid suggesting previously used IDs.
> 
> Co-authored-by: Daniel Krambrock <krambrock at hrz.uni-marburg.de>
> Signed-off-by: Severen Redwood <severen.redwood at sitehost.co.nz>
> ---
>   src/PVE/API2/LXC.pm | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm
> index 918e719..ee0e3e9 100644
> --- a/src/PVE/API2/LXC.pm
> +++ b/src/PVE/API2/LXC.pm
> @@ -794,7 +794,9 @@ __PACKAGE__->register_method({
>   		}
>   	    }
>   
> -	    # only now remove the zombie config, else we can have reuse race
> +	    # only now mark the CT ID as previously used and remove the zombie
> +	    # config, else we can have reuse race
> +	    PVE::UsedVmidList::add_vmid($vmid);
>   	    PVE::LXC::Config->destroy_config($vmid);
>   	};
>   





More information about the pve-devel mailing list