--- Begin Message ---
Hi Fabian,

> =
> +     $plugin->parse_volname($volname);
> + $plugin->free_image($snap_storeid, $scfg, $snap_volname,
> $snap_isBase, $snap_format);
> +     }
> +     $plugin->free_image($storeid, $scfg, $volname, $isBase,
> $format);

>>this is the wrong place to do this, you need to handle this in the
>>cleanup worker returned by the plugin and still execute it here..
>>also you need to honor saferemove when cleaning up the snapshots

ok. 
currently, I'm deleting the snapshots in reverse before the main image,
as I'm reading snasphot chain from the image. But maybe it could be
better to scan the files/image directly based on the snap names ? (if
the chain is broken for example). as anyway we want to delete all
snapshot here.



> + };
>  
> +my $rpcenv_module;
> +$rpcenv_module = Test::MockModule->new('PVE::RPCEnvironment');
> +$rpcenv_module->mock(
> +    get_user => sub {
> +        return 'root@pam';
> +    },
> +    fork_worker => sub {
> + my ($self, $dtype, $id, $user, $function, $background) = @_;
> + $function->(123456);
> + return '123456';
> +    }
> +);
> +
> +my $rpcenv = PVE::RPCEnvironment->init('pub');
> +

>>what? why? no explanation?

About this, the current vdisk_free code is

"
$plugin->cluster_lock_storage($storeid, $scfg->{shared}, undef, sub {
   ....
        $cleanup_worker = $plugin->free_image($storeid, $scfg,
$volname, $isBase, $format);
}

return if !$cleanup_worker;

my $rpcenv = PVE::RPCEnvironment::get();
my $authuser = $rpcenv->get_user();

$rpcenv->fork_worker('imgdel', undef, $authuser, $cleanup_worker);
"


but, if I look in different plugins, free_image always return undef.
(so with my change, the code was going to the rpcenv..., and the zfs
test was failing)

So, maybe I miss something, but does it work ?




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

Reply via email to