dmsimard / ara-archive

This repository is an historical archive of https://github.com/dmsimard/ara, please use https://github.com/openstack/ara instead.
https://github.com/openstack/ara
GNU General Public License v3.0
120 stars 19 forks source link

Loading web UI fails with a Jinja2 error #121

Closed glitchcrab closed 7 years ago

glitchcrab commented 7 years ago

Hi, I'm currently seeing the following error when trying to load the webui (running with the standalone webserver for testing purposes):

[2017-05-08 21:08:54,090] ERROR in app: Exception on /reports/ [GET]
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1988, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1641, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1544, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1639, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1625, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/usr/local/lib/python2.7/dist-packages/ara/views/reports.py", line 66, in report_list
    stats=stats)
  File "/usr/local/lib/python2.7/dist-packages/flask/templating.py", line 134, in render_template
    context, ctx.app)
  File "/usr/local/lib/python2.7/dist-packages/flask/templating.py", line 116, in _render
    rv = template.render(context)
  File "/usr/lib/python2.7/dist-packages/jinja2/environment.py", line 969, in render
    return self.environment.handle_exception(exc_info, True)
  File "/usr/lib/python2.7/dist-packages/jinja2/environment.py", line 742, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python2.7/dist-packages/ara/templates/report_list.html", line 1, in top-level template code
    {% extends "layout.html" %}
  File "/usr/local/lib/python2.7/dist-packages/ara/templates/layout.html", line 6, in top-level template code
    {% block content -%}
  File "/usr/local/lib/python2.7/dist-packages/ara/templates/report_list.html", line 10, in block "content"
    {% include "report.html" -%}
  File "/usr/local/lib/python2.7/dist-packages/ara/templates/report.html", line 12, in top-level template code
    {{ macros.render_status(stats[playbook.id].status) }}
  File "/usr/lib/python2.7/dist-packages/jinja2/environment.py", line 397, in getattr
    return getattr(obj, attribute)
UndefinedError: 'macros' is undefined
127.0.0.1 - - [08/May/2017 21:08:54] "GET /reports/ HTTP/1.1" 500 -

Some environment info:

root@denver:~$ python --version
Python 2.7.9
root@denver:~# pip freeze | grep ara
ara==0.13.0
root@denver:~# apt-cache policy python-jinja2
python-jinja2:
  Installed: 2.7.3-1
  Candidate: 2.7.3-1
  Version table:
 *** 2.7.3-1 0
        500 http://mirrordirector.raspbian.org/raspbian/ jessie/main armhf Packages
        100 /var/lib/dpkg/status

Anything you can suggest to debug this issue? I am running as an unprivileged user if that matters.

dmsimard commented 7 years ago

I haven't seen that happen but then again I don't mix packaged (yum/apt) packages with unpackaged (pip).

The first step I would see to troubleshoot would be to install in a clean (empty) virtualenv and then see if you can reproduce. If not, start from there and try to identify the differences (in versions or other) between what the virtualenv provides and what your packages provide.

dmsimard commented 7 years ago

FWIW there seems to be a lot of Jinja2 bugfixes in >=2.9: http://jinja.pocoo.org/docs/2.9/changelog/ Maybe if we find there's a minimum version of Jinja required we can properly pin it.

Otherwise, here's the output of a pip freeze on my end:

alembic==0.9.1
ansible==2.3.0.0
appdirs==1.4.3
ara==0.13.0
asn1crypto==0.22.0
cffi==1.10.0
click==6.7
cliff==2.7.0
cmd2==0.7.0
cryptography==1.8.1
debtcollector==1.13.0
decorator==4.0.11
enum34==1.1.6
extras==1.0.0
fixtures==3.0.0
Flask==0.11.1
Flask-Migrate==2.0.3
Flask-Script==2.0.5
Flask-SQLAlchemy==2.2
Frozen-Flask==0.14
funcsigs==1.0.2
idna==2.5
ipaddress==1.0.18
itsdangerous==0.24
Jinja2==2.9.6
junit-xml==1.7
linecache2==1.0.0
Mako==1.0.6
MarkupSafe==1.0
mox3==0.21.0
packaging==16.8
paramiko==2.1.2
pbr==3.0.0
prettytable==0.7.2
pyasn1==0.2.3
pycparser==2.17
pycrypto==2.6.1
pyfakefs==3.1
Pygments==2.2.0
pyparsing==2.2.0
python-editor==1.0.3
python-mimeparse==1.6.0
PyYAML==3.12
six==1.10.0
SQLAlchemy==1.1.9
stevedore==1.21.0
testtools==2.2.0
traceback2==1.4.0
unicodecsv==0.14.1
unittest2==1.1.0
Werkzeug==0.12.1
wrapt==1.10.10
XStatic==1.0.1
XStatic-Bootstrap-SCSS==3.3.7.1
XStatic-DataTables==1.10.15.1
XStatic-jQuery==1.10.2.1
XStatic-Patternfly==3.21.0.1
XStatic-Patternfly-Bootstrap-Treeview==2.1.3.2
glitchcrab commented 7 years ago

@dmsimard thanks for that, I hadn't realised the Debian version was lagging so far behind. Purging and installing via Pip seems to have resolved it.

On a tangential note, one of your colleagues (?) was bigging up ARA at the Openstack Summit this afternoon ;)

dmsimard commented 7 years ago

@analbeard thanks for the confirmation -- I'll try and figure out what's the minimum version of Jinja and properly pin a minimum version before closing this issue.

Yup ! He told me about it after the fact, pretty cool! Wish I could've gone to the summit. Oh well, next time !

dmsimard commented 7 years ago

This will be fixed by https://review.openstack.org/463572