dimberman commented on a change in pull request #8219: Add migration waiting
script and log cleaner
URL: https://github.com/apache/airflow/pull/8219#discussion_r408833820
##########
File path: airflow/utils/db.py
##########
@@ -561,6 +562,37 @@ def initdb():
Base.metadata.create_all(settings.engine) # pylint: disable=no-member
+def wait_for_migrations(timeout):
+ """
+ Function to wait for all airflow migrations to complete. Used for
launching airflow in k8s
+ @param timeout:
+ @return:
+ """
+ from alembic.config import Config
+ from alembic.runtime.migration import MigrationContext
+
+ package_dir = os.path.dirname(importlib.util.find_spec('airflow').origin)
+ directory = os.path.join(package_dir, 'migrations')
+ config = Config(os.path.join(package_dir, 'alembic.ini'))
+ config.set_main_option('script_location', directory)
+ config.set_main_option('sqlalchemy.url', settings.SQL_ALCHEMY_CONN)
+ script_ = ScriptDirectory.from_config(config)
Review comment:
Fixed
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services