You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "Ash Berlin-Taylor (JIRA)" <ji...@apache.org> on 2019/04/17 09:36:00 UTC

[jira] [Comment Edited] (AIRFLOW-4304) App.py Flask Blueprint registration causes webserver shutdown

    [ https://issues.apache.org/jira/browse/AIRFLOW-4304?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16819888#comment-16819888 ] 

Ash Berlin-Taylor edited comment on AIRFLOW-4304 at 4/17/19 9:35 AM:
---------------------------------------------------------------------

-Ah, this was only a problem when log level was DEBUG. Will fix.-

 

Actually I cannot reproduce this. With 0 code changes on version 1.10.3 (commit 16d93c9e) I see this in the logs.

 
{noformat}
[2019-04-17 10:35:15,477] {__init__.py:540} DEBUG - Loaded DAG <DAG: test>
[2019-04-17 10:35:15,670] {app.py:147} DEBUG - Adding blueprint themes:__Users__ash__code__python__incubator-airflow__airflow_home__plugins_theme
[2019-04-17 10:35:16,102] {cli.py:816} DEBUG - [1 / 1] sleeping for 30000s starting doing a refresh...
{noformat}


was (Author: ashb):
Ah, this was only a problem when log level was DEBUG. Will fix.

> App.py Flask Blueprint registration causes webserver shutdown
> -------------------------------------------------------------
>
>                 Key: AIRFLOW-4304
>                 URL: https://issues.apache.org/jira/browse/AIRFLOW-4304
>             Project: Apache Airflow
>          Issue Type: Bug
>          Components: ui
>    Affects Versions: 1.10.3
>         Environment: macosx
>            Reporter: Andrew Piermarini
>            Priority: Major
>              Labels: blueprint, flask, ui
>             Fix For: 1.10.4
>
>
> Flask Blueprint objects are treated as subscriptable in `app.py`, which raises an exception that causes the webserver to shut down.
> The exception is raised on line 147 of /airflow/www/app.py. In prior versions, the Blueprint object was retrieved from a dictionary-like flask_blueprints object by calling bp["blueprint"]. As of 10.3, it appears that flask_blueprints is loaded as an array of non-subscriptable Blueprint objects on which `name` and `import_name` can be called directly. 
>  
> *Exception:*
> {code:java}
> [2019-04-11 15:09:02 -0700] [54143] [ERROR] Exception in worker process
> Traceback (most recent call last):
> File "/Users/andrew/.asdf/installs/python/3.6.6/lib/python3.6/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
> worker.init_process()
> File "/Users/andrew/.asdf/installs/python/3.6.6/lib/python3.6/site-packages/gunicorn/workers/base.py", line 129, in init_process
> self.load_wsgi()
> File "/Users/andrew/.asdf/installs/python/3.6.6/lib/python3.6/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi
> self.wsgi = self.app.wsgi()
> File "/Users/andrew/.asdf/installs/python/3.6.6/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
> self.callable = self.load()
> File "/Users/andrew/.asdf/installs/python/3.6.6/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 52, in load
> return self.load_wsgiapp()
> File "/Users/andrew/.asdf/installs/python/3.6.6/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
> return util.import_app(self.app_uri)
> File "/Users/andrew/.asdf/installs/python/3.6.6/lib/python3.6/site-packages/gunicorn/util.py", line 362, in import_app
> app = eval(obj, vars(mod))
> File "<string>", line 1, in <module>
> File "/Users/andrew/.asdf/installs/python/3.6.6/lib/python3.6/site-packages/airflow/www/app.py", line 192, in cached_app
> app = create_app(config, testing)
> File "/Users/andrew/.asdf/installs/python/3.6.6/lib/python3.6/site-packages/airflow/www/app.py", line 153, in create_app
> integrate_plugins()
> File "/Users/andrew/.asdf/installs/python/3.6.6/lib/python3.6/site-packages/airflow/www/app.py", line 147, in integrate_plugins
> log.debug("Adding blueprint %s:%s", bp["name"], bp["blueprint"].import_name)
> TypeError: 'Blueprint' object is not subscriptable
> {code}
> *Existing Codeblock:*
>  
> {code:java}
> # www/app.py, lines 138-153
> def integrate_plugins():
>   """Integrate plugins to the context"""
>   log = LoggingMixin().log
>   from airflow.plugins_manager import (
>   admin_views, flask_blueprints, menu_links)
>   for v in admin_views:
>     log.debug('Adding view %s', v.name)
>     admin.add_view(v)
>   for bp in flask_blueprints:
>     log.debug("Adding blueprint %s:%s", bp["name"],  bp["blueprint"].import_name)
>     app.register_blueprint(bp["blueprint"])
>   for ml in sorted(menu_links, key=lambda x: x.name):
>     log.debug('Adding menu link %s', ml.name)
>     admin.add_link(ml)
> integrate_plugins()
> {code}
>  
> Corrected Codeblock:
> {code:java}
> # www/app.py, lines 138-153
> def integrate_plugins():
>   """Integrate plugins to the context"""
>   log = LoggingMixin().log
>   from airflow.plugins_manager import (
>   admin_views, flask_blueprints, menu_links)
>   for v in admin_views:
>     log.debug('Adding view %s', v.name)
>     admin.add_view(v)
>   for bp in flask_blueprints:
>     log.debug("Adding blueprint %s:%s", bp.name, bp.import_name)
>     app.register_blueprint(bp)
>   for ml in sorted(menu_links, key=lambda x: x.name):
>     log.debug('Adding menu link %s', ml.name)
>     admin.add_link(ml)
> integrate_plugins(){code}
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)