[pve-devel] [PATCH storage] lvm: avoid warning due to human-readable text in vgs output

Fabian Grünbichler f.gruenbichler at proxmox.com
Fri Jan 12 10:22:14 CET 2024


On January 11, 2024 5:58 pm, Friedrich Weber wrote:
> If the metadata archive under /etc/lvm/archive for a particular VG has
> a lot of files or is overly large, `vgs` occasionally prints a message
> to stdout [1]. The LVM plugin tries to parse this message and thus
> produces the following confusing warnings in the output of `pvesm
> status` or the journal (via pvestatd):
> 
> Use of uninitialized value $size in int at [...]/LVMPlugin.pm line 133
> Use of uninitialized value $free in int at [...]/LVMPlugin.pm line 133
> Use of uninitialized value $lvcount in int [...]/LVMPlugin.pm line 133
> 
> Reported in enterprise support where LVM picked up on VGs on VM disks
> (due to a missing KRBD device filter in the LVM config), and since
> several VM disks had VGs with the same name, LVM quickly produced a
> lot of files in /etc/lvm/archive.
> 
> Reproducible as follows with a VG named `spam`:
> 
>     for i in $(seq 8192);
>     do vgrename spam spam2; vgrename spam2 spam; done
>     rm /etc/lvm/backup/spam; vgs -o vg_name
> 
> Output (linebreak for readability):
> 
>     Consider pruning spam VG archive with more then 8 MiB in 8268\n
>     files (check archiving is needed in lvm.conf).
>     VG
>     spam
> 
> [1] https://sourceware.org/git/?p=lvm2.git;a=blob;f=lib/format_text/archive.c;h=5acf0c04a;hb=38e0c7a1#l222
> 
> Signed-off-by: Friedrich Weber <f.weber at proxmox.com>
> ---
>  src/PVE/Storage/LVMPlugin.pm | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/src/PVE/Storage/LVMPlugin.pm b/src/PVE/Storage/LVMPlugin.pm
> index 4b951e7..557d602 100644
> --- a/src/PVE/Storage/LVMPlugin.pm
> +++ b/src/PVE/Storage/LVMPlugin.pm
> @@ -130,6 +130,9 @@ sub lvm_vgs {
>  
>  	    my ($name, $size, $free, $lvcount, $pvname, $pvsize, $pvfree) = split (':', $line);
>  
> +	    # skip human-readable messages that vgs occasionally prints to stdout
> +	    return if !defined($size);
> +

we might want to either log this message (like anything printed to
STDERR), so that the admin at least can notice something weird is going
on, or pass '-qq' to switch `vgs` into silent mode where no such
messages will be printed - although for the latter variant we might want
to check what (else) gets suppressed ("log_print_unless_silent")..

AFAICT this message only gets printed if the archives grew very big, and
the backup file does not exist? at least for me using your reproducer,
it's only printed once, and I have to rename rename rm again afterwards
to get it to show up again, which would mean it's not too bad to log it
(as long as it doesn't confuse our code).

the `lvmscan` endpoint also picks up the line btw, which means it ends
up being included in the "VG" selector on the web UI when adding an LVM
storage ;)

>  	    $vgs->{$name} //= {
>  		size => int ($size),
>  		free => int ($free),
> -- 
> 2.39.2
> 
> 
> 
> _______________________________________________
> pve-devel mailing list
> pve-devel at lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
> 
> 
> 




More information about the pve-devel mailing list