#1030 fronted: builder-live.log path leads to an exception
Merged 4 years ago by praiskup. Opened 4 years ago by schlupov.
copr/ schlupov/copr fix_build_log  into  master

@@ -935,14 +935,6 @@ 

          path = os.path.normpath(os.path.join(*parts))

          return urljoin(app.config["BACKEND_BASE_URL"], path)

  

-     def backend_live_log(self, chroot):

-         parts = ["results", self.copr.owner_name, self.copr_dirname,

-                  chroot.name, self.id_fixed_width + "-" + self.package.name,

-                  "builder-live.log" if chroot.status == StatusEnum("running")

-                                     else "builder-live.log.gz"]

-         path = os.path.normpath(os.path.join(*parts))

-         return urljoin(app.config["BACKEND_BASE_URL"], path)

- 

      @property

      def source_json_dict(self):

          if not self.source_json:
@@ -1403,6 +1395,17 @@ 

          return urljoin(app.config["BACKEND_BASE_URL"], os.path.join(

              "results", self.build.copr_dir.full_name, self.name, self.result_dir, ""))

  

+     @property

+     def live_log_link(self):

+         if not self.build.package:

+             return None

+ 

+         if not (self.finished or self.state == "running"):

+             return None

+ 

+         return os.path.join(self.result_dir_url,

+                             "builder-live.log" if self.state == 'running' else "builder-live.log.gz")

+ 

  

  class LegalFlag(db.Model, helpers.Serializer):

      id = db.Column(db.Integer, primary_key=True)

@@ -228,8 +228,8 @@ 

                  {{ chroot.started_on|time_ago(chroot.ended_on) }}

                </td>

                <td>

-                 {% if chroot.finished or chroot.state == "running" %}

-                     <a href="{{ build.backend_live_log(chroot) }}">{{ build_state_text(chroot.state) }}</a>

+                 {% if chroot.live_log_link %}

+                     <a href="{{ chroot.live_log_link }}">{{ build_state_text(chroot.state) }}</a>

                  {% else %}

                    {{ build_state_text(chroot.state) }}

                  {% endif %}

no initial comment

Hmpfs, why this failed actually? The chroot.finished is much more than just "succeded", there's at least "failed" .. but probably much more.

The traceback is:

[Fri Sep 27 08:45:31.544612 2019] [wsgi:error] [pid 25438:tid 140195985078016] [remote 212.96.182.5:33298] ERROR:flask.app:Exception on /coprs/schlupov/testing_project/build/847575/ [GET]
[Fri Sep 27 08:45:31.544654 2019] [wsgi:error] [pid 25438:tid 140195985078016] [remote 212.96.182.5:33298] Traceback (most recent call last):
[Fri Sep 27 08:45:31.544659 2019] [wsgi:error] [pid 25438:tid 140195985078016] [remote 212.96.182.5:33298]   File "/usr/lib/python3.7/site-packages/flask/app.py", line 2292, in wsgi_app
[Fri Sep 27 08:45:31.544663 2019] [wsgi:error] [pid 25438:tid 140195985078016] [remote 212.96.182.5:33298]     response = self.full_dispatch_request()
[Fri Sep 27 08:45:31.544665 2019] [wsgi:error] [pid 25438:tid 140195985078016] [remote 212.96.182.5:33298]   File "/usr/lib/python3.7/site-packages/flask/app.py", line 1815, in full_dispatch_request
[Fri Sep 27 08:45:31.544668 2019] [wsgi:error] [pid 25438:tid 140195985078016] [remote 212.96.182.5:33298]     rv = self.handle_user_exception(e)
[Fri Sep 27 08:45:31.544671 2019] [wsgi:error] [pid 25438:tid 140195985078016] [remote 212.96.182.5:33298]   File "/usr/share/copr/coprs_frontend/coprs/rest_api/__init__.py", line 44, in error_router
[Fri Sep 27 08:45:31.544674 2019] [wsgi:error] [pid 25438:tid 140195985078016] [remote 212.96.182.5:33298]     return original_handler(e)
[Fri Sep 27 08:45:31.544677 2019] [wsgi:error] [pid 25438:tid 140195985078016] [remote 212.96.182.5:33298]   File "/usr/lib/python3.7/site-packages/flask/app.py", line 1718, in handle_user_exception
[Fri Sep 27 08:45:31.544679 2019] [wsgi:error] [pid 25438:tid 140195985078016] [remote 212.96.182.5:33298]     reraise(exc_type, exc_value, tb)
[Fri Sep 27 08:45:31.544682 2019] [wsgi:error] [pid 25438:tid 140195985078016] [remote 212.96.182.5:33298]   File "/usr/lib/python3.7/site-packages/flask/_compat.py", line 35, in reraise
[Fri Sep 27 08:45:31.544684 2019] [wsgi:error] [pid 25438:tid 140195985078016] [remote 212.96.182.5:33298]     raise value
[Fri Sep 27 08:45:31.544687 2019] [wsgi:error] [pid 25438:tid 140195985078016] [remote 212.96.182.5:33298]   File "/usr/lib/python3.7/site-packages/flask/app.py", line 1813, in full_dispatch_request
[Fri Sep 27 08:45:31.544731 2019] [wsgi:error] [pid 25438:tid 140195985078016] [remote 212.96.182.5:33298]     rv = self.dispatch_request()
[Fri Sep 27 08:45:31.544737 2019] [wsgi:error] [pid 25438:tid 140195985078016] [remote 212.96.182.5:33298]   File "/usr/lib/python3.7/site-packages/flask/app.py", line 1799, in dispatch_request
[Fri Sep 27 08:45:31.544741 2019] [wsgi:error] [pid 25438:tid 140195985078016] [remote 212.96.182.5:33298]     return self.view_functions[rule.endpoint](**req.view_args)
[Fri Sep 27 08:45:31.544743 2019] [wsgi:error] [pid 25438:tid 140195985078016] [remote 212.96.182.5:33298]   File "/usr/share/copr/coprs_frontend/coprs/views/misc.py", line 352, in wrapper
[Fri Sep 27 08:45:31.544746 2019] [wsgi:error] [pid 25438:tid 140195985078016] [remote 212.96.182.5:33298]     return f(copr, **kwargs) 
[Fri Sep 27 08:45:31.544748 2019] [wsgi:error] [pid 25438:tid 140195985078016] [remote 212.96.182.5:33298]   File "/usr/share/copr/coprs_frontend/coprs/views/coprs_ns/coprs_builds.py", line 41, in copr_build
[Fri Sep 27 08:45:31.544751 2019] [wsgi:error] [pid 25438:tid 140195985078016] [remote 212.96.182.5:33298]     return render_copr_build(build_id, copr)
[Fri Sep 27 08:45:31.544760 2019] [wsgi:error] [pid 25438:tid 140195985078016] [remote 212.96.182.5:33298]   File "/usr/share/copr/coprs_frontend/coprs/views/coprs_ns/coprs_builds.py", line 46, in render_copr_build
[Fri Sep 27 08:45:31.544767 2019] [wsgi:error] [pid 25438:tid 140195985078016] [remote 212.96.182.5:33298]     return render_template("coprs/detail/build.html", build=build, copr=copr)
[Fri Sep 27 08:45:31.544770 2019] [wsgi:error] [pid 25438:tid 140195985078016] [remote 212.96.182.5:33298]   File "/usr/lib/python3.7/site-packages/flask/templating.py", line 135, in render_template
[Fri Sep 27 08:45:31.544773 2019] [wsgi:error] [pid 25438:tid 140195985078016] [remote 212.96.182.5:33298]     context, ctx.app)
[Fri Sep 27 08:45:31.544775 2019] [wsgi:error] [pid 25438:tid 140195985078016] [remote 212.96.182.5:33298]   File "/usr/lib/python3.7/site-packages/flask/templating.py", line 117, in _render
[Fri Sep 27 08:45:31.544778 2019] [wsgi:error] [pid 25438:tid 140195985078016] [remote 212.96.182.5:33298]     rv = template.render(context)
[Fri Sep 27 08:45:31.544781 2019] [wsgi:error] [pid 25438:tid 140195985078016] [remote 212.96.182.5:33298]   File "/usr/lib/python3.7/site-packages/jinja2/asyncsupport.py", line 76, in render
[Fri Sep 27 08:45:31.544783 2019] [wsgi:error] [pid 25438:tid 140195985078016] [remote 212.96.182.5:33298]     return original_render(self, *args, **kwargs)
[Fri Sep 27 08:45:31.544786 2019] [wsgi:error] [pid 25438:tid 140195985078016] [remote 212.96.182.5:33298]   File "/usr/lib/python3.7/site-packages/jinja2/environment.py", line 1008, in render
[Fri Sep 27 08:45:31.544789 2019] [wsgi:error] [pid 25438:tid 140195985078016] [remote 212.96.182.5:33298]     return self.environment.handle_exception(exc_info, True) 
[Fri Sep 27 08:45:31.544792 2019] [wsgi:error] [pid 25438:tid 140195985078016] [remote 212.96.182.5:33298]   File "/usr/lib/python3.7/site-packages/jinja2/environment.py", line 780, in handle_exception
[Fri Sep 27 08:45:31.544794 2019] [wsgi:error] [pid 25438:tid 140195985078016] [remote 212.96.182.5:33298]     reraise(exc_type, exc_value, tb)
[Fri Sep 27 08:45:31.544797 2019] [wsgi:error] [pid 25438:tid 140195985078016] [remote 212.96.182.5:33298]   File "/usr/lib/python3.7/site-packages/jinja2/_compat.py", line 37, in reraise
[Fri Sep 27 08:45:31.544799 2019] [wsgi:error] [pid 25438:tid 140195985078016] [remote 212.96.182.5:33298]     raise value.with_traceback(tb)
[Fri Sep 27 08:45:31.544802 2019] [wsgi:error] [pid 25438:tid 140195985078016] [remote 212.96.182.5:33298]   File "/usr/share/copr/coprs_frontend/coprs/templates/coprs/detail/build.html", line 8, in top-level template code
[Fri Sep 27 08:45:31.544805 2019] [wsgi:error] [pid 25438:tid 140195985078016] [remote 212.96.182.5:33298]     {% set selected_tab = "builds" %}
[Fri Sep 27 08:45:31.544808 2019] [wsgi:error] [pid 25438:tid 140195985078016] [remote 212.96.182.5:33298]   File "/usr/share/copr/coprs_frontend/coprs/templates/coprs/detail.html", line 2, in top-level template code
[Fri Sep 27 08:45:31.544829 2019] [wsgi:error] [pid 25438:tid 140195985078016] [remote 212.96.182.5:33298]     {% from "_helpers.html" import copr_title, copr_url, render_crumb, copr_name %}
[Fri Sep 27 08:45:31.544834 2019] [wsgi:error] [pid 25438:tid 140195985078016] [remote 212.96.182.5:33298]   File "/usr/share/copr/coprs_frontend/coprs/templates/layout.html", line 98, in top-level template code
[Fri Sep 27 08:45:31.544837 2019] [wsgi:error] [pid 25438:tid 140195985078016] [remote 212.96.182.5:33298]     {% block body %}{% endblock %}
[Fri Sep 27 08:45:31.544839 2019] [wsgi:error] [pid 25438:tid 140195985078016] [remote 212.96.182.5:33298]   File "/usr/share/copr/coprs_frontend/coprs/templates/coprs/detail.html", line 66, in block "body"
[Fri Sep 27 08:45:31.544842 2019] [wsgi:error] [pid 25438:tid 140195985078016] [remote 212.96.182.5:33298]     {% block detail_body %}{% endblock %}
[Fri Sep 27 08:45:31.544845 2019] [wsgi:error] [pid 25438:tid 140195985078016] [remote 212.96.182.5:33298]   File "/usr/share/copr/coprs_frontend/coprs/templates/coprs/detail/build.html", line 232, in block "detail_body"
[Fri Sep 27 08:45:31.544848 2019] [wsgi:error] [pid 25438:tid 140195985078016] [remote 212.96.182.5:33298]     <a href="{{ build.backend_live_log(chroot) }}">{{ build_state_text(chroot.state) }}</a>
[Fri Sep 27 08:45:31.544851 2019] [wsgi:error] [pid 25438:tid 140195985078016] [remote 212.96.182.5:33298]   File "/usr/share/copr/coprs_frontend/coprs/models.py", line 940, in backend_live_log
[Fri Sep 27 08:45:31.544853 2019] [wsgi:error] [pid 25438:tid 140195985078016] [remote 212.96.182.5:33298]     chroot.name, self.id_fixed_width + "-" + self.package.name,
[Fri Sep 27 08:45:31.544856 2019] [wsgi:error] [pid 25438:tid 140195985078016] [remote 212.96.182.5:33298] AttributeError: 'NoneType' object has no attribute 'name'

Can we please move this logic to models.py so we can do:

{% if chroot.live_log_link %}
<a href="{{ chroot.live_log_link }}">{{ build_state_text(chroot.state) }}</a>
{% endif %}

... and then implement the status logic (self.build.finished and ... etc.) in models.py in the BuildChroot.live_log_link property?

rebased onto 3add46bcc962dcd29d1dfe06cb2146fa57b04bb5

4 years ago

Can we please do

if not self.build.package:
    return None
if self.finished:
    ...

rebased onto ec7a392995641b7388d7771fad2546376139269a

4 years ago

The chroot.state == "running" condition probably isn't necessary now? If it is, please move it into live_log_link() directly.

You probably want:

if not self.build.package:
    # package name isn't know yet, probably still waiting for SRPM
    return None
if not (self.finished or self.state == StatusEnum("running"): 
    # it doesn't make sense to provide link yet, it would be 404
    return None

there used to be id_fixed_width instead of id, so this needs fix, also consider using self.resultdir_url

rebased onto ba87f3eb3a75e61e7e9bb48096709adab10ba27a

4 years ago

rebased onto 7f03a651513c8300885c02072cca8c2eabd03bd4

4 years ago

The condition here isn't correct; you need to take a look at self.state == 'running' (source status is out of question for this log file).

rebased onto 968ab390bc14f8d6ff35670ea925a0f8dfe8ff8a

4 years ago

rebased onto 8842fafff115b2995177ac30427461b153efd6e6

4 years ago

It isn't valid to call normpath on http:// string. Simply call urljoin(self.result_dir_url, builder_live_log_basename).

Metadata Update from @praiskup:
- Pull-request tagged with: release-blocker

4 years ago

rebased onto ae6bb7e60dd543ad5407eba498eaaef80622f3b6

4 years ago

rebased onto 4f8bcd8

4 years ago

Commit 5cec3fe fixes this pull-request

Pull-Request has been merged by praiskup

4 years ago