Prepare and test your skills

Prepare and test your skills

A directed acyclic graph (DAG) (opens in a new tab) is a Python workflow file that defines tasks and the dependencies between them in an order that never loops back. The Managed Service for Apache Airflow (formerly Cloud Composer) (opens in a new tab) evaluates the whole file to build the execution graph, so every dependency must move forward from start to end without cycles. A DAG definition is the container that binds workflow identity, owner, start date, and schedule together, for example with with DAG(dag_id="controller_dag_to_trigger_other_dags", default_args={"owner": "airflow"}, start_date=days_ago(1), schedule_interval="@once") as dag:. Tasks such as DummyOperator are created inside that context with a unique task_id, and the bitshift operator >> connects them so control flows from the upstream task on the left to the downstream task on the right.
Parallel branches and ordered progression are expressed by combining single tasks and task lists with >>. A list such as [task_1, task_2] means the workflow depends on both tasks in parallel, while start >> [task_1, task_2] means control flows from start to both tasks at the same time. The pattern start >> [task_1, task_2] >> some_other_task >> [task_3, task_4] >> end executes in a fixed order:
start to task_1 and task_2, which run in parallel.task_1 and task_2 to some_other_task, which runs only after both parallel tasks succeed.some_other_task to task_3 and task_4, which run in parallel.task_3 and task_4 to end, which closes the workflow.This structure preserves acyclic properties because no downstream task points back to an upstream task. Logical progression is maintained by narrowing parallel branches back to a single task before fanning out again, which prevents ambiguous ordering and skipped dependencies.
TriggerDagRunOperator is the operator that triggers a child DAG run from within a parent controller DAG. The parent task defines task_id="dag_1", trigger_dag_id="dag-to-trigger", and conf={"message": "Hello World"}, where control flows from the parent task to a new run of the child DAG and the conf dictionary flows from the parent to the triggered run as configuration. The implementation requires two separate DAG files uploaded to the same Managed Airflow environment, with the parent using schedule_interval="@once" and the sequence start >> trigger_1 >> some_other_task >> trigger_2 >> end. The child DAG defines DAG_NAME = "dag-to-trigger" with schedule_interval="None", so the child DAG does not run on its own schedule and runs only when the parent task triggers it.
Exam tip: The value of trigger_dag_id must exactly match the dag_id of the DAG to trigger, and the triggered DAG uses schedule_interval="None" so it waits for the trigger.
Pausing an Airflow DAG is the operational control that stops the scheduler from launching new DAG runs while a failure is investigated. An operator pauses from the Scheduling page in the Google Cloud console by either opening the name of the DAG and then selecting Pause DAG on the DAG details page, or by selecting View actions in the Actions column for that row and then selecting Pause DAG. Pausing does not fix the underlying error, but it prevents additional failed runs, downstream tasks from consuming partial data, and alert noise while troubleshooting proceeds. Only after the DAG runs successfully should the DAG be unpaused to resume its schedule.
Checking for DAG errors is the ordered verification that confirms a DAG is syntactically valid and scheduled correctly in the Managed Airflow (Gen 3) environment. The check moves from static errors to runtime behavior:
This sequence matters because a DAG that parses cleanly can still fail at runtime, and a DAG that succeeds once in Gen 3 proves that its dependencies, connections, and timing are correct in the new environment. Investigating a failed run moves the pipeline from a failed state back to a successful state by opening the Executions tab, finding the failed run, selecting Investigate, reviewing logs for causes such as schema drift, applying the fix, and waiting for a successful rerun before closing the incident.
Optimizing DAG performance means reducing wasted scheduling work while keeping the Managed Airflow environment healthy. Pausing idle or migrating DAGs stops the scheduler from creating new runs for those DAGs, so they remain defined but do not consume scheduling attention. The Scheduling page with optional detail columns helps identify which DAGs are active, paused, or failing without opening each DAG individually. After DAGs and configuration are transferred, the Managed Airflow (Gen 3) environment should be monitored for failed runs and scheduling delays over a sufficient stable period, and only after that stable period should the legacy Gen 1 or Gen 2 environment be deleted.
Service perimeters and network boundaries are security controls that can block DAG work when required services are not allowed. Managed Airflow (Gen 3) environments protected by VPC Service Controls block calls to Google APIs, services, and domains that are not in the required set, and blocked calls cause DAG task failures and wasted retries. The perimeter must protect the core services that Managed Airflow depends on:
composer.googleapis.com)artifactregistry.googleapis.com)compute.googleapis.com)container.googleapis.com)containerfilesystem.googleapis.com)dns.googleapis.com)iamcredentials.googleapis.com)logging.googleapis.com)monitoring.googleapis.com)pubsub.googleapis.com)sqladmin.googleapis.com)storage.googleapis.com)For any additional service used by DAGs, such as aiplatform.googleapis.com for a Vertex AI Operator, the service must first be added to restricted services and then added to VPC accessible services. If the environment uses Shared VPC or Customer-Managed Encryption Keys (CMEK), the service project with the environment, the host project with the Shared VPC network, and the project hosting the Cloud Key Management Service keys must sit in the same service perimeter, because misalignment can block database operations and cause creation or update failures.
Continue with this study guide: Creating directed acyclic graphs (DAGs) for Cloud Composer
A managed Airflow environment is a self-contained Airflow deployment based on Google Kubernetes Engine (GKE) that runs schedulers, workers, and supporting services as one system. You can create one or more environments in a single Google Cloud project in any supported region, and Managed Airflow provisions the Google Cloud services and Airflow components for you. Data flows from the environment's Cloud Storage bucket to the GKE cluster, where the scheduler parses DAG files and workers execute tasks. The GKE cluster hosts schedulers, triggerers, workers, Composer Agent, and Airflow Monitoring, while logs flow outward to Cloud Logging and metrics flow outward to Cloud Monitoring.
The Airflow database sits behind the scheduler and web server to hold metadata about DAG runs, tasks, and state, and the Airflow web server reads that state to show DAG status in the Airflow user interface (UI). A directed acyclic graph (DAG) (opens in a new tab) defines task order so downstream tasks run only after upstream tasks complete, declared in code with >> and << as in hello_python >> goodbye_bash. For reliable parsing, define only one DAG object per Python module, group tasks inside DAGs instead of using SubDAGs, place parse-time files in the dags/ folder rather than data/, keep custom libraries in a nested directory inside a DAG ZIP archive, and add unit and pre-deployment tests. Secure execution separates environment management from DAG management, where environments are created through the console, CLI, API, or Terraform with project Identity and Access Management (IAM) roles, while DAGs are managed through the console, Airflow UI, or CLI with the Airflow access-control model.
An Airflow operator defines the type of work a task performs, while a task is a single instance of that operator inside a DAG. Choosing the correct operator controls where code runs, which service it calls, and how resources are used. BashOperator runs command-line programs on an Airflow worker, which is a Debian-based container that includes gcloud including gcloud storage, bq for BigQuery, and kubectl for GKE pods. Use BashOperator when the task wraps existing command-line automation.
PythonOperator runs arbitrary Python code in a container that includes packages for the environment's Managed Airflow image version, with extra packages added through managed dependency installation. Use PythonOperator for custom transformation, branching, or callback logic such as decoding Pub/Sub messages. Google Cloud operators execute natively in managed services, such as BigQueryInsertJobOperator sending SQL with destination project, dataset, and table to BigQuery, and transfer operators moving data between BigQuery and Cloud Storage. EmailOperator sends email from a DAG and can pull values from prior tasks with XCom, while email_on_failure sends alerts on failure and depends on SendGrid configuration with recipient, retry count, and retry delay.
Cloud Scheduler is a fully managed, time-driven scheduler for batch, streaming, and infrastructure jobs that must occur on defined intervals. Each job defines a name unique in the same region, a region such as us-central1, a frequency in unix-cron format, and a target such as Pub/Sub or HTTP. Documented frequency examples are */5 * * * * to run every 5 minutes and 30 16 * * 7 to send a message at 16:30 on Sundays. Cloud Scheduler evaluates the schedule in a configured time zone with a default of UTC, and it runs on wall clock time so daylight saving time can cause a job to run twice or not at all when local time repeats.
A Cloud Scheduler job configuration establishes the identity the scheduler uses, the permission that identity receives, and the schedule and payload it sends. The workflow depends on a service account for authentication, depends on IAM bindings for authorization, and depends on the target API for execution. Configuration follows an ordered workflow:
cloud-run-invoker so Cloud Scheduler can call the Workflows API or Cloud Run API, where the name must be 6 to 30 characters of lowercase letters, numbers, and dashes and cannot be changed later.roles/workflows.invoker on the project or roles/run.developer plus roles/iam.serviceAccountTokenCreator when the target is a Cloud Run job.Hello world! to a topic such as cron-topic, and an HTTP target sends POST to the Workflows execution endpoint or Cloud Run job run endpoint with body {}.cron-topic-sub or by checking Workflows execution and call logging.Retry policy controls what happens after an attempt fails or exceeds its deadline, with the Terraform representation setting attempt_deadline = "320s" and retry_config with retry_count = 3. Because Force run and automatic retry can both deliver duplicates, downstream logic must be idempotent and produce consistent results when the same payload arrives again.
Exam tip: Use UTC for Cloud Scheduler when exact cadence matters, because wall clock time in daylight saving time zones can cause a scheduled run to repeat or be skipped.
Event-driven chaining starts when a state change sends a message to a predefined Pub/Sub topic that decouples producers from executors. The publisher only writes to the topic while an agent installed in each virtual machine (VM) listens, pulls the next message, starts a pipeline in third-party software, waits for completion, then retrieves the next message. High availability comes from the global Pub/Sub endpoint visible from any Google Cloud location, while a message storage policy can pin persistence to specified regions or use customer-managed encryption keys (CMEK). A subscription can buffer unacknowledged messages for up to 7 days so delayed pipelines can resume with low data loss after an outage.
Dataflow (opens in a new tab) is a fully managed service for running Apache Beam jobs at scale with the same programming model for batch and streaming. Apache Beam provides windowing and session-analysis primitives plus source and sink connectors, including a connector for BigQuery, and supports Java, Python, and Go SDKs. When a Dataflow job runs, the Dataflow service allocates a pool of worker VMs, distributes data in parallel across them, and automatically deletes the VMs when the job completes or is cancelled. Dataflow can autoscale workers up or down and dynamically rebalance work, and it provides exactly-once processing of every record by default.
Cloud Data Fusion is a fully managed data integration service built on the open source CDAP project for building pipelines through a graphical interface. Developers connect sources to transformations, sinks, and other nodes to form a DAG in the Cloud Data Fusion UI. When deployed, the planner transforms that DAG into parallel computations executed as an Apache Spark job on Managed Service for Apache Spark. Sources can include databases accessed through Java Database Connectivity (JDBC) drivers, with data read, transformed, and loaded into destinations such as BigQuery without writing code.
Scheduling method selection starts by identifying whether workloads are event-driven, time-driven, or both. An event is a state change such as a database change or a file arriving in Cloud Storage, so an object landing in a bucket can trigger immediate processing. Time-driven scheduling loads or aggregates on a clock, such as once per day or hourly for reports, and both methods can combine when objects load into a data lake in real time while reports generate daily. An event-driven pattern can use a frequently scheduled controller DAG that polls for external events and then triggers target DAGs dynamically through subscribe, pull with XCom, and dynamic trigger steps.
Dataform (opens in a new tab) orchestration with Workflows executes in two ordered steps: first it pulls repository code from the Git provider and compiles it into a compilation result, then it creates and executes a workflow invocation from that result at the scheduled frequency. For production reliability, schedule with release configurations rather than passing gitCommitish on every run, because cloning the remote Git repository on every frequent compilation can fail. Tool choice depends on focus, complexity, user profile, and latency:
| Scheduler | Best fit | Scheduling method |
|---|---|---|
| Dataform | Organized, tested, version-controlled SQL collections in BigQuery after raw data is loaded | Time-driven |
| Workflows | Chaining HTTP-based microservices with very low latency and automating infrastructure | Event-driven and time-driven |
| Managed Service for Apache Airflow | Durable extract-transform-load (ETL) or ELT and MLOps across heterogeneous systems with more than 1,000 prebuilt operators | Time-driven and event-driven |
| Cloud Scheduler | Invoking batch, streaming, or infrastructure operations on intervals, including triggering Workflows and Cloud Run jobs | Time-driven |
The simplest time-driven option is scheduled queries in BigQuery, recommended only for straightforward GoogleSQL chains with no external dependencies. Assets created in a BigQuery repository, such as queries, notebooks, pipelines, or Dataform workflows, cannot be scheduled from Dataform and must use BigQuery execution and scheduling. Other options include Vertex AI Pipelines for container-based machine learning, Apigee Integration for enterprise apps, and Cloud Data Fusion for code-free pipelines with more than 150 connectors.
Continue with this study guide: Scheduling and orchestrating jobs in a repeatable way
>> to define execution order, where control flows from the upstream task on the left to the downstream task on the right.dag_id exactly matches trigger_dag_id, and the child DAG uses schedule_interval="None" so it runs only when triggered.The bitshift operator defines execution order where control flows from the upstream task on the left to the downstream task on the right. A task list runs in parallel, and narrowing parallel branches back to a single task before fanning out again preserves acyclic properties and prevents ambiguous ordering and skipped dependencies.
TriggerDagRunOperator triggers a child DAG run from within a parent controller DAG, where control flows from the parent task to a new run and the conf dictionary flows from the parent to the triggered run as configuration. The value of trigger_dag_id must exactly match the dag_id of the DAG to trigger, and the child DAG uses schedule_interval None so it runs only when triggered, with two separate DAG files uploaded to the same environment.
Pausing a DAG from the Scheduling page stops the scheduler from launching new DAG runs while a failure is investigated and prevents additional failed runs, downstream use of partial data, and alert noise. Verification moves from checking for syntax errors in the Airflow web interface to checking that runs are scheduled at the correct time, then waiting for runs in the Gen 3 environment and troubleshooting any failed run until it succeeds.
Last updated