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

ASF GitHub Bot commented on AIRFLOW-5194:
-----------------------------------------

villasv commented on pull request #5883: [AIRFLOW-5194] Add error handler to 
action log
URL: https://github.com/apache/airflow/pull/5883
 
 
   ### Jira
   
   - [X] My PR addresses the following [Airflow 
Jira](https://issues.apache.org/jira/browse/AIRFLOW-5194) issues and references 
them in the PR title.
     - https://issues.apache.org/jira/browse/AIRFLOW-5194
   
   ### Description
   
   Added try/except with logging.warning on action log error, quite less scary 
than having a wall of red text pop up from the unhandled error.
   
   Also removed action logging from the CLI version command which doesn't do
   anything worth logging.
   
   ### Tests
   
   - [X] My PR adds the following unit tests __OR__ does not need testing for 
this extremely good reason: no functional changes.
   
   ### Commits
   
   - [X] My commits all reference Jira issues in their subject lines, and I 
have squashed multiple commits if they address the same issue. In addition, my 
commits follow the guidelines from "[How to write a good git commit 
message](http://chris.beams.io/posts/git-commit/)":
     1. Subject is separated from body by a blank line
     1. Subject is limited to 50 characters (not including Jira issue reference)
     1. Subject does not end with a period
     1. Subject uses the imperative mood ("add", not "adding")
     1. Body wraps at 72 characters
     1. Body explains "what" and "why", not "how"
   
   ### Documentation
   
   - [X] In case of new functionality, my PR adds documentation that describes 
how to use it.
     - All the public functions and the classes in the PR contain docstrings 
that explain what it does
     - If you implement backwards incompatible changes, please leave a note in 
the [Updating.md](https://github.com/apache/airflow/blob/master/UPDATING.md) so 
we can assign it to a appropriate release
   
   ### Code Quality
   
   - [X] Passes `flake8`
   
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> Make @cli_utils.action_logging silent about missing log table
> -------------------------------------------------------------
>
>                 Key: AIRFLOW-5194
>                 URL: https://issues.apache.org/jira/browse/AIRFLOW-5194
>             Project: Apache Airflow
>          Issue Type: Improvement
>          Components: cli
>    Affects Versions: 1.10.4
>            Reporter: Victor Villas Bôas Chaves
>            Priority: Minor
>
> https://issues.apache.org/jira/browse/AIRFLOW-2253 introduced 
> `@cli_utils.action_logging` to CLI commands, but a few of those commands are 
> reasonably expected to run before the database has been initialized. On doing 
> so, an `relation "log" does not exist` error pops out (see below for a 
> complete output).
> https://issues.apache.org/jira/browse/AIRFLOW-2436 was created and solved 
> that problem in the `initdb` command itself, but this still affects two 
> commands that are often used before tables exist: `version` and `upgradedb` 
> (which is frequently used as a kind of `initdb` that won't load default 
> connections, so quite a few people use it to initialize the db as well).
>  
> {code:java}
> [root@ip-10-0-11-97 ~]# /usr/local/bin/airflow version
> /usr/local/lib/python3.7/site-packages/airflow/configuration.py:614: 
> DeprecationWarning: You have two airflow.cfg files: /root/airflow/airflow.cfg 
> and /airflow/airflow.cfg. Airflow used to look at ~/airflow/airflow.cfg, even 
> when AIRFLOW_HOME was set to a different value. Airflow will now only read 
> /airflow/airflow.cfg, and you should remove the other file
>   category=DeprecationWarning,
> [2019-08-13 11:13:39,985] {settings.py:213} INFO - settings.configure_orm(): 
> Using pool settings. pool_size=5, max_overflow=10, pool_recycle=1800, pid=3547
> /usr/local/lib64/python3.7/site-packages/psycopg2/__init__.py:144: 
> UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in 
> order to keep installing from binary please use "pip install psycopg2-binary" 
> instead. For details see: 
> <http://initd.org/psycopg/docs/install.html#binary-install-from-pypi>.
>   """)
> [2019-08-13 11:13:40,188] {__init__.py:51} INFO - Using executor 
> CeleryExecutor
> [2019-08-13 11:13:40,524] {cli_action_loggers.py:70} ERROR - Failed on 
> pre-execution callback using <function default_action_log at 0x7fc6e1afe200>
> Traceback (most recent call last):
>   File "/usr/local/lib64/python3.7/site-packages/sqlalchemy/engine/base.py", 
> line 1244, in _execute_context
>     cursor, statement, parameters, context
>   File 
> "/usr/local/lib64/python3.7/site-packages/sqlalchemy/engine/default.py", line 
> 552, in do_execute
>     cursor.execute(statement, parameters)
> psycopg2.ProgrammingError: relation "log" does not exist
> LINE 1: INSERT INTO log (dttm, dag_id, task_id, event, execution_dat...
>                     ^
> The above exception was the direct cause of the following exception:
> Traceback (most recent call last):
>   File 
> "/usr/local/lib/python3.7/site-packages/airflow/utils/cli_action_loggers.py", 
> line 68, in on_pre_execution
>     cb(**kwargs)
>   File 
> "/usr/local/lib/python3.7/site-packages/airflow/utils/cli_action_loggers.py", 
> line 99, in default_action_log
>     session.add(log)
>   File "/usr/lib64/python3.7/contextlib.py", line 119, in __exit__
>     next(self.gen)
>   File "/usr/local/lib/python3.7/site-packages/airflow/utils/db.py", line 45, 
> in create_session
>     session.commit()
>   File "/usr/local/lib64/python3.7/site-packages/sqlalchemy/orm/session.py", 
> line 1027, in commit
>     self.transaction.commit()
>   File "/usr/local/lib64/python3.7/site-packages/sqlalchemy/orm/session.py", 
> line 494, in commit
>     self._prepare_impl()
>   File "/usr/local/lib64/python3.7/site-packages/sqlalchemy/orm/session.py", 
> line 473, in _prepare_impl
>     self.session.flush()
>   File "/usr/local/lib64/python3.7/site-packages/sqlalchemy/orm/session.py", 
> line 2459, in flush
>     self._flush(objects)
>   File "/usr/local/lib64/python3.7/site-packages/sqlalchemy/orm/session.py", 
> line 2597, in _flush
>     transaction.rollback(_capture_exception=True)
>   File 
> "/usr/local/lib64/python3.7/site-packages/sqlalchemy/util/langhelpers.py", 
> line 68, in __exit__
>     compat.reraise(exc_type, exc_value, exc_tb)
>   File "/usr/local/lib64/python3.7/site-packages/sqlalchemy/util/compat.py", 
> line 153, in reraise
>     raise value
>   File "/usr/local/lib64/python3.7/site-packages/sqlalchemy/orm/session.py", 
> line 2557, in _flush
>     flush_context.execute()
>   File 
> "/usr/local/lib64/python3.7/site-packages/sqlalchemy/orm/unitofwork.py", line 
> 422, in execute
>     rec.execute(self)
>   File 
> "/usr/local/lib64/python3.7/site-packages/sqlalchemy/orm/unitofwork.py", line 
> 589, in execute
>     uow,
>   File 
> "/usr/local/lib64/python3.7/site-packages/sqlalchemy/orm/persistence.py", 
> line 245, in save_obj
>     insert,
>   File 
> "/usr/local/lib64/python3.7/site-packages/sqlalchemy/orm/persistence.py", 
> line 1138, in _emit_insert_statements
>     statement, params
>   File "/usr/local/lib64/python3.7/site-packages/sqlalchemy/engine/base.py", 
> line 988, in execute
>     return meth(self, multiparams, params)
>   File "/usr/local/lib64/python3.7/site-packages/sqlalchemy/sql/elements.py", 
> line 287, in _execute_on_connection
>     return connection._execute_clauseelement(self, multiparams, params)
>   File "/usr/local/lib64/python3.7/site-packages/sqlalchemy/engine/base.py", 
> line 1107, in _execute_clauseelement
>     distilled_params,
>   File "/usr/local/lib64/python3.7/site-packages/sqlalchemy/engine/base.py", 
> line 1248, in _execute_context
>     e, statement, parameters, cursor, context
>   File "/usr/local/lib64/python3.7/site-packages/sqlalchemy/engine/base.py", 
> line 1466, in _handle_dbapi_exception
>     util.raise_from_cause(sqlalchemy_exception, exc_info)
>   File "/usr/local/lib64/python3.7/site-packages/sqlalchemy/util/compat.py", 
> line 398, in raise_from_cause
>     reraise(type(exception), exception, tb=exc_tb, cause=cause)
>   File "/usr/local/lib64/python3.7/site-packages/sqlalchemy/util/compat.py", 
> line 152, in reraise
>     raise value.with_traceback(tb)
>   File "/usr/local/lib64/python3.7/site-packages/sqlalchemy/engine/base.py", 
> line 1244, in _execute_context
>     cursor, statement, parameters, context
>   File 
> "/usr/local/lib64/python3.7/site-packages/sqlalchemy/engine/default.py", line 
> 552, in do_execute
>     cursor.execute(statement, parameters)
> sqlalchemy.exc.ProgrammingError: (psycopg2.ProgrammingError) relation "log" 
> does not exist
> LINE 1: INSERT INTO log (dttm, dag_id, task_id, event, execution_dat...
>                     ^
> [SQL: INSERT INTO log (dttm, dag_id, task_id, event, execution_date, owner, 
> extra) VALUES (%(dttm)s, %(dag_id)s, %(task_id)s, %(event)s, 
> %(execution_date)s, %(owner)s, %(extra)s) RETURNING log.id]
> [parameters: {'dttm': datetime.datetime(2019, 8, 13, 11, 13, 40, 486015, 
> tzinfo=<Timezone [UTC]>), 'dag_id': None, 'task_id': None, 'event': 
> 'cli_version', 'execution_date': None, 'owner': 'root', 'extra': 
> '{"host_name": "ip-10-0-11-97.ec2.internal", "full_command": 
> "[\'/usr/local/bin/airflow\', \'version\']"}'}]
> (Background on this error at: http://sqlalche.me/e/f405)
>   ____________       _____________
>  ____    |__( )_________  __/__  /________      __
> ____  /| |_  /__  ___/_  /_ __  /_  __ \_ | /| / /
> ___  ___ |  / _  /   _  __/ _  / / /_/ /_ |/ |/ /
>  _/_/  |_/_/  /_/    /_/    /_/  \____/____/|__/  v1.10.4
> {code}



--
This message was sent by Atlassian Jira
(v8.3.2#803003)

Reply via email to