You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "Vamsi-klu (via GitHub)" <gi...@apache.org> on 2026/04/10 00:49:53 UTC

[PR] Google: Fix false success in Cloud Composer DAG run sensor [airflow]

Vamsi-klu opened a new pull request, #64990:
URL: https://github.com/apache/airflow/pull/64990

   CloudComposer DAG-run waits could report success even when no DAG run existed inside the requested execution window. That can let downstream work continue before the expected Composer run is actually present.
   
   This change keeps both synchronous and deferrable DAG-run waits pending until:
   - at least one DAG run exists inside the requested execution window, and
   - every in-window DAG run is in an allowed state.
   
   It also adds regression coverage for:
   - allowed in-window runs
   - disallowed in-window runs
   - responses where all returned runs are outside the requested window
   - both Airflow 2 (`execution_date`) and Airflow 3 (`logical_date`) response shapes
   
   Validation:
   - `breeze run pytest providers/google/tests/unit/google/cloud/sensors/test_cloud_composer.py -xvs`
   - `breeze run pytest providers/google/tests/unit/google/cloud/triggers/test_cloud_composer.py -xvs`
   - `prek run --from-ref main --stage pre-commit`
   
   closes: #57512
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes — Codex (GPT-5)
   
   Generated-by: Codex (GPT-5) following [the guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Google: Fix false success in Cloud Composer DAG run sensor [airflow]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk closed pull request #64990: Google: Fix false success in Cloud Composer DAG run sensor
URL: https://github.com/apache/airflow/pull/64990


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Google: Fix false success in Cloud Composer DAG run sensor [airflow]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #64990:
URL: https://github.com/apache/airflow/pull/64990#issuecomment-4300309792

   Quick follow-up to the triage comment above — one clarification on the "Unresolved review comments" item:
   
   Once you believe a thread has been addressed — whether by pushing a fix, or by replying in-thread with an explanation of why the suggestion doesn't apply — **please mark the thread as resolved yourself** by clicking the "Resolve conversation" button at the bottom of each thread. Reviewers don't auto-close their own threads, so an addressed-but-unresolved thread reads as "still waiting on the author" and keeps the PR from moving forward. The author doing the resolve-click is the expected convention on this project.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Google: Fix false success in Cloud Composer DAG run sensor [airflow]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #64990:
URL: https://github.com/apache/airflow/pull/64990#issuecomment-4297430987

   @Vamsi-klu This PR has been converted to **draft** because it does not yet meet our [Pull Request quality criteria](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-quality-criteria).
   
   **Issues found:**
   - :x: **Unresolved review comments** (4 threads): please walk through each unresolved review thread. **Even if a suggestion looks incorrect or irrelevant** — and some of them will be, especially any comments left by automated reviewers like GitHub Copilot — it is still the author's responsibility to respond: apply the fix, reply in-thread with a brief explanation of why the suggestion does not apply, or resolve the thread if the feedback is no longer relevant. Leaving threads unaddressed for weeks blocks the PR from moving forward.
   
   **What to do next:**
   - Walk through each unresolved review thread and respond as described above.
   - Make sure static checks pass locally: `prek run --from-ref main --stage pre-commit`.
   - Mark the PR as "Ready for review" when you're done.
   
   Converting a PR to draft is **not** a rejection — it is an invitation to bring the PR up to the project's standards so that maintainer review time is spent productively. There is no rush — take your time and work at your own pace. We appreciate your contribution and are happy to wait for updates. If you have questions, feel free to ask on the [Airflow Slack](https://s.apache.org/airflow-slack).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Google: Fix false success in Cloud Composer DAG run sensor [airflow]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #64990:
URL: https://github.com/apache/airflow/pull/64990#issuecomment-4383007573

   @Vamsi-klu This draft PR has been inactive for 13 days since the last triage comment and no response from the author. Closing to keep the queue clean.
   
   You are welcome to reopen this PR when you resume work, or to open a new one addressing the issues previously raised. There is no rush — take your time.
   
   ---
   
   _Note: This comment was drafted by an AI-assisted triage tool and may contain mistakes. Once you have addressed the points above, an Apache Airflow maintainer — a real person — will take the next look at your PR. We use this [two-stage triage process](https://github.com/apache/airflow/blob/main/contributing-docs/25_maintainer_pr_triage.md#why-the-first-pass-is-automated) so that our maintainers' limited time is spent where it matters most: the conversation with you._
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Google: Fix false success in Cloud Composer DAG run sensor [airflow]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #64990:
URL: https://github.com/apache/airflow/pull/64990#discussion_r3066476060


##########
providers/google/tests/unit/google/cloud/triggers/test_cloud_composer.py:
##########
@@ -59,6 +59,14 @@
     "output_end": True,
     "exit_info": {"exit_code": 0, "error": ""},
 }
+TEST_DAG_RUNS_RESULT = lambda state, date_key, dag_run_date: [
+    {
+        "dag_id": TEST_COMPOSER_DAG_ID,
+        "dag_run_id": TEST_COMPOSER_DAG_RUN_ID,
+        "state": state,
+        date_key: dag_run_date,
+    }
+]
 
 

Review Comment:
   Avoid assigning `lambda` to a name in tests; this commonly trips linters (e.g., E731 in flake8/ruff) and reduces debuggability. Use a small `def test_dag_runs_result(...):` helper function instead.
   ```suggestion
   
   
   def test_dag_runs_result(state, date_key, dag_run_date):
       return [
           {
               "dag_id": TEST_COMPOSER_DAG_ID,
               "dag_run_id": TEST_COMPOSER_DAG_RUN_ID,
               "state": state,
               date_key: dag_run_date,
           }
       ]
   ```



##########
providers/google/tests/unit/google/cloud/sensors/test_cloud_composer.py:
##########
@@ -53,6 +53,20 @@
     "dag_runs": TEST_DAG_RUNS_RESULT(state, date_key, "dag_run_id"),
     "total_entries": 1,
 }
+TEST_DAG_RUN_EXECUTION_RANGE = [datetime(2024, 5, 22, 11, 0, 0), datetime(2024, 5, 22, 12, 0, 0)]
+TEST_DAG_RUN_RESULT_WITH_DATE = lambda state, date_key, dag_run_date: {

Review Comment:
   These tests use naive `datetime(...)` values for `execution_range`, while mocked DAG run dates include `+00:00` (timezone-aware). Because the production code compares via `.timestamp()`, naive timestamps are interpreted in the runner’s local timezone, making the tests potentially flaky across environments. Use timezone-aware UTC datetimes for `TEST_DAG_RUN_EXECUTION_RANGE` (and the `logical_date` you pass in `context`) to make the range checks deterministic.



##########
providers/google/src/airflow/providers/google/cloud/triggers/cloud_composer.py:
##########
@@ -267,16 +267,16 @@ def _check_dag_runs_states(
         start_date: datetime,
         end_date: datetime,
     ) -> bool:
+        found_in_range = False
         for dag_run in dag_runs:
-            if (
-                start_date.timestamp()
-                < parser.parse(
-                    dag_run["execution_date" if self.composer_airflow_version < 3 else "logical_date"]
-                ).timestamp()
-                < end_date.timestamp()
-            ) and dag_run["state"] not in self.allowed_states:
-                return False
-        return True
+            dag_run_date = parser.parse(
+                dag_run["execution_date" if self.composer_airflow_version < 3 else "logical_date"]
+            ).timestamp()
+            if start_date.timestamp() < dag_run_date < end_date.timestamp():
+                found_in_range = True
+                if dag_run["state"] not in self.allowed_states:
+                    return False
+        return found_in_range

Review Comment:
   The `_check_dag_runs_states` logic is now duplicated (nearly identically) in both the sensor and trigger modules. To reduce the risk of future drift, consider extracting a shared helper (e.g., a small utility function that takes `dag_runs`, `allowed_states`, date-key selection, and window bounds) and reusing it in both places.



##########
providers/google/src/airflow/providers/google/cloud/sensors/cloud_composer.py:
##########
@@ -217,16 +217,16 @@ def _check_dag_runs_states(
         start_date: datetime,
         end_date: datetime,
     ) -> bool:
+        found_in_range = False
         for dag_run in dag_runs:
-            if (
-                start_date.timestamp()
-                < parser.parse(
-                    dag_run["execution_date" if self._composer_airflow_version < 3 else "logical_date"]
-                ).timestamp()
-                < end_date.timestamp()
-            ) and dag_run["state"] not in self.allowed_states:
-                return False
-        return True
+            dag_run_date = parser.parse(
+                dag_run["execution_date" if self._composer_airflow_version < 3 else "logical_date"]
+            ).timestamp()
+            if start_date.timestamp() < dag_run_date < end_date.timestamp():
+                found_in_range = True
+                if dag_run["state"] not in self.allowed_states:
+                    return False
+        return found_in_range

Review Comment:
   Within the loop, `start_date.timestamp()` and `end_date.timestamp()` are recomputed for every DAG run. Cache these as local variables before the loop (e.g., `start_ts`, `end_ts`) to avoid repeated conversions. (This same pattern exists in the trigger implementation as well.)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org