From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 9103B91163 for ; Wed, 7 Sep 2022 11:06:11 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 592C32FE87 for ; Wed, 7 Sep 2022 11:06:11 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Wed, 7 Sep 2022 11:06:10 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id DB1DA43F02; Wed, 7 Sep 2022 10:58:30 +0200 (CEST) From: Daniel Tschlatscher To: pve-devel@lists.proxmox.com, pbs-devel@lists.proxmox.com, pmg-devel@lists.proxmox.com Date: Wed, 7 Sep 2022 10:56:30 +0200 Message-Id: <20220907085633.89113-5-d.tschlatscher@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220907085633.89113-1-d.tschlatscher@proxmox.com> References: <20220907085633.89113-1-d.tschlatscher@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.067 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pmg-devel] [PATCH manager v2 4/7] revised task log API call for PVE X-BeenThere: pmg-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Mail Gateway development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Sep 2022 09:06:11 -0000 The API call for fetching a tasklog with limit=0 now returns the whole log as a file stream rather than reading all lines in memory and then transfering them in JSON format. The behaviour when the url parameter limit is undefined or not 0 is the same as before, in accordance with the API specification. Signed-off-by: Daniel Tschlatscher --- PVE/API2/Tasks.pm | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/PVE/API2/Tasks.pm b/PVE/API2/Tasks.pm index 9cd1e56b..88762f2f 100644 --- a/PVE/API2/Tasks.pm +++ b/PVE/API2/Tasks.pm @@ -5,6 +5,7 @@ use warnings; use POSIX; use IO::File; use File::ReadBackwards; +use File::stat; use PVE::Tools; use PVE::SafeSyslog; use PVE::RESTHandler; @@ -387,11 +388,17 @@ __PACKAGE__->register_method({ $rpcenv->check($user, "/nodes/$node", [ 'Sys.Audit' ]); } - my ($count, $lines) = PVE::Tools::dump_logfile($filename, $start, $limit); + if ($limit == 0) { + # TCP Max Transfer Unit size is 1500, compression for lower numbers has no effect + my $use_compression = stat($filename)->size > 1500; + return PVE::Tools::stream_file($filename, $param->{upid}, $use_compression); + } else { + my ($count, $lines) = PVE::Tools::dump_logfile($filename, $start, $limit); - $rpcenv->set_result_attrib('total', $count); + $rpcenv->set_result_attrib('total', $count); - return $lines; + return $lines; + } }}); -- 2.30.2