public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH storage] base plugin: do not decode the empty string
@ 2024-09-02 12:47 Maximiliano Sandoval
  2024-09-06 17:09 ` [pve-devel] applied: " Thomas Lamprecht
  2024-09-10  9:52 ` [pve-devel] " Fiona Ebner
  0 siblings, 2 replies; 3+ messages in thread
From: Maximiliano Sandoval @ 2024-09-02 12:47 UTC (permalink / raw)
  To: pve-devel

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;
+    }
 
     my $info = eval { decode_json($json) };
     if (my $err = $@) {
-- 
2.39.2



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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [pve-devel] applied: [PATCH storage] base plugin: do not decode the empty string
  2024-09-02 12:47 [pve-devel] [PATCH storage] base plugin: do not decode the empty string Maximiliano Sandoval
@ 2024-09-06 17:09 ` Thomas Lamprecht
  2024-09-10  9:52 ` [pve-devel] " Fiona Ebner
  1 sibling, 0 replies; 3+ messages in thread
From: Thomas Lamprecht @ 2024-09-06 17:09 UTC (permalink / raw)
  To: Proxmox VE development discussion, Maximiliano Sandoval

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [pve-devel] [PATCH storage] base plugin: do not decode the empty string
  2024-09-02 12:47 [pve-devel] [PATCH storage] base plugin: do not decode the empty string Maximiliano Sandoval
  2024-09-06 17:09 ` [pve-devel] applied: " Thomas Lamprecht
@ 2024-09-10  9:52 ` Fiona Ebner
  1 sibling, 0 replies; 3+ messages in thread
From: Fiona Ebner @ 2024-09-10  9:52 UTC (permalink / raw)
  To: Proxmox VE development discussion, Maximiliano Sandoval

Am 02.09.24 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.
> 

I know it's already applied, so mentioning it for the future: the commit
title (and actually also message) really should've included the context,
e.g. "when querying file size".


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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-09-10  9:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-02 12:47 [pve-devel] [PATCH storage] base plugin: do not decode the empty string Maximiliano Sandoval
2024-09-06 17:09 ` [pve-devel] applied: " Thomas Lamprecht
2024-09-10  9:52 ` [pve-devel] " Fiona Ebner

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