Managed Airflow Migrations

Managed Airflow Migrations

Migrates Apache Airflow DAGs in Managed Airflow to Airflow 2.11.1 or Airflow 3, inspecting the environment, downloading DAGs and scanning for breaking changes.

Skill files5 files

references/

SKILL.md344 lines
1
---
2
name: managed-airflow-migrations
3
description: Provides guidance for migrating Apache Airflow DAGs in Managed Service for Apache Airflow (MSAA; formerly Cloud Composer). Covers migration to Airflow 2.11.1 (MSAA Gen 2 and 3) and Airflow 3 (MSAA Gen 3), including environment inspection, GCS download/upload and scanning patterns for breaking changes. Use when migrating the DAG code to newer Airflow version. Don't use when checking DAG run failures unrelated to code migration.
4
metadata:
5
version: "1.0.1"
6
category: BigDataAndAnalytics
7
---
8
9
# Managed Service for Apache Airflow (formerly Cloud Composer) Migration Guide
10
11
This skill guides you through the process of adjusting Airflow DAGs from an
12
existing Managed Service for Apache Airflow (formerly Cloud Composer)
13
environment (or available locally) to make them compatible with **Airflow
14
2.11.1** (MSAA Gen 2 or 3) or **Airflow 3** (MSAA Gen 3).
15
16
--------------------------------------------------------------------------------
17
18
## Attribution
19
20
**MUST READ**: Before executing any `gcloud`, REST API, or MCP command, you
21
MUST read [Usage Attribution](references/attribution.md). For commands executed
22
directly in the terminal (never in generated scripts, Terraform, or user code),
23
prefix `gcloud` with
24
`CLOUDSDK_METRICS_REQUEST_ATTRIBUTION="agent-skills/1.0 (skill:managed-airflow-migrations)"`
25
and append `agent-skills/1.0 (skill:managed-airflow-migrations)` to `User-Agent` headers.
26
27
## Phase 1: Discovery & Download
28
29
Before making any changes, download the existing DAG files if explicitly
30
requested. Inspect the source environment to confirm source version only if
31
explicitly requested. For detailed instructions about environment inspection and
32
downloading files check
33
[references/environment-inspection.md](references/environment-inspection.md).
34
35
--------------------------------------------------------------------------------
36
37
## Phase 2: Target Version & Dependency Mapping
38
39
### 2.1 Airflow 2.11.1+ Dependency Mapping
40
41
If migrating to Airflow 2.11.1 (MSAA Gen 2) or Airflow 3, use the list below to
42
trace the version progression of key dependencies. The list covers changes
43
needed to get to Airflow 2.11.1. Take them into account when migrating from
44
Airflow 2 (earlier than 2.11.1) to Airflow 3.
45
46
### Composer 2.10.0 (Airflow 2.10.2)
47
48
- **Google Provider**: `10.26.0`
49
- **SSH Provider**: `3.14.0`
50
- **HTTP Provider**: `4.13.3`
51
- **Breaking Changes**: *Baseline for oldest fully documented source.*
52
53
### Composer 2.15.3 (Airflow 2.10.5)
54
55
- **Google Provider**: `18.0.0`
56
- **SSH Provider**: `4.1.4`
57
- **HTTP Provider**: `5.3.4`
58
- **Breaking Changes**:
59
- **SSH Provider 4.0.0:** Hook `timeout` removed; `get_conn()` context
60
manager.
61
- **HTTP Provider 5.0.0:** `SimpleHttpOperator` -> `HttpOperator`.
62
- **Google Provider 11.0.0:** `BigQueryExecuteQueryOperator` removed.
63
- **Google Provider 12.0.0:** Legacy Data Pipeline operators removed.
64
- **Google Provider 13.0.0:** `AutoMLBatchPredictOperator` removed.
65
- **Google Provider 17.0.0:** `BigQueryCreateEmptyTableOperator` and
66
`BigQueryCreateExternalTableOperator` removed; Life Sciences operators
67
removed.
68
- **Google Provider 18.0.0:** Legacy DV360 operators removed.
69
70
### Composer 2.16.1 (Airflow 2.10.5)
71
72
- **Google Provider**: `19.0.0`
73
- **SSH Provider**: `4.1.6`
74
- **HTTP Provider**: `5.5.0`
75
- **Breaking Changes**: **Google Provider 19.0.0:** AutoML operators removed
76
(use Vertex AI).
77
78
### Composer 2.17.0 (Target Airflow 2.11.1)
79
80
- **Google Provider**: **`20.0.0`**
81
- **SSH Provider**: **`5.0.0`**
82
- **HTTP Provider**: **`6.0.2`**
83
- **Breaking Changes**:
84
- **SSH Provider 5.0.0:** `sshtunnel` removed (native tunneling).
85
- **HTTP Provider 6.0.0:** JSON serialization.
86
- **Google Provider 20.0.0:** ADLS Gen2 migration.
87
88
### 2.2 Airflow 3 Migration
89
90
If migrating to Airflow 3 (MSAA Gen 3), note that this is a major version
91
upgrade with significant changes, including:
92
93
* Decoupled Task SDK (imports change from `airflow` to `airflow.sdk`).
94
* Removal of direct metadata DB access.
95
* Renaming of `Dataset` to `Asset`.
96
* Removal of SubDAGs and SLAs.
97
* Changes to context variables availability.
98
99
Take into account all applicable changes within Airflow 2 (e.g. when migrating
100
from Airflow 2.10.2, apply changes needed to move to Airflow 2.11.1 and Airflow
101
3 migration changes on top of that).
102
103
--------------------------------------------------------------------------------
104
105
## Phase 3: Analysis & Remediation (Scanning Downloaded Files)
106
107
Run the scan commands from the root of your local workspace
108
(`./migration_workspace` unless indicated otherwise).
109
110
--------------------------------------------------------------------------------
111
112
### 3.1 Airflow 2.11.1 Core & Dependency checks
113
114
Use these scans if migrating to Airflow 2.11.1+ (intermediate step when
115
migrating to Airflow 3).
116
117
#### 3.1.1 Dataset Scheduling (Airflow 2.11.0)
118
119
* **Change:** DAGs scheduled on datasets only trigger if events occur while
120
the DAG is unpaused.
121
* **Scan Command:** `grep -rn "Dataset(" ./dags`
122
* **Remediation:** You MUST document that these DAGs must remain unpaused to
123
catch events, or plan manual triggers for catch-up.
124
125
#### 3.1.2 HTML in Descriptions (Airflow 2.11.0)
126
127
* **Change:** Raw HTML in DAG docs / params is escaped by default.
128
* **Scan Command:**
129
130
```bash
131
grep -rn -E "doc_md.*<|doc_md.*>|description.*<|description.*>" ./dags
132
```
133
134
* **Remediation:** Convert HTML to Markdown, or set
135
`AIRFLOW__WEBSERVER__ALLOW_RAW_HTML_DESCRIPTIONS=True` in target.
136
137
#### 3.1.3 Teardown Tasks (Airflow 2.10.5)
138
139
* **Change:** Teardowns always run when a DAG is marked failed.
140
* **Scan Command:** `grep -rn "as_teardown" ./dags`
141
* **Remediation:** Ensure teardown tasks are idempotent.
142
143
#### 3.1.4 Pendulum 3 Upgrade (Airflow 2.11.0)
144
145
* **Change:** `Period` renamed to `Interval`, testing helpers removed.
146
* **Scan Command (Code):**
147
148
```bash
149
grep -rn -E "pendulum\.Period|pendulum\.period" ./dags
150
```
151
152
* **Scan Command (Tests):**
153
154
```bash
155
grep -rn -E "\.test\(|set_test_now\(" ./tests 2>/dev/null || true
156
```
157
158
* **Remediation:** Replace `Period` with `Interval`, and `period(...)` with
159
`interval(...)`.
160
161
--------------------------------------------------------------------------------
162
163
### 3.2 Path A: Airflow 2.11.1 Provider Package Scan
164
165
#### 3.2.1 SSH Provider (SSH 4.0.0 & 5.0.0)
166
167
* **Scan Command (Timeout):** `grep -rn "SSHHook" ./dags | grep "timeout"`
168
* **Scan Command (Context Manager):** `grep -rn "with SSHHook" ./dags`
169
* **Scan Command (Tunnel Attributes):** `grep -rn "\.get_tunnel" ./dags`
170
* **Remediation:**
171
* Replace `timeout` with `conn_timeout` in `SSHHook`.
172
* Replace `with hook as conn:` with `with hook.get_conn() as conn:`.
173
* Use `get_tunnel()` as context manager: `with hook.get_tunnel(...) as
174
tunnel:`.
175
176
#### 3.2.2 HTTP Provider (HTTP 5.0.0 & 6.0.0)
177
178
* **Scan Command:** `grep -rn "SimpleHttpOperator" ./dags`
179
* **Remediation:** Replace `SimpleHttpOperator` with `HttpOperator`.
180
181
#### 3.2.3 Google Provider (v11 to v20)
182
183
* **Scan Command (BigQuery query):**
184
185
```bash
186
grep -rn "BigQueryExecuteQueryOperator" ./dags
187
```
188
189
* *Remediation:* Replace with `BigQueryInsertJobOperator` (use
190
`configuration` dict).
191
* **Scan Command (BigQuery table):**
192
193
```bash
194
grep -rn -E "BigQueryCreateEmptyTableOperator|BigQueryCreateExternalTableOperator" ./dags
195
```
196
197
* *Remediation:* Replace with `BigQueryCreateTableOperator` (use
198
`table_resource` dict).
199
* **Scan Command (AutoML):**
200
201
```bash
202
grep -rn -E "AutoMLTrainModelOperator|AutoMLPredictOperator|AutoMLCreateDatasetOperator|AutoMLBatchPredictOperator" ./dags
203
```
204
205
* *Remediation:* Migrate to Vertex AI operators.
206
* **Scan Command (Dataflow):**
207
208
```bash
209
grep -rn -E "CreateDataPipelineOperator|RunDataPipelineOperator" ./dags
210
```
211
212
* *Remediation:* Replace with
213
`DataflowCreatePipelineOperator`/`DataflowRunPipelineOperator`.
214
* **Scan Command (Life Sciences):**
215
216
```bash
217
grep -rn "LifeSciencesRunPipelineOperator" ./dags`
218
```
219
220
* *Remediation:* Migrate to Google Cloud Batch operators
221
(`BatchCreateJobOperator`).
222
* **Scan Command (ADLS to GCS):** `grep -rn "ADLSToGCSOperator" ./dags`
223
* *Remediation:* Ensure `file_system_name` is provided.
224
225
--------------------------------------------------------------------------------
226
227
### 3.3 Airflow 3 Migration checks
228
229
Use instructions from [references/airflow-3.md](references/airflow-3.md) when
230
migrating to Airflow 3.
231
232
--------------------------------------------------------------------------------
233
234
## Phase 4: Deployment & Verification
235
236
*Perform deployment and verification steps only if explicitly requested to do
237
so.*
238
239
### 4.1 Static Verification (when migrating to Airflow 3)
240
241
After applying code changes for Airflow 3, verify syntax correctness. If
242
available in the development environment, run static lint checks:
243
244
```bash
245
ruff check {target_dag_file} --select AIR30
246
```
247
248
Resolve any reported deprecation warnings before finalization. If ruff is not
249
available, recommend installing one.
250
251
### 4.2 Deployment to MSAA
252
253
#### 4.2.1 Get Target GCS Bucket Path (only when requested)
254
255
```bash
256
gcloud composer environments describe <TARGET_ENV> \
257
--location <TARGET_REGION> \
258
--format="value(config.dagGcsPrefix)"
259
```
260
261
*Expected Output:* `gs://<target-bucket-name>/dags`
262
263
### 4.2 Upload Modified DAGs and Bucket Dependencies (Only when requested)
264
265
*Perform this step only if explicitly requested to do so.* Copy the modified
266
DAGs and any backed-up bucket dependencies from your local workspace to the
267
target GCS bucket. *If you skipped the inspection step, ensure you have the
268
correct `<target-bucket-name>`.*
269
270
1. **Upload DAGs:**
271
272
```bash
273
gcloud storage cp -r ./dags/* gs://<target-bucket-name>/dags/
274
```
275
276
2. **Upload Other Bucket Dependencies (If applicable):**
277
278
```bash
279
gcloud storage cp -r ./migration_workspace/<dependency-folder> gs://<target-bucket-name>/<dependency-folder>
280
```
281
282
### 4.3 Verify DAGs via Airflow CLI
283
284
*Perform this step only if explicitly requested to upload modified DAGS to a
285
target environment (and after uploading).*
286
287
You can verify that your DAGs have been successfully uploaded, parsed, and
288
registered by the Airflow scheduler in the target environment using the Airflow
289
CLI.
290
291
1. **List Registered DAGs:** Run the following command to list all DAGs
292
registered in the target environment. Verify that your migrated DAGs appear
293
in this list.
294
295
```bash
296
gcloud composer environments run <TARGET_ENV> \
297
--location <TARGET_REGION> \
298
dags list
299
```
300
301
2. **Check for Import Errors:** If some DAGs are missing from the list, or to
302
ensure there are no parsing issues, check for import errors:
303
304
```bash
305
gcloud composer environments run <TARGET_ENV> \
306
--location <TARGET_REGION> \
307
dags list-import-errors
308
```
309
310
*Expected Output:*
311
312
* If there are no errors, the command will output `No data found`.
313
* If there are errors, it will list the file path and the traceback of the
314
error.
315
316
*Note: It may take a couple of minutes for the Airflow scheduler to parse the
317
new files and for changes to reflect in these commands.*
318
319
### 4.4 Verify in Cloud Logging
320
321
*Perform this step only if explicitly requested to upload modified DAGS to a
322
target environment (and after uploading).* Monitor Cloud Logging for the target
323
environment to detect any runtime errors or import errors.
324
325
Run the following query in the **GCP Cloud Logging Console** (or via `gcloud
326
logging read`):
327
328
```query
329
resource.type="cloud_composer_environment"
330
resource.labels.environment_name="<TARGET_ENV>"
331
log_id("airflow-scheduler")
332
severity>=ERROR
333
```
334
335
--------------------------------------------------------------------------------
336
337
## Appendix: Local Environment Verification
338
339
If you want to verify your changes locally before deploying to the target
340
environment, you can use the Composer Local Development CLI tool
341
(`composer-dev`). Use
342
[references/local-development-environment.md](references/local-development-environment.md)
343
as a reference for interactions with local development environments.
344

© Google LLC · Apache 2.0 · source · posted by @OpenSourceBuffGuy on promptparty.com

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 11,978 prompts

More by @OpenSourceBuffGuy

See all
Luxury Skincare Vial Product Shot prompt image

Luxury Skincare Vial Product Shot

Renders a luxury skincare commercial photo of a faceted crystal elixir vial on an ivory marble pedestal with orchids and golden droplets, specified as JSON.

image-prompt, json-prompt, gpt-image, product-photography, luxury, photorealistic, studio-lighting, packaging-design, still-life, bokeh, text-rendering, flowers, structured-output, for-marketers, for-designers, low-angle, advertising, beauty, skincare, dramatic-lighting

Black ink doodle portrait with floral border prompt image

Black ink doodle portrait with floral border

Turns a reference photo into a whimsical black ink doodle portrait with a floral doodle border, keeping likeness and expression.

image-prompt, line-art, ink-drawing, doodle, sketch, portrait, face-reference, reference-image, style-transfer, nano-banana, black-and-white, flowers, whimsical, illustration, drawing, avatar, prompt-weights, limited-palette, vertical-format, for-artists, quick

Pixar 3D Character Design Sheet prompt image

Pixar 3D Character Design Sheet

Makes a Pixar-style 3D character sheet pitting a pole vaulter against his vault, with poses, stat bars, a title and a cinematic close-up strip.

image-prompt, gpt-image, pixar-style, 3d-render, character-design, character-sheet, character-consistency, multi-panel, white-background, text-rendering, sports, cartoon, vibrant-colors, cinematic, close-up, man, poster, structured-output, for-artists, for-designers, long-form, humorous

Reviews

Loading reviews…

Discussion

Loading comments…