From 2d77252c28d65277612a175437b0caed2c297ff4 Mon Sep 17 00:00:00 2001
From: Marcelo Vogel <mavogel@cern.ch>
Date: Thu, 20 Apr 2017 13:10:56 +0200
Subject: [PATCH] Added a limit to the number of detail messages in the job
 report from G4Exceptions (ATLASJT-357)

G4 exceptions can be fatal, therefore, even warnings associated to them are added to the job
report. However, there was no limit on the number of messages that could be added. This has led
to grid tasks producing job report files with over 8MB. The fixes included in this branch place
a limit on the number of messages that can be included in the job report from G4 exceptions.
---
 Tools/PyJobTransforms/python/trfValidation.py | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/Tools/PyJobTransforms/python/trfValidation.py b/Tools/PyJobTransforms/python/trfValidation.py
index f79b01474056..36131827fa7f 100644
--- a/Tools/PyJobTransforms/python/trfValidation.py
+++ b/Tools/PyJobTransforms/python/trfValidation.py
@@ -489,8 +489,11 @@ class athenaLogFileReport(logFileReport):
         # G4 exceptions can be fatal or they can be warnings...
         msg.debug('Identified G4 exception - adding to error detail report')
         if "just a warning" in g4Report:
-            self._levelCounter['WARNING'] += 1
-            self._errorDetails['WARNING'].append({'message': g4Report, 'firstLine': firstLineCount, 'count': 1})
+            if self._levelCounter['WARNING'] <= self._msgLimit:
+                self._levelCounter['WARNING'] += 1
+                self._errorDetails['WARNING'].append({'message': g4Report, 'firstLine': firstLineCount, 'count': 1})
+            elif self._levelCounter['WARNING'] == self._msgLimit + 1:
+                msg.warning("Found message number {0} at level WARNING - this and further messages will be supressed from the report".format(self._levelCounter['WARNING']))
         else:
             self._levelCounter['FATAL'] += 1
             self._errorDetails['FATAL'].append({'message': g4Report, 'firstLine': firstLineCount, 'count': 1})
@@ -511,8 +514,11 @@ class athenaLogFileReport(logFileReport):
         # G4 exceptions can be fatal or they can be warnings...
         msg.debug('Identified G4 exception - adding to error detail report')
         if "-------- WWWW -------" in g4Report:
-            self._levelCounter['WARNING'] += 1
-            self._errorDetails['WARNING'].append({'message': g4Report, 'firstLine': firstLineCount, 'count': 1})
+            if self._levelCounter['WARNING'] <= self._msgLimit:
+                self._levelCounter['WARNING'] += 1
+                self._errorDetails['WARNING'].append({'message': g4Report, 'firstLine': firstLineCount, 'count': 1})
+            elif self._levelCounter['WARNING'] == self._msgLimit + 1:
+                msg.warning("Found message number {0} at level WARNING - this and further messages will be supressed from the report".format(self._levelCounter['WARNING'])) 
         else:
             self._levelCounter['FATAL'] += 1
             self._errorDetails['FATAL'].append({'message': g4Report, 'firstLine': firstLineCount, 'count': 1})
-- 
GitLab