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.we...@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 via email to