From 7ee739bb9202e9d5318d1513b55676ab75b66e3b Mon Sep 17 00:00:00 2001 From: Daniel Standish <15932138+dstandish@users.noreply.github.com> Date: Wed, 11 May 2022 07:13:57 -0700 Subject: [PATCH] Simplify flash message for _airflow_moved tables (#23635) Co-authored-by: Jed Cunningham <66968678+jedcunningham@users.noreply.github.com> (cherry picked from commit b68667843c7a9796e7017b729f4474c0b0c990cd) --- airflow/www/templates/airflow/dags.html | 26 ++++++++++++++++++------- airflow/www/views.py | 4 ++-- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/airflow/www/templates/airflow/dags.html b/airflow/www/templates/airflow/dags.html index ba0e35f8c1fd5..a824369769897 100644 --- a/airflow/www/templates/airflow/dags.html +++ b/airflow/www/templates/airflow/dags.html @@ -80,15 +80,27 @@ {% for m in dashboard_alerts %} {{ show_message(m.message, m.category) }} {% endfor %} - {% for original_table_name, moved_table_name in migration_moved_data_alerts %} - {% call show_message(category='error', dismissible=false) %} - Airflow found incompatible data in the {{ original_table_name }} table in the - metadatabase, and has moved them to {{ moved_table_name }} during the database migration - to upgrade. Please inspect the moved data to decide whether you need to keep them, and manually drop - the {{ moved_table_name }} table to dismiss this warning. Read more about it + {% if migration_moved_data_alerts %} + {% call show_message(category='warning', dismissible=false) %} + While upgrading the metadatabase, Airflow had to move some bad data in order to apply new constraints. + The moved data can be found in the following tables:
+ + + + + + {% for original_table_name, moved_table_name in migration_moved_data_alerts %} + + + + + {% endfor %} +
Source tableTable with moved rows
{{ original_table_name }}{{ moved_table_name }}
+ Please inspect the moved data to decide whether you need to keep them, and manually drop + the moved tables to dismiss this warning. Read more about it in Upgrading. {% endcall %} - {% endfor %} + {% endif %} {{ super() }} {% if sqlite_warning | default(true) %} {% call show_message(category='warning', dismissible=false) %} diff --git a/airflow/www/views.py b/airflow/www/views.py index 2ab0067bb2eaa..b2360fca8123b 100644 --- a/airflow/www/views.py +++ b/airflow/www/views.py @@ -829,13 +829,13 @@ def index(self): def _iter_parsed_moved_data_table_names(): for table_name in inspect(session.get_bind()).get_table_names(): - segments = table_name.split("__", 2) + segments = table_name.split("__", 3) if len(segments) < 3: continue if segments[0] != settings.AIRFLOW_MOVED_TABLE_PREFIX: continue # Second segment is a version marker that we don't need to show. - yield segments[2], table_name + yield segments[3], table_name if ( permissions.ACTION_CAN_ACCESS_MENU,