[pve-devel] [PATCH container] api: record CT ID as used after a container is destroyed
Thomas Lamprecht
t.lamprecht at proxmox.com
Thu Sep 26 19:48:20 CEST 2024
Am 26/09/2024 um 15:52 schrieb Severen Redwood:
> 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 | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm
> index 918e719..c4cc427 100644
> --- a/src/PVE/API2/LXC.pm
> +++ b/src/PVE/API2/LXC.pm
> @@ -800,6 +800,7 @@ __PACKAGE__->register_method({
>
> my $realcmd = sub { PVE::LXC::Config->lock_config($vmid, $code); };
>
> + PVE::UsedVmidList::add_vmid($vmid);
at this point the CT is not yet destroyed, only the worker that tries to destroy
it is started, destruction can still fail.
It'd be better to place it inside the $realcmd, or even the $code, ideally
before the actual unlink of the vmid.conf file, as after that happens the
ID gets free again from the POV of the pmxcfs and thus pve-cluster's VMID
list that is used by the next-id call.
> return $rpcenv->fork_worker('vzdestroy', $vmid, $authuser, $realcmd);
> }});
>
More information about the pve-devel
mailing list