Skip to content

Commit 67a7c7b

Browse files
committed
review feedback comments
1 parent a601a41 commit 67a7c7b

File tree

4 files changed

+12
-44
lines changed

4 files changed

+12
-44
lines changed

docs/modules/demos/pages/airflow-scheduled-job.adoc

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -131,31 +131,6 @@ image::airflow-scheduled-job/airflow_11.png[]
131131

132132
== Patching Airflow to stress-test DAG parsing using relevant environment variables
133133

134-
By default, Airflow runs database intialization routines on start-up.
135-
These check that an Admin user exists and that the database schema is up-to-date.
136-
Since they are idempotent and invoke little overhead, they can be run safely each time for most environments.
137-
If, however, it makes sense to deactivate this, it can be turned off by patching the running cluster with a resource definition such as this:
138-
139-
[source,yaml]
140-
----
141-
---
142-
apiVersion: airflow.stackable.tech/v1alpha1
143-
kind: AirflowCluster
144-
metadata:
145-
name: airflow
146-
spec:
147-
clusterConfig:
148-
databaseInitialization:
149-
enabled: false # <1>
150-
----
151-
<1> Turn off the initialization routine by setting `databaseInitialization.enabled` to `false`
152-
153-
NOTE: The field `databaseInitialization.enabled` is `true` by default to be backwards-compatible.
154-
A fresh Airflow cluster cannot be created with this field set to `false` as this results in missing metadata in the Airflow database.
155-
156-
WARNING: Setting `databaseInitialization.enabled` to `false` is an unsupported operation as subsequent updates to a running Airflow cluster can result in broken behaviour due to inconsistent metadata.
157-
Only set `databaseInitialization.enabled` to `false` if you know what you are doing!
158-
159134
The demo also created a third DAG in the ConfigMap, called `dag_factory.py`, which was not mounted to the cluster and therefore does not appear in the UI.
160135
This DAG can be used to create a number of individual DAGs on-the-fly, thus allowing a certain degree of stress-testing of the DAG scan/register steps (the generated DAGs themselves are trivial and so this approach will not really increase the burden of DAG _parsing_).
161136
To include this in the list of DAGs (without removing the existing ones), an extra volumeMount is needed, as shown below.
@@ -170,8 +145,6 @@ metadata:
170145
name: airflow
171146
spec:
172147
clusterConfig:
173-
databaseInitialization:
174-
enabled: false
175148
volumeMounts:
176149
- name: airflow-dags
177150
mountPath: /dags/dag_factory.py
@@ -203,6 +176,18 @@ spec:
203176
envOverrides: *envOverrides
204177
----
205178

179+
THe patch can be applied like this:
180+
181+
[source,console]
182+
----
183+
kubectl patch airflowcluster airflow --type="merge" --patch-file stacks/airflow/patch_airflow.yaml
184+
----
185+
186+
[NOTE]
187+
====
188+
The scheduled job runs every minute and so an instance of it may be running while the scheduler is being re-started as a result of the patch, in which case that instance may fail.
189+
====
190+
206191
== Summary
207192

208193
This demo showed how DAGs can be made available for Airflow, scheduled, run and then inspected with the Webserver UI.

stacks/_templates/redis-airflow.yaml

Lines changed: 0 additions & 14 deletions
This file was deleted.

stacks/airflow/airflow.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,4 +345,3 @@ stringData:
345345
adminUser.password: "{{ airflowAdminPassword }}"
346346
connections.secretKey: "{{ airflowSecretKey }}"
347347
connections.sqlalchemyDatabaseUri: postgresql+psycopg2://airflow:airflow@postgresql-airflow/airflow
348-
connections.celeryResultBackend: db+postgresql://airflow:airflow@postgresql-airflow/airflow

stacks/airflow/patch_airflow.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ metadata:
55
name: airflow
66
spec:
77
clusterConfig:
8-
databaseInitialization:
9-
enabled: false
108
volumeMounts:
119
- name: airflow-dags
1210
mountPath: /dags/dag_factory.py

0 commit comments

Comments
 (0)