#353 Limit Pungi error log parsing output to 2kB.
Merged 4 years ago by lsedlar. Opened 4 years ago by jkaluza.
jkaluza/odcs log-too-big  into  master

@@ -510,6 +510,10 @@ 

              if error.startswith("Extended traceback in:"):

                  continue

              errors += error

+             if len(errors) > 2000:

+                 errors = errors[:2000]

+                 errors += " ...\n Too many errors, see Pungi log for more information."

+                 break

  

          if self.compose.on_default_target_dir:

              errors = errors.replace(

@@ -570,6 +570,20 @@ 

              "For more details see http://localhost/odcs/odcs-717-1-20180323.n.0/work/x86_64/pungi/Temporary.x86_64.log\n")

  

      @patch("odcs.server.pungi.open", create=True)

+     def test_error_string_too_many_errors(self, patched_open):

+         pungi_log = """

+ 2018-03-23 03:38:42 [INFO    ] Writing pungi config

+ 2018-03-22 17:10:49 [ERROR   ] Compose run failed: No such entry in table tag: tag

+         """ * 100

+         patched_open.return_value = mock_open(

+             read_data=pungi_log).return_value

+ 

+         pungi_logs = PungiLogs(self.compose)

+         errors = pungi_logs.get_error_string()

+         self.assertTrue("Too many errors" in errors)

+         self.assertEqual(len(errors), 2058)

+ 

+     @patch("odcs.server.pungi.open", create=True)

      def test_error_string_no_error(self, patched_open):

          pungi_log = """

  2018-03-23 03:38:42 [INFO    ] Writing pungi config

Before this commit, the ODCS would store unlimited amount
of data comming from Pungi log in state_reason. This is
a problem, because Pungi can print lot of errors for example
if it cannot find any of the requested RPMs on filesystem.

This commit limits the error message parsed from Pungi logs
to 2kB.

Signed-off-by: Jan Kaluza jkaluza@redhat.com

Pull-Request has been merged by lsedlar

4 years ago