On 10/15/19 1:00 PM, Christian Ebner wrote:
> When destroying a CT, we intentionally did not remove all related configs 
> such as
> backup or replication jobs.
> The intention of this flag is to allow the removal of such configs on destroy.
> 
> Signed-off-by: Christian Ebner <c.eb...@proxmox.com>
> ---
> version 4:
>     * no changes since v3
> 


applied, but ammended in the merge-conflict resolving changes (this got
touched by me recently) and...

>  src/PVE/API2/LXC.pm | 17 ++++++++++++++---
>  1 file changed, 14 insertions(+), 3 deletions(-)
> 
> diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm
> index 28c9047..5c22060 100644
> --- a/src/PVE/API2/LXC.pm
> +++ b/src/PVE/API2/LXC.pm
> @@ -18,6 +18,7 @@ use PVE::LXC;
>  use PVE::LXC::Create;
>  use PVE::LXC::Migrate;
>  use PVE::GuestHelpers;
> +use PVE::VZDump::Plugin;
>  use PVE::API2::LXC::Config;
>  use PVE::API2::LXC::Status;
>  use PVE::API2::LXC::Snapshot;
> @@ -636,6 +637,11 @@ __PACKAGE__->register_method({
>       properties => {
>           node => get_standard_option('pve-node'),
>           vmid => get_standard_option('pve-vmid', { completion => 
> \&PVE::LXC::complete_ctid_stopped }),
> +         purge => {
> +             type => 'boolean',
> +             description => "Remove vmid from backup cron jobs.",
> +             optional => 1,
> +         },
>       },
>      },
>      returns => {
> @@ -656,9 +662,13 @@ __PACKAGE__->register_method({
>       die "unable to remove CT $vmid - used in HA resources\n"
>           if PVE::HA::Config::vm_is_ha_managed($vmid);
>  
> -     # do not allow destroy if there are replication jobs
> -     my $repl_conf = PVE::ReplicationConfig->new();
> -     $repl_conf->check_for_existing_jobs($vmid);
> +     if ($param->{purge}) {
> +         PVE::ReplicationConfig::remove_vmid_jobs($vmid);

... moved this inside the locked context below, thanks!

> +     } else {
> +         # do not allow destroy if there are replication jobs
> +         my $repl_conf = PVE::ReplicationConfig->new();
> +         $repl_conf->check_for_existing_jobs($vmid);
> +     }
>  
>       my $running_error_msg = "unable to destroy CT $vmid - container is 
> running\n";
>  
> @@ -674,6 +684,7 @@ __PACKAGE__->register_method({
>           PVE::LXC::destroy_lxc_container($storage_cfg, $vmid, $conf);
>           PVE::AccessControl::remove_vm_access($vmid);
>           PVE::Firewall::remove_vmfw_conf($vmid);
> +         PVE::VZDump::Plugin::remove_vmid_from_backup_jobs($vmid) if 
> ($param->{purge});
>       };
>  
>       my $realcmd = sub { PVE::LXC::Config->lock_config($vmid, $code); };
> 


_______________________________________________
pve-devel mailing list
pve-devel@pve.proxmox.com
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to