You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by ds...@apache.org on 2022/04/14 01:49:19 UTC

[airflow] branch main updated: Skip log template sync if table doesn't exist (#22993)

This is an automated email from the ASF dual-hosted git repository.

dstandish pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 3ac1be2027 Skip log template sync if table doesn't exist (#22993)
3ac1be2027 is described below

commit 3ac1be20274c51f9cfd7b5489b4de8babd0d13a0
Author: Daniel Standish <15...@users.noreply.github.com>
AuthorDate: Wed Apr 13 18:49:12 2022 -0700

    Skip log template sync if table doesn't exist (#22993)
    
    When doing partial or offline upgrades the log template table (which is added in 2.3.0) may not exist.  We should skip synchrization (and save the user some error logging) in that case.
---
 airflow/utils/db.py | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/airflow/utils/db.py b/airflow/utils/db.py
index c9b7ad09e5..8b3b5ebf21 100644
--- a/airflow/utils/db.py
+++ b/airflow/utils/db.py
@@ -779,6 +779,16 @@ def synchronize_log_template(*, session: Session = NEW_SESSION) -> None:
     This checks if the last row fully matches the current config values, and
     insert a new row if not.
     """
+
+    def log_template_exists():
+        metadata = reflect_tables([LogTemplate], session)
+        log_template_table = metadata.tables.get(LogTemplate.__tablename__)
+        return log_template_table is not None
+
+    if not log_template_exists():
+        log.info('Log template table does not exist (added in 2.3.0); skipping log template sync.')
+        return
+
     filename = conf.get("logging", "log_filename_template")
     elasticsearch_id = conf.get("elasticsearch", "log_id_template")