ashb commented on code in PR #74204:
URL: https://github.com/apache/airflow/pull/74204#discussion_r4185180710
##########
providers/elasticsearch/src/airflow/providers/elasticsearch/log/es_task_handler.py:
##########
@@ -226,6 +230,29 @@ def _render_log_id(log_id_template: str, ti: TaskInstance
| TaskInstanceKey, try
)
+def _get_ti_id_fields(ti: TaskInstance | TaskInstanceKey) -> dict[str, str]:
+ # Airflow 2 task instances have no id.
+ return {"ti_id": str(ti_id)} if (ti_id := getattr(ti, "id", None)) else {}
+
+
+def _build_log_query(log_id: str, ti: RuntimeTI) -> list[dict[str, Any]]:
+ log_id_match = {"match_phrase": {"log_id": log_id}}
+ # Before 3.4 a cleared task instance gets a new id, which can differ from
the id its logs were written under.
+ if not AIRFLOW_V_3_4_PLUS:
+ return [log_id_match]
+ return [
+ {
+ "bool": {
+ "should": [
+ {"match_phrase": {"ti_id": str(ti.id)}},
Review Comment:
Oh, so this needs task is deferred, goes back to queued and _then_ fails.
> Before 3.4, a try in UP_FOR_RETRY is stored as (B, N) (see
https://github.com/apache/airflow/pull/73554), while its logs carry the running
UUID
Yes, but a task in UP_FOR_RETRY can't produce any logs. And the upgrade
changes (B,N) rows to (B, N+1) unless I'm mistaken? (And at this point I'm a
bit frazzled so may well be?)
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]