kaxil commented on code in PR #69914:
URL: https://github.com/apache/airflow/pull/69914#discussion_r3606262083
##########
providers/cncf/kubernetes/src/airflow/providers/cncf/kubernetes/operators/pod.py:
##########
@@ -610,9 +640,53 @@ def log_matching_pod(self, pod: k8s.V1Pod, context:
Context) -> None:
self.log.info("`try_number` of task_instance: %s",
context["ti"].try_number)
self.log.info("`try_number` of pod: %s",
pod.metadata.labels["try_number"])
+ def _get_pod_from_task_state_store(self, context: Context) -> k8s.V1Pod |
None:
+ task_state_store = context.get("task_state_store")
+ if task_state_store is None:
+ return None
+ stored = task_state_store.get(POD_IDENTIFIER_STATE_KEY)
+ if not isinstance(stored, dict):
+ return None
+ name, namespace = stored.get("name"), stored.get("namespace")
+ if not isinstance(name, str) or not isinstance(namespace, str):
+ self.log.warning(
+ "Pod identity stored in task state store is malformed (%s),
falling back to label search.",
+ stored,
+ )
+ return None
+ try:
+ pod = self.hook.get_pod(name, namespace)
Review Comment:
Minor, non-blocking: `_persist_pod_identity_to_task_state_store` stores
`uid` alongside `name`/`namespace`, but the reconnect here only uses
`name`/`namespace` and never compares the fetched `pod.metadata.uid` against
the stored one. So the persisted `uid` is currently dead weight, and to someone
reading the stored dict it looks like pod identity is verified on reconnect
when it isn't.
Practical risk is low, since pod names carry a random suffix and exact name
reuse for the same task instance is unlikely. But I'd either compare the uid
and fall back to label search on mismatch, or drop `uid` from the stored
payload so the schema doesn't imply a check that isn't performed.
`test_durable_reconnects_directly_via_task_state_store` stores `uid: "abc"` and
never asserts on it, which reflects the same gap.
--
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]