Skip to content

Google: forward Cloud Run container logs to Airflow log via verbose flag - #67140

Merged
shahar1 merged 4 commits into
apache:mainfrom
aaron-y-chen:fix-cloud-run-execute-job-logs
Jun 17, 2026
Merged

Google: forward Cloud Run container logs to Airflow log via verbose flag#67140
shahar1 merged 4 commits into
apache:mainfrom
aaron-y-chen:fix-cloud-run-execute-job-logs

Conversation

@aaron-y-chen

Copy link
Copy Markdown
Contributor

closes: #36963

How

  • Use the Cloud Logging library to fetch container logs.
  • Support both normal and deferrable mode.

How to reproduce

  1. Use gcloud to create a job template.
    export PROJECT_ID="<put-your-project-id>"
    export REGION="us-central1"
    export JOB_NAME="issue-36963-hello-job"
    
    gcloud run jobs create "${JOB_NAME}" \
        --image="us-docker.pkg.dev/cloudrun/container/job:latest" \
        --region="${REGION}" \
        --project="${PROJECT_ID}" \
        --labels="created-by=airflow-36963-repro"
  2. Set up the GCP connection.
  3. Run the reproduction Dag.
    with DAG(
        dag_id="issue_36963_cloud_run_logs_repro",
        start_date=datetime(2026, 1, 1),
        schedule=None,
        catchup=False,
        tags=["repro", "issue-36963", "cloud-run"],
    ) as dag:
        execute_job = CloudRunExecuteJobOperator(
            task_id="execute_cloud_run_job",
            project_id=PROJECT_ID,
            region=REGION,
            job_name=JOB_NAME,
            deferrable=False,
        )
    
        execute_job_verbose = CloudRunExecuteJobOperator(
            task_id="execute_cloud_run_job_verbose",
            project_id=PROJECT_ID,
            region=REGION,
            job_name=JOB_NAME,
            deferrable=False,
            verbose=True,
        )
    
        execute_job_deferrable = CloudRunExecuteJobOperator(
            task_id="execute_cloud_run_job_deferrable",
            project_id=PROJECT_ID,
            region=REGION,
            job_name=JOB_NAME,
            deferrable=True,
        )
    
        execute_job_deferrable_verbose = CloudRunExecuteJobOperator(
            task_id="execute_cloud_run_job_deferrable_verbose",
            project_id=PROJECT_ID,
            region=REGION,
            job_name=JOB_NAME,
            deferrable=True,
            verbose=True,
        )
    
        execute_job_failing_verbose = CloudRunExecuteJobOperator(
            task_id="execute_cloud_run_job_failing_verbose",
            project_id=PROJECT_ID,
            region=REGION,
            job_name=FAILING_JOB_NAME,
            verbose=True,
        )
    
        (
            execute_job
            >> execute_job_verbose
            >> execute_job_deferrable
            >> execute_job_deferrable_verbose
            >> execute_job_failing_verbose
        )

What

Before the fix

  • Cloud Run has container logs such as Starting Task #0, Attempt #0 ....
36963_cloud_run_log
  • However, these logs are not shown in the Airflow UI.
36963_before_the_fix

After the fix

  • Cloud Run container logs are shown in the Airflow UI as expected.
36963_after_the_fix
  • Failed jobs also show their container logs before the task failure is raised.
36963_cloud_run_fail_job_log_2 36963_fail_log_show_on_ui




Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

Generated-by: Codex 5.5 following the guidelines

@boring-cyborg boring-cyborg Bot added area:providers kind:documentation provider:google Google (including GCP) related issues labels May 18, 2026
@aaron-y-chen
aaron-y-chen force-pushed the fix-cloud-run-execute-job-logs branch from f064cd2 to 48f95dc Compare May 18, 2026 23:42
@aaron-y-chen
aaron-y-chen marked this pull request as ready for review May 19, 2026 02:54
@aaron-y-chen
aaron-y-chen requested a review from shahar1 as a code owner May 19, 2026 02:54
@aaron-y-chen
aaron-y-chen force-pushed the fix-cloud-run-execute-job-logs branch from be94629 to 91576c5 Compare May 19, 2026 05:57
@potiuk potiuk added the ready for maintainer review Set after triaging when all criteria pass. label May 24, 2026

@shahar1 shahar1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks promising!
Few comments before approval :)

Comment thread providers/google/src/airflow/providers/google/cloud/operators/cloud_run.py Outdated
@aaron-y-chen
aaron-y-chen force-pushed the fix-cloud-run-execute-job-logs branch from 3a000fb to 499770a Compare May 30, 2026 21:29
@aaron-y-chen

Copy link
Copy Markdown
Contributor Author

Thanks for the review! I believe this version is better than the original one.

Please let me know if there's anything that can be improved :)

@shahar1

shahar1 commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Thanks for the review! I believe this version is better than the original one.

Please let me know if there's anything that can be improved :)

Thanks for fixing!
Hopefully I'll get to it in the next few days :)

@shahar1
shahar1 merged commit c006c18 into apache:main Jun 17, 2026
96 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:providers kind:documentation provider:google Google (including GCP) related issues ready for maintainer review Set after triaging when all criteria pass.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CloudRunExecuteJobOperator - logs from inside the container are not shown in Airflow

3 participants