public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Thomas Lamprecht <t.lamprecht@proxmox.com>
To: "Proxmox VE development discussion" <pve-devel@lists.proxmox.com>,
	"Dominic Jäger" <d.jaeger@proxmox.com>
Subject: Re: [pve-devel] [PATCH storage] lvmthin: Match snapshot remove regex to allowed names
Date: Tue, 27 Oct 2020 13:18:15 +0100	[thread overview]
Message-ID: <36ff14ea-46b5-be9f-d2ff-6080b41abc5c@proxmox.com> (raw)
In-Reply-To: <20201027101207.73749-1-d.jaeger@proxmox.com>

On 27.10.20 11:12, Dominic Jäger wrote:
> We allow snapshot names that match pve-configid but during qm destroy we have
> not removed all snapshots that match pve-configid so far. For example, the name
> x-y was allowed but the resulting snap_vm-105-disk-0_x-y was not removed.
> 
> Reported-by: Hannes Laimer <h.laimer@proxmox.com>
> Signed-off-by: Dominic Jäger <d.jaeger@proxmox.com>
> ---
> Something like m/^snap_${volname}_${configidre}$/ would maybe be nicer, but I
> didn't see how to get that RE from JSONSchema in a shorter way than that single
> function call.
> 

hmm, I'd either:

* move that regex to an `our $PROXMOX_CONFID_RE = ...` variable (or a method which
  returns it

* copy over that regex to here, could be just fine here

but I'd like to avoid using a capture group just to pass it a method which then
regex checks it again.

>  PVE/Storage/LvmThinPlugin.pm | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/PVE/Storage/LvmThinPlugin.pm b/PVE/Storage/LvmThinPlugin.pm
> index d1c5b1f..4af57be 100644
> --- a/PVE/Storage/LvmThinPlugin.pm
> +++ b/PVE/Storage/LvmThinPlugin.pm
> @@ -117,7 +117,8 @@ sub free_image {
>  
>  	# remove all volume snapshots first
>  	foreach my $lv (keys %$dat) {
> -	    next if $lv !~ m/^snap_${volname}_(\w+)$/;
> +	    next if $lv !~ m/^snap_${volname}_(.+)$/;
> +	    next if !PVE::JSONSchema::pve_verify_configid($1, 1);
>  	    my $cmd = ['/sbin/lvremove', '-f', "$vg/$lv"];
>  	    run_command($cmd, errmsg => "lvremove snapshot '$vg/$lv' error");
>  	}
> 






      reply	other threads:[~2020-10-27 12:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-27 10:12 Dominic Jäger
2020-10-27 12:18 ` Thomas Lamprecht [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=36ff14ea-46b5-be9f-d2ff-6080b41abc5c@proxmox.com \
    --to=t.lamprecht@proxmox.com \
    --cc=d.jaeger@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
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal