Invoke airflow dag from import helper - #772
Conversation
Not up to standards ⛔🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 14 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
There was a problem hiding this comment.
Code Review
This pull request integrates Cloud Composer (Airflow) into the import automation workflow, allowing the import-helper service to trigger Airflow DAGs via REST API calls, complete with fallback logic and unit tests. The review feedback points out critical improvements: avoiding a globally hardcoded _AIRFLOW_WEB_SERVER_URL in cloudbuild.yaml to prevent environment cross-talk, using an OIDC ID token instead of an OAuth 2.0 Access Token to successfully authenticate through Identity-Aware Proxy (IAP) on Cloud Composer v2, and removing the hardcoded default tenant URL in config.py to prevent environment-specific leaks.
1a56749 to
a6ed84a
Compare
ffe5644 to
4fc0cb1
Compare
Add
import_automation_airflowoption in import-helper to trigger Cloud Composer DAGsSummary
Adds support for triggering Cloud Composer (Airflow) DAGs from
import-helperwhenpost_process=import_automation_airflowis specified in CDA transfer completion events (/imports/feed), while preserving existing Cloud Workflows execution forspanner_ingestion_workflowandimport_automation_workflow.Key Changes
utils/imports.py): Addedinvoke_import_automation_airflowto trigger DAG runs via the Composer REST API (/api/v1/dags/{dag_id}/dagRuns), supporting both IAP OIDC ID tokens (AIRFLOW_IAP_CLIENT_ID) and defaultcloud-platformOAuth2 credentials.routes/events.py):post_process == 'import_automation_airflow'branch inhandle_feed_event.dag_idPub/Sub attribute when provided, defaulting (and falling back on HTTP404) to the genericimport_automation_workflowDAG.config.py,deploy-services.yaml,cloudbuild.yaml): AddedAIRFLOW_WEB_SERVER_URL,AIRFLOW_DEFAULT_DAG_ID, andAIRFLOW_IAP_CLIENT_IDconfiguration and Cloud Build substitutions.app_test.py): Added unit tests forimport_automation_airflowevent handling, generic DAG routing,404fallback, and authentication modes.TAG=agy
CONV=e8d6e7b3-338a-4bed-8f9f-3e7c9ca97a52