Skip to content

Commit

Permalink
More verbose logs when running airflow check_migrations (#15662)
Browse files Browse the repository at this point in the history
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 apache/airflow#15650

GitOrigin-RevId: 86ad628158eb728e56c817eea2bea4ddcaa571c2
  • Loading branch information
kaxil authored and Cloud Composer Team committed Sep 23, 2021
1 parent 5a1f2ec commit 77bbccb
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion airflow/utils/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 77bbccb

Please sign in to comment.