From nobody Sun Dec 22 05:05:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=patchew-devel-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1548314894869857.768364480603; Wed, 23 Jan 2019 23:28:14 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9D8697BDCA; Thu, 24 Jan 2019 07:28:13 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8E2041001F4A; Thu, 24 Jan 2019 07:28:13 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 801583F7CD; Thu, 24 Jan 2019 07:28:13 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x0O7SClo024279 for ; Thu, 24 Jan 2019 02:28:12 -0500 Received: by smtp.corp.redhat.com (Postfix) id C78456013C; Thu, 24 Jan 2019 07:28:12 +0000 (UTC) Received: from donizetti.redhat.com (ovpn-112-33.ams2.redhat.com [10.36.112.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0D74660464 for ; Thu, 24 Jan 2019 07:28:11 +0000 (UTC) From: Paolo Bonzini To: patchew-devel@redhat.com Date: Thu, 24 Jan 2019 08:28:04 +0100 Message-Id: <20190124072804.9622-3-pbonzini@redhat.com> In-Reply-To: <20190124072804.9622-1-pbonzini@redhat.com> References: <20190124072804.9622-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: patchew-devel@redhat.com Subject: [Patchew-devel] [PATCH] patchew-tester: truncate logs if they are too large X-BeenThere: patchew-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Patchew development and discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: patchew-devel-bounces@redhat.com Errors-To: patchew-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 24 Jan 2019 07:28:13 +0000 (UTC) Content-Type: text/plain; charset="utf-8" If the logs are too large for the server, the tester loops forever on the s= ame test. Instead, trap 413 errors (request entity too large) and truncate the log to= a smaller amount of data. Signed-off-by: Paolo Bonzini --- patchew-cli | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/patchew-cli b/patchew-cli index 430dbe3..b2d0bbb 100755 --- a/patchew-cli +++ b/patchew-cli @@ -577,15 +577,32 @@ class TesterCommand(SubCommand): log =3D "N/A. Internal error while reading log file\n" print(" Result:", "Passed" if passed else "Failed") logging.debug(log) - self.api_do("testing-report", project=3Dr["project"], - identity=3Dr["identity"], - test=3Dr["test"]["name"], - tester=3Dname, - head=3Dr["head"], - base=3Dr["base"], - passed=3Dpassed, - log=3Dlog, - is_timeout=3Dis_timeout) + max_size =3D 100000000 + prefixed =3D False + orig_log_size =3D len(log) + while max_size > 100000: + try: + self.api_do("testing-report", project=3Dr["project= "], + identity=3Dr["identi= ty"], + test=3Dr["test"]["na= me"], + tester=3Dname, + head=3Dr["head"], + base=3Dr["base"], + passed=3Dpassed, + log=3Dlog, + is_timeout=3Dis_time= out) + except error.HTTPError as e: + if e.code !=3D 413: + raise e + if not prefixed: + prefixed =3D True + log =3D 'WARNING: Log truncated!\n\n' + log + log =3D log[:max_size] + max_size =3D max_size / 10 + else: + break + if prefixed: + print("Log truncated from %d to %d bytes" % {orig_log_= size, len(log)}) logf.close() finally: if not no_clean_up: --=20 2.20.1 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel