all lists on 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>,
	Maximiliano Sandoval <m.sandoval@proxmox.com>
Subject: [pve-devel] applied: [PATCH storage] base plugin: do not decode the empty string
Date: Fri, 6 Sep 2024 19:09:44 +0200	[thread overview]
Message-ID: <7e3c9f92-f5a1-4017-a97f-d084befa7ee3@proxmox.com> (raw)
In-Reply-To: <20240902124745.77160-1-m.sandoval@proxmox.com>

Am 02/09/2024 um 14:47 schrieb Maximiliano Sandoval:
> If the json was empty, for example if the qemu-img command times out, a
> message
> 
>     warn "could not parse qemu-img info command output for '$filename' - $err\n";
> 
> would have been printed.
> 
> This message could lead one to think the issue lies in the contents of
> the json, even if the previous warning said that there was a timeout.
> 
> Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
> ---
>  src/PVE/Storage/Plugin.pm | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/src/PVE/Storage/Plugin.pm b/src/PVE/Storage/Plugin.pm
> index 6444390f..8cc693c7 100644
> --- a/src/PVE/Storage/Plugin.pm
> +++ b/src/PVE/Storage/Plugin.pm
> @@ -974,6 +974,10 @@ sub file_size_info {
>  	# otherwise we warn about it and try to parse the json
>  	warn $err_output;
>      }
> +    if (!$json) {
> +	# skip decoding if there was no output, e.g. if there was a timeout.
> +	return wantarray ? (undef, undef, undef, undef, $st->ctime) : undef;
> +    }
>  

FWIW, one could have avoided a tiny bit of duplication (trading against being
explicit) by changing the call to warn in the error path to something like:

warn "..." if !!$json;

but OTOH trying to parse json when one knows that it cannot work makes no sense
either, so your variant is probably better...

applied, thanks!


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


  reply	other threads:[~2024-09-06 17:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-02 12:47 [pve-devel] " Maximiliano Sandoval
2024-09-06 17:09 ` Thomas Lamprecht [this message]
2024-09-10  9:52 ` Fiona Ebner

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=7e3c9f92-f5a1-4017-a97f-d084befa7ee3@proxmox.com \
    --to=t.lamprecht@proxmox.com \
    --cc=m.sandoval@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal