From ba2fa02e83c2125a5e9a45631bfb5ec8ccf95774 Mon Sep 17 00:00:00 2001 From: Ephraim Anierobi Date: Wed, 1 Jun 2022 10:53:19 +0100 Subject: [PATCH] Run the `check_migration` loop at least once This is broken since 2.3.0. that's if a user specifies a migration_timeout of 0 then no migration is run at all. --- airflow/utils/db.py | 1 + tests/utils/test_db.py | 1 + 2 files changed, 2 insertions(+) diff --git a/airflow/utils/db.py b/airflow/utils/db.py index 1e2adbadbb79a..c289e7366ad15 100644 --- a/airflow/utils/db.py +++ b/airflow/utils/db.py @@ -691,6 +691,7 @@ def check_migrations(timeout): :param timeout: Timeout for the migration in seconds :return: None """ + timeout = timeout or 1 # run the loop at least 1 with _configured_alembic_environment() as env: context = env.get_context() source_heads = None diff --git a/tests/utils/test_db.py b/tests/utils/test_db.py index e2ea0168c3926..752f9873aaa5a 100644 --- a/tests/utils/test_db.py +++ b/tests/utils/test_db.py @@ -96,6 +96,7 @@ def test_default_connections_sort(self): def test_check_migrations(self): # Should run without error. Can't easily test the behaviour, but we can check it works + check_migrations(0) check_migrations(1) @mock.patch('alembic.command')