public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Friedrich Weber <f.weber@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH common] tools: dump logfile: fix result type in case the file cannot be opened
Date: Thu, 17 Jul 2025 18:50:01 +0200	[thread overview]
Message-ID: <20250717165006.106126-1-f.weber@proxmox.com> (raw)

The second return value of dump_logfile should be a reference to an
array of hash references (one per log line), but in case the file
cannot be opened, it currently directly returns a reference to a hash.

As a result, the /nodes/{node}/tasks/{upid}/log endpoint response does
not match the schema in case the task log cannot be opened (for
example, does not exist). This was reported in enterprise support, as
it trips up external monitoring tools that query this endpoint.

To fix this, make sure to return an array.

This technically also affects the endpoints that query the Ceph,
replication, and firewall logs, though there it is more likely that
the logfile actually exists and can be opened.

Signed-off-by: Friedrich Weber <f.weber@proxmox.com>
---

Notes:
    proxmox-perltidy makes a small formatting change (to pre-existing code
    in Tools.pm) that I didn't include here.

 src/PVE/Tools.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/PVE/Tools.pm b/src/PVE/Tools.pm
index 948ef5e..fe9616e 100644
--- a/src/PVE/Tools.pm
+++ b/src/PVE/Tools.pm
@@ -1426,7 +1426,7 @@ sub dump_logfile {
 
     my $fh = IO::File->new($filename, "r");
     if (!$fh) {
-        return (1, { n => 1, t => "unable to open file - $!" });
+        return (1, [{ n => 1, t => "unable to open file - $!" }]);
     }
 
     my %state = (
-- 
2.47.2



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


             reply	other threads:[~2025-07-17 16:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-17 16:50 Friedrich Weber [this message]
2025-07-17 19:27 ` [pve-devel] applied: " Thomas Lamprecht

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=20250717165006.106126-1-f.weber@proxmox.com \
    --to=f.weber@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