Skip to content

Commit

Permalink
Simplify flash message for _airflow_moved tables (#23635)
Browse files Browse the repository at this point in the history
Co-authored-by: Jed Cunningham <66968678+jedcunningham@users.noreply.github.com>
(cherry picked from commit b686678)
  • Loading branch information
dstandish authored and jedcunningham committed May 26, 2022
1 parent 4ba96b8 commit 7ee739b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
26 changes: 19 additions & 7 deletions airflow/www/templates/airflow/dags.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 <code>{{ original_table_name }}</code> table in the
metadatabase, and has moved them to <code>{{ moved_table_name }}</code> during the database migration
to upgrade. Please inspect the moved data to decide whether you need to keep them, and manually drop
the <code>{{ moved_table_name }}</code> 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:<br>
<table>
<tr>
<th style="padding-right:10px">Source table</th>
<th>Table with moved rows</th>
</tr>
{% for original_table_name, moved_table_name in migration_moved_data_alerts %}
<tr>
<td style="padding-right:10px"><code>{{ original_table_name }}</code></td>
<td><code>{{ moved_table_name }}</code></td>
</tr>
{% endfor %}
</table>
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 <a href={{ get_docs_url("installation/upgrading.html") }}><b>Upgrading</b></a>.
{% endcall %}
{% endfor %}
{% endif %}
{{ super() }}
{% if sqlite_warning | default(true) %}
{% call show_message(category='warning', dismissible=false) %}
Expand Down
4 changes: 2 additions & 2 deletions airflow/www/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 7ee739b

Please sign in to comment.