Page MenuHomePhabricator

CI for Airflow 3
Closed, ResolvedPublic

Description

Update .gitlab-ci.yml, blubber, ci-related code, and deployment-charts so the Airflow 2 and Airflow 3 are stored in different images, and so that the MR pipeline uses correct image to run tests with.


Hi, I have a question about kokkuri and docker images building. As far as I understood, .kokkuri:build-and-publish-image publishes the image with the name that equals the name of the GitLab repository. We now have a situation where we prepare the upgrade for a piece of software, and rebuilding not-yet-production image a lot (with a separate tag) https://gitlab.wikimedia.org/repos/data-engineering/airflow-dags/-/blob/main/.gitlab-ci.yml?ref_type=heads#L42
Production images are build with the version and the latest tags, but not as frequently

I worry that we can accidentally evict all old airflow-2.*images from registry by continuing building new `airflow-3* images here https://docker-registry.wikimedia.org/repos/data-engineering/airflow-dags/tags/

So the questions are: 1) is this worry warranted, or the registry will keep at least one old image because it is tagged as latest, and 2) should it be better to have major versions as different images, and does kokkuri support it?

Event Timeline

Somewhat related to T437829, can't really rebuild images to setup CI until we clear this one. Maybe we want to periodically build production images and have a CD.

@elukey I have a question about docker-registry garbage collection

We publish 2 versions of the same software in one docker image https://docker-registry.wikimedia.org/repos/data-engineering/airflow-dags/tags/ . Old version, airflow-2* is running in prod, and is tagged with version tag and with latest tag on build, but rarely built (shame on us, we better have CD). New version is built frequently but published only with version tag.
I'm afraid that if I continue building new version, we can accidentally evict old verison from the registry. Is it correct assumption?

atsuko changed the task status from Open to In Progress.Sep 16 2026, 2:29 PM

Code that tests/conftest.py relies on is removed in Airflow 3.

On class `TaskInstance, functions run(), render_templates()`,
`get_template_context()`, and private members related to them have been
removed. The class has been considered internal since 3.0, and should not be
relied on in user code. (#59780, #59835)

To make CI working again, we'll need to re-implement how we instantiate a task in conftest.render_task_fixture based on how it is done now in TaskRunner RuntimeTaskInstance.parse.

I'll make work branch that removes most of the noise and ask help from DE.

Looks like there are some docs hinting at a way forward: https://airflow.apache.org/docs/apache-airflow/stable/best-practices.html

TaskInstance.run() and TaskInstance.render_templates() were removed in Airflow 3.2 — TaskInstance has been an internal class since Airflow 3.0. Replace ti.run() with op.execute(context) and ti.render_templates(context) with op.render_template_fields(context) as shown above.

Started a branch with the fixes and skips. It is now has zero failed tests, and fully disabled tests/conftest.py. Will make it pass mypy and start using it as a basis for CI with the new image that I'll try to merge tomorrow.

@EBernhardson thanks! I'll look into it. Airflow 3 provides some other test fixtures as well, e.g. dag_maker.

I will see if I'll be able to migrate this code, or will create task for this.

atsuko opened https://gitlab.wikimedia.org/repos/data-engineering/airflow-dags/-/merge_requests/2673

Configuring CI to enable running latest Airflow 3 images for main_airflow_3.3 branch tests

atsuko merged https://gitlab.wikimedia.org/repos/data-engineering/airflow-dags/-/merge_requests/2673

Configuring CI to enable running latest Airflow 3 images for main_airflow_3.3 branch tests

atsuko changed the task status from In Progress to Stalled.Sep 18 2026, 4:40 PM

I merged basic support for CI, will disengage from this task from now.

@MoritzMuehlenhoff @tstarling re: T437829, do you know when we will stop adding snapshots to the new repositories? our CI pipeline depends on installing additional packages to a base repository during test (so we don't have pip in runtime), and it fails CI in a week after building the base image, e.g. https://gitlab.wikimedia.org/repos/data-engineering/airflow-dags/-/jobs/968848#L235

@MoritzMuehlenhoff @tstarling re: T437829, do you know when we will stop adding snapshots to the new repositories? our CI pipeline depends on installing additional packages to a base repository during test (so we don't have pip in runtime), and it fails CI in a week after building the base image, e.g. https://gitlab.wikimedia.org/repos/data-engineering/airflow-dags/-/jobs/968848#L235

I created https://phabricator.wikimedia.org/T438866 for adapting debuerreotype, time permitting I'll work on this later the week.

@MoritzMuehlenhoff @tstarling re: T437829, do you know when we will stop adding snapshots to the new repositories? our CI pipeline depends on installing additional packages to a base repository during test (so we don't have pip in runtime), and it fails CI in a week after building the base image, e.g. https://gitlab.wikimedia.org/repos/data-engineering/airflow-dags/-/jobs/968848#L235

This is now fixed: https://phabricator.wikimedia.org/T438866#12369414

So once you re-deploy the CI images based on the latest base images from last night, this is addressed.

@MoritzMuehlenhoff I did rebuild it on the last image this morning (with Airflow 3.3.2), thanks.

Started with commenting pytest.skip("Not implemented yet.") and going into PDB

make test.interactive args=tests/test_on_disk_fixtures.py::test_kubernetes_pod_operator_against_fixtures
atsuko changed the task status from Stalled to In Progress.Oct 2 2026, 2:45 PM

The main problem with conftest is that the some of the Dag methods are now only available in SerialisedDag. Fortunately, the built-in test method (dag.test as described in https://airflow.apache.org/docs/apache-airflow/stable/core-concepts/debug.html#concepts-debugging) is able to serialise it, so we might want to copy the behaviour.

Repro

dev@085a7d6f9676:/opt/airflow$ AIRFLOW__CORE__LOAD_EXAMPLES=False AIRFLOW__CORE__DAGS_FOLDER=/opt/airflow/test_k8s/dags/ AIRFLOW__DAG_PROCESSOR__DAG_BUNDLE_STORAGE_PATH=/opt/airflow/test_k8s/dags/ python3
>>> import test_k8s.dags.datahub_cleanup_dag
>>> test_k8s.dags.datahub_cleanup_dag.dag
<DAG: Datahub_Cleanup>
>>> dagrun = test_k8s.dags.datahub_cleanup_dag.dag.test()
>>> dagrun.dag
<SerializedDAG: Datahub_Cleanup>

It started serialising configs now, https://gitlab.wikimedia.org/repos/data-engineering/airflow-dags/-/commit/a8d7790803b11125235699acd50483c78c51b754

Almost all tests are back 56 failed, 2909 passed, 28 skipped, I'll check if it easier to fix it or skip it and create upgrade task.

The next popular use-case is running the DAG in test-time, and inspecting the XCOM. This requires reimplementing a big part of DAG.test() T440709. Lots of these tests need to be fixed in main instance, cc @JAllemandou T435480.