public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH common] tools: dump logfile: fix result type in case the file cannot be opened
@ 2025-07-17 16:50 Friedrich Weber
  2025-07-17 19:27 ` [pve-devel] applied: " Thomas Lamprecht
  0 siblings, 1 reply; 2+ messages in thread
From: Friedrich Weber @ 2025-07-17 16:50 UTC (permalink / raw)
  To: pve-devel

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


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

* [pve-devel] applied: [PATCH common] tools: dump logfile: fix result type in case the file cannot be opened
  2025-07-17 16:50 [pve-devel] [PATCH common] tools: dump logfile: fix result type in case the file cannot be opened Friedrich Weber
@ 2025-07-17 19:27 ` Thomas Lamprecht
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Lamprecht @ 2025-07-17 19:27 UTC (permalink / raw)
  To: pve-devel, Friedrich Weber

On Thu, 17 Jul 2025 18:50:01 +0200, Friedrich Weber wrote:
> 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.
> 
> [...]

Applied, thanks!

[1/1] tools: dump logfile: fix result type in case the file cannot be opened
      (no commit info)


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


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

end of thread, other threads:[~2025-07-17 19:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-07-17 16:50 [pve-devel] [PATCH common] tools: dump logfile: fix result type in case the file cannot be opened Friedrich Weber
2025-07-17 19:27 ` [pve-devel] applied: " Thomas Lamprecht

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