From c0a4645ea98bb0e40be4308f0f4155138762a7aa Mon Sep 17 00:00:00 2001 From: Kaxil Naik Date: Wed, 5 May 2021 06:30:11 +0100 Subject: [PATCH] More verbose logs when running `airflow check_migrations` (#15662) Currently it just shows "TimeoutError: There are still unapplied migrations after 60 seconds. " which is not that helpful. This commit adds more info to show the difference in migrations in DB and source code running `check_migrations`: Now: ``` TimeoutError: There are still unapplied migrations after 60 seconds. Migration Head(s) in DB: {'e165e7455d70'} | Migration Head(s) in Source Code: {'a13f7613ad25'} ``` closes https://github.com/apache/airflow/issues/15650 GitOrigin-RevId: 86ad628158eb728e56c817eea2bea4ddcaa571c2 --- airflow/utils/db.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/airflow/utils/db.py b/airflow/utils/db.py index 79e9c9f8e5a..979e0202527 100644 --- a/airflow/utils/db.py +++ b/airflow/utils/db.py @@ -613,7 +613,10 @@ def check_migrations(timeout): if source_heads == db_heads: break if ticker >= timeout: - raise TimeoutError(f"There are still unapplied migrations after {ticker} seconds.") + raise TimeoutError( + f"There are still unapplied migrations after {ticker} seconds. " + f"Migration Head(s) in DB: {db_heads} | Migration Head(s) in Source Code: {source_heads}" + ) ticker += 1 time.sleep(1) log.info('Waiting for migrations... %s second(s)', ticker)