#330 Show URL to pungi-stderr.log/pungi-stdout.log in state_reason in case compose fails.
Merged 4 years ago by lsedlar. Opened 4 years ago by jkaluza.
jkaluza/odcs release  into  master

@@ -892,6 +892,9 @@ 

              except Exception:

                  log.exception("Exception raised when getting Pungi logs.")

  

+             # Be nice to end user and replace paths to logs or other files with URL

+             # accessible to the user.

+             state_reason = state_reason.replace(conf.target_dir, conf.target_dir_url)

              compose.transition(COMPOSE_STATES["failed"], state_reason)

  

          compose = Compose.query.filter(Compose.id == compose_id).one()

file modified
+4 -2
@@ -691,7 +691,8 @@ 

      def test_generate_compose_exception(

              self, get_error_string, generate_pungi_compose, resolve_compose):

          get_error_string.return_value = "Compose failed for unknown reason."

-         generate_pungi_compose.side_effect = RuntimeError("Expected exception")

+         generate_pungi_compose.side_effect = RuntimeError(

+             "Expected exception, see %s" % os.path.join(conf.target_dir, "foo.log"))

  

          c = Compose.create(

              db.session, "me", PungiSourceType.KOJI_TAG, "foo-1",
@@ -707,7 +708,8 @@ 

          self.assertEqual(c1.state, COMPOSE_STATES["failed"])

          six.assertRegex(

              self, c1.state_reason,

-             r'Error while generating compose: Expected exception\n'

+             r'Error while generating compose: Expected exception, see '

+             'http://localhost/odcs/foo.log\n'

              'Compose failed for unknown reason*')

  

      @patch("odcs.server.backend.resolve_compose")