whilst I succeed in deploying the latest Airflow tags vis-a-vis 2.7* using helm charts on my minikube cluster, I really want to at first, deploy airflow 2.5.* i.e
apache/airflow:slim-2.5.1-python3.7
, which is failing as:
client.go:607: [debug] airflow-run-airflow-migrations: Jobs active: 1, jobs failed: 0, jobs succeeded: 0
Error: failed post-install: timed out waiting for the condition
helm.go:84: [debug] failed post-install: timed out waiting for the condition
Let me walk you through the entire setup, and the things I have tried:
My Docker Image:
FROM apache/airflow:2.5.1-python3.7
...
so as you can see, I am trying to pull and build top of airflow image with version/tag 2.5.1
I build my image as: docker build -t my-airflow:unified . -f local.dockerfile
Then, I try to deploy the above to my minikube cluster, via helm.
helm upgrade --namespace airflow --install airflow apache-airflow/airflow --set images.airflow.repository=my-airflow --set images.airflow.tag=unified --create-namespace --debug --version 1.8.0
the reason, I put "version" is, because for airflow 2.5.1, I am supposed to use the Helm Charts version "1.8.0", which I found from helm search repo airflow -l
, which outputs:
NAME CHART VERSION APP VERSION DESCRIPTION
apache-airflow/airflow 1.10.0 2.6.2 The official Helm chart to deploy Apache Airflo...
apache-airflow/airflow 1.9.0 2.5.3 The official Helm chart to deploy Apache Airflo...
apache-airflow/airflow 1.8.0 2.5.1 The official Helm chart to deploy Apache Airflo...
thus, I realised I must explicitly provide a --version
for correct airflow to be installed.
However, I see that the deployment, eventually fails. This is so because "airflow-run-flow-migrations" pod fails.
When I see the Logs of the pod, these are as follows:
DB: postgresql://postgres:***@airflow-postgresql.airflow:5432/postgres?sslmode=disable
Performing upgrade with database postgresql://postgres:***@airflow-postgresql.airflow:5432/postgres?sslmode=disable
[2023-10-16T14:02:39.388+0000] {migration.py:205} INFO - Context impl PostgresqlImpl.
[2023-10-16T14:02:39.389+0000] {migration.py:212} INFO - Will assume transactional DDL.
[2023-10-16T14:02:39.396+0000] {db.py:1571} INFO - Creating tables
INFO [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO [alembic.runtime.migration] Will assume transactional DDL.
Traceback (most recent call last):
File "/home/airflow/.local/lib/python3.7/site-packages/alembic/script/base.py", line 233, in _catch_revision_errors
yield
File "/home/airflow/.local/lib/python3.7/site-packages/alembic/script/base.py", line 443, in _upgrade_revs
for script in reversed(list(revs))
File "/home/airflow/.local/lib/python3.7/site-packages/alembic/script/revision.py", line 802, in iterate_revisions
assert_relative_length=assert_relative_length,
File "/home/airflow/.local/lib/python3.7/site-packages/alembic/script/revision.py", line 1452, in _collect_upgrade_revisions
current_revisions = self.get_revisions(lower)
File "/home/airflow/.local/lib/python3.7/site-packages/alembic/script/revision.py", line 525, in get_revisions
return sum([self.get_revisions(id_elem) for id_elem in id_], ())
File "/home/airflow/.local/lib/python3.7/site-packages/alembic/script/revision.py", line 525, in <listcomp>
return sum([self.get_revisions(id_elem) for id_elem in id_], ())
File "/home/airflow/.local/lib/python3.7/site-packages/alembic/script/revision.py", line 552, in get_revisions
for rev_id in resolved_id
File "/home/airflow/.local/lib/python3.7/site-packages/alembic/script/revision.py", line 552, in <genexpr>
for rev_id in resolved_id
File "/home/airflow/.local/lib/python3.7/site-packages/alembic/script/revision.py", line 633, in _revision_for_ident
resolved_id,
alembic.script.revision.ResolutionError: No such revision or branch '405de8318b3a'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/airflow/.local/bin/airflow", line 8, in <module>
sys.exit(main())
File "/home/airflow/.local/lib/python3.7/site-packages/airflow/__main__.py", line 39, in main
args.func(args)
File "/home/airflow/.local/lib/python3.7/site-packages/airflow/cli/cli_parser.py", line 52, in command
return func(*args, **kwargs)
File "/home/airflow/.local/lib/python3.7/site-packages/airflow/utils/cli.py", line 108, in wrapper
return f(*args, **kwargs)
File "/home/airflow/.local/lib/python3.7/site-packages/airflow/cli/commands/db_command.py", line 88, in upgradedb
reserialize_dags=args.reserialize_dags,
File "/home/airflow/.local/lib/python3.7/site-packages/airflow/utils/session.py", line 75, in wrapper
return func(*args, session=session, **kwargs)
File "/home/airflow/.local/lib/python3.7/site-packages/airflow/utils/db.py", line 1578, in upgradedb
command.upgrade(config, revision=to_revision or "heads")
File "/home/airflow/.local/lib/python3.7/site-packages/alembic/command.py", line 378, in upgrade
script.run_env()
File "/home/airflow/.local/lib/python3.7/site-packages/alembic/script/base.py", line 569, in run_env
util.load_python_file(self.dir, "env.py")
File "/home/airflow/.local/lib/python3.7/site-packages/alembic/util/pyfiles.py", line 94, in load_python_file
module = load_module_py(module_id, path)
File "/home/airflow/.local/lib/python3.7/site-packages/alembic/util/pyfiles.py", line 110, in load_module_py
spec.loader.exec_module(module) # type: ignore
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/airflow/.local/lib/python3.7/site-packages/airflow/migrations/env.py", line 117, in <module>
run_migrations_online()
File "/home/airflow/.local/lib/python3.7/site-packages/airflow/migrations/env.py", line 111, in run_migrations_online
context.run_migrations()
File "<string>", line 8, in run_migrations
File "/home/airflow/.local/lib/python3.7/site-packages/alembic/runtime/environment.py", line 867, in run_migrations
self.get_context().run_migrations(**kw)
File "/home/airflow/.local/lib/python3.7/site-packages/alembic/runtime/migration.py", line 611, in run_migrations
for step in self._migrations_fn(heads, self):
File "/home/airflow/.local/lib/python3.7/site-packages/alembic/command.py", line 367, in upgrade
return script._upgrade_revs(revision, rev)
File "/home/airflow/.local/lib/python3.7/site-packages/alembic/script/base.py", line 443, in _upgrade_revs
for script in reversed(list(revs))
File "/usr/local/lib/python3.7/contextlib.py", line 130, in __exit__
self.gen.throw(type, value, traceback)
File "/home/airflow/.local/lib/python3.7/site-packages/alembic/script/base.py", line 265, in _catch_revision_errors
raise util.CommandError(resolution) from re
alembic.util.exc.CommandError: Can't locate revision identified by '405de8318b3a'
Now, I checked that this alembic revision '405de8318b3a' was actually added, in Airflow 2.7.0 onwards, and thus no denying the fact that, airflow 2.7.0 installs like a charm, which is not what I want. You may look up these alembic migration revisions here: https://airflow.apache.org/docs/apache-airflow/stable/migrations-ref.html
Now my question is:
-> why does an installation of airflow 2.5.1 has to honor a revision ID that came for subsequent versions?
-> how do I circumvent this? I also tried to look at the revisions.py
file but somewhere it is too much for me to debug and too cumbersome, that the help sought from an expert/been there done that amid the awesome SO community, can be better value for my time.