npx skills add ...
npx skills add google/skills --skill managed-airflow-dag-troubleshooting
Provides guidance for troubleshooting Apache Airflow DAGs (failed DAG runs and task instances) in Managed Service for Apache Airflow (MSAA; formerly Cloud Composer). Use when figuring out reasons for DAG run or task instance failures. Don't use when looking for overall recommendations for Managed Airflow environment performance.
npx skills add google/skills --skill managed-airflow-dag-troubleshooting
This skill provides instructions for troubleshooting Managed Airflow DAGs (DAG
runs and task instances), utilizing gcloud composer, gcloud logging and
gcloud storage commands to fetch remote logs and code.
Provide suggestions on how to troubleshoot the failed jobs. Provide only the steps that the user can actually take. Ground all troubleshooting advice in direct findings.
When troubleshooting a failure, follow the following practices to always provide a deterministic diagnosis:
Fetch relevant logs: Always fetch the logs for a task under
investigation using gcloud logging read; check the logs for specific
error patterns: Python tracebacks, API error codes (e.g., 400, 403, 404,
500), or Airflow signals (e.g., AirflowTaskTimeout).
Fetch task metadata: When troubleshooting a task, fetch the task state and metadata (execution state, try number, timestamps, and execution details) using:
or for an individual task instance:
Retrieve and compare DAG source code: Download the remote DAG source
code using gcloud storage cp gs://{bucket_name}/dags/{dag_file}.py .
(find the environment bucket via gcloud composer environments describe {env_name} --location {location} --format="value(config.dagGcsPrefix)"). Compare the parameters in the
code (e.g., table IDs, disk sizes, URI paths) against the error messages
found in the task logs.
Explain code mistakes and potential fixes: Explain mistakes in the code (if any are actually visible); suggest potential fixes (if they are very likely to be meaningful); discuss source code availability if needed - if some source code is unavailable (e.g. imported from a file other than the main source code file), mention this (you can mention the package name) - in such a case take into account most likely trigger rules if they are unknown.
Check for environment-level errors: Query Cloud Logging with gcloud logging read to see if there are high-level environment issues or known
platform errors correlating with the failure (see Known issues
below). You MUST return ALL found issues.
Identify failing tasks in a DAG run: When troubleshooting a failed
DAG run, mention the task that caused a failure (use tasks states-for-dag-run or Cloud Logging to identify failed tasks). Provide
a task instance name. If many tasks failed, mention which task was
critical (mandatory for successful DAG run execution - look into task
dependencies and trigger rules) and focus on this one.
Verify service configurations in code: If logs suggest an issue with a specific service (e.g., BigQuery, Dataform, Compute Engine), use the log details to verify the configuration in the DAG source code.
Correlate logs with code: E.g., if BigQuery returns a 404, verify the dataset ID or table ID in the DAG source code matches reality.
Prioritize known platform issues: Check against Known issues below. If Cloud Logging queries return matching platform error signals, prioritize that diagnosis.
Summarize with Evidence (Deterministic Response): Your response must be specific. Avoid general advice like 'check your permissions.' or 'check the logs.' Instead, say 'The service account is missing X permission.'
textPayload) or the specific line of code from the DAG that caused
the failure. Do not summarize the evidence; show the data.DAGs Generated by Orchestration Pipelines: Some DAGs may be generated by Orchestration Pipelines. A special requirement related to those DAGs is the need to explain the failure in terms of the logical actions defined in the pipeline YAML.
bundle_name, version_id, and pipeline_name set in their DAG Run
metadata (DagRun.note that contains JSON metadata). All of them (i.e.
Orchestration Pipeline DAGs deployed by dedicated tools and created
manually) have an op:orchestration_pipeline tag set (DAG properties,
including tags, can be verified in the DAG source code or via gcloud composer environments run {env_name} --location {location} dags list).op:pipeline, e.g. op:pipeline:xyz indicates
a name xyzop:bundleop:versiongcloud storage cp gs://{bucket_name}/dags/{dag_file}.py . (or
gcloud storage cat gs://{bucket_name}/dags/{dag_file}.py).generate or generate_dags
function calls:
generate call found. The first argument is the
path to the YAML file - relative to the dags folder in
environment's bucket.generate_dags call found.
/home/airflow/gcs/, remove this prefix
to get a path relative to the root of environment's
bucket.bundle_name, version_id, and pipeline_name
(as explained above).{data_directory}/{bundle_name}/versions/{version_id}/{pipeline_name}.yml
(or .yaml).data/{bundle_name}/versions/{version_id}/{pipeline_name}.yml
(or .yaml) in an environment's bucket.gcloud storage cp gs://{bucket_name}/{yaml_path} . (or gcloud storage cat gs://{bucket_name}/{yaml_path}).op_action_name in task note).gcloud storage cp gs://{bucket_name}/{asset_path} .). If they are in a custom artifact
bucket (see GCS URIs in logs/config), note the limitation that they
cannot be read directly but analyze based on available logs.You can assume that environment variables set by default (they can be used
in DAG code, but are not visible in custom environment configuration), e.g.
GCS_BUCKET, are correct - users cannot change them.
"Not found" (404) errors from GCP APIs can be misleading. A "not found" error might be returned when a resource actually exists, but the caller does not have permissions to access or view it. If a resource is expected to exist, suggest verifying proper permissions.
When the RCA is complete and a fix is ready:
List composer environments:
Describe environment (get DAGs bucket and config):
List composer DAGs:
List composer DAG Runs:
List task instance states for a DAG run:
Get state of a specific task instance:
Fetch error logs for a DAG / Task:
Fetch scheduler logs for environment failures:
Download DAG code from GCS:
Download pipeline YAML definition or script from GCS:
Use gcloud logging read with the queries below to identify specific known
platform failure modes:
Issue summary: The task instance execution was interrupted because a timeout for a DAG was exceeded. Unfinished tasks were marked as 'SKIPPED' or failed.
Cloud Logging Query:
Issue summary: Task failed because it remained queued longer than the maximum allowed queue time.
Cloud Logging Query:
Remediation: Consider increasing worker resources (CPU, memory, worker
count) or adjusting [celery]worker_concurrency.
Issue summary: Task reached DAG run timeout because task was stuck in queue for too long.
Cloud Logging Query:
Remediation: Consider increasing the timeout or reducing the load on the environment.
Issue summary: Task failed because of a BigQuery job failure inside a BigQuery operator.
Cloud Logging Query:
Remediation: Inspect the worker logs for the BigQuery Job ID (Job ID: ...) to diagnose the underlying query error or permissions issue.
Issue summary: The task instance was revoked by the executor due to
missing heartbeats. Task instances send heartbeats periodically (every
job_heartbeat_sec, 5 seconds by default) and if heartbeats are missing for
scheduler_zombie_task_threshold (300 seconds by default), the task is
considered a zombie and marked as failed or up for retry.
Cloud Logging Query:
Remediation: This can happen when a worker is overloaded (CPU/memory starvation) and unable to send heartbeats on time, a worker was terminated with unfinished tasks (OOM kill/eviction), or the metadata database is overloaded. Check worker metrics and consider scaling worker CPU/memory.
Issue summary: Task instance failed because a worker is running out of pod storage (ephemeral disk space reached or pod evicted due to storage limits).
Cloud Logging Query:
Remediation: Update the worker storage configuration according to the amount of data being stored or clean up temporary files created during task execution.