#270 Log Pungi stderr/stdout to logs in compose directory.
Merged 5 months ago by jkaluza. Opened 5 months ago by jkaluza.
jkaluza/odcs remove-raw-config  into  master

file modified
+9 -2

@@ -426,8 +426,15 @@ 

              self._write_cfgs(td)

              compose_dir = self._prepare_compose_dir(td, conf.target_dir)

              pungi_cmd = self.get_pungi_cmd(td, conf.target_dir, compose_dir)

-             odcs.server.utils.execute_cmd(pungi_cmd, cwd=td,

-                                           timeout=conf.pungi_timeout)

+ 

+             log_out_path = os.path.join(compose_dir, "pungi-stdout.log")

+             log_err_path = os.path.join(compose_dir, "pungi-stderr.log")

+ 

+             with open(log_out_path, "w") as log_out:

+                 with open(log_err_path, "w") as log_err:

+                     odcs.server.utils.execute_cmd(

+                         pungi_cmd, cwd=td, timeout=conf.pungi_timeout,

+                         stdout=log_out, stderr=log_err)

          finally:

              try:

                  if td is not None:

file modified
+1 -1

@@ -176,7 +176,7 @@ 

              db.session.commit()

  

              if CELERY_AVAILABLE and conf.celery_broker_url:

-                 if source_type == PungiSourceType.PULP:

+                 if compose.source_type == PungiSourceType.PULP:

                      generate_pulp_compose.delay(compose.id)

                  else:

                      generate_pungi_compose.delay(compose.id)

file modified
+3 -1

@@ -369,7 +369,9 @@ 

          execute_cmd.assert_called_once_with(

              ['pungi-koji', AnyStringWith('pungi.conf'),

               AnyStringWith('--compose-dir='), '--nightly'],

-             cwd=AnyStringWith('/tmp/'), timeout=3600)

+             cwd=AnyStringWith('/tmp/'), timeout=3600,

+             stderr=AnyStringWith("pungi-stderr.log"),

+             stdout=AnyStringWith("pungi-stdout.log"))

  

      @patch("odcs.server.utils.execute_cmd")

      def test_pungi_run_raw_config(self, execute_cmd):

file modified
+1 -1

@@ -36,7 +36,7 @@ 

  

  class AnyStringWith(str):

      def __eq__(self, other):

-         return self in other

+         return self in str(other)

  

  

  class ConfigPatcher(object):

With raw_config, it can easily happen that the configuration file is
wrong and Pungi even cannot parse it. This is currently hard to debug,
because such error is not logged anywhere.

In this commit, the Pungi stdout/stderr is logged to log files in
the compose directory and therefore easy to access and check.

rebased onto e539efb

5 months ago

Fixed tests. I will merge it if they pass.

rebased onto c7cd54f

5 months ago

Pull-Request has been merged by jkaluza

5 months ago