From: Wolfgang Bumiller <w.bumiller@proxmox.com>
To: Dominik Csapak <d.csapak@proxmox.com>
Cc: pve-devel@lists.proxmox.com
Subject: [pve-devel] applied: [PATCH container] move_volume: call deactivate volume for the old volid in any case
Date: Tue, 14 Jun 2022 11:43:56 +0200 [thread overview]
Message-ID: <20220614094356.ek67cuooj5gbmwss@casey.proxmox.com> (raw)
In-Reply-To: <20220504081502.810023-1-d.csapak@proxmox.com>
applied, thanks
On Wed, May 04, 2022 at 10:15:02AM +0200, Dominik Csapak wrote:
> not only when we want to remove it. Otherwise, if the old volume is
> mapped (e.g. ceph krbd), we don't unmap it when we're finished.
>
> We have to save if we deactivated successfully before attempting to
> remove it. If it was not removed (either because we could not
> deactivate, or the remove failed), we add it back as unused.
>
> Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
> ---
> src/PVE/API2/LXC.pm | 22 ++++++++++++++++------
> 1 file changed, 16 insertions(+), 6 deletions(-)
>
> diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm
> index 64724cb..e909cb0 100644
> --- a/src/PVE/API2/LXC.pm
> +++ b/src/PVE/API2/LXC.pm
> @@ -2043,13 +2043,23 @@ __PACKAGE__->register_method({
> die $err;
> }
>
> + my $deactivated = 0;
> + eval {
> + PVE::Storage::deactivate_volumes($storage_cfg, [ $old_volid ]);
> + $deactivated = 1;
> + };
> + warn $@ if $@;
> +
> if ($param->{delete}) {
> - eval {
> - PVE::Storage::deactivate_volumes($storage_cfg, [ $old_volid ]);
> - PVE::Storage::vdisk_free($storage_cfg, $old_volid);
> - };
> - if (my $err = $@) {
> - warn $err;
> + my $removed = 0;
> + if ($deactivated) {
> + eval {
> + PVE::Storage::vdisk_free($storage_cfg, $old_volid);
> + $removed = 1;
> + };
> + warn $@ if $@;
> + }
> + if (!$removed) {
> PVE::LXC::Config->lock_config($vmid, sub {
> my $conf = PVE::LXC::Config->load_config($vmid);
> PVE::LXC::Config->add_unused_volume($conf, $old_volid);
> --
> 2.30.2
prev parent reply other threads:[~2022-06-14 9:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-04 8:15 [pve-devel] " Dominik Csapak
2022-06-14 9:43 ` Wolfgang Bumiller [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220614094356.ek67cuooj5gbmwss@casey.proxmox.com \
--to=w.bumiller@proxmox.com \
--cc=d.csapak@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox