JH-A-Kim commented on code in PR #70475:
URL: https://github.com/apache/airflow/pull/70475#discussion_r3737907413


##########
providers/cncf/kubernetes/src/airflow/providers/cncf/kubernetes/executors/kubernetes_executor.py:
##########
@@ -805,9 +852,26 @@ def _change_state(
             self.log.debug("TI key not in running, not adding to event_buffer: 
%s", key)
             return
 
-        # If we don't have a TI state, look it up from the db. event_buffer 
expects the TI state
+        # If we don't have a TI state, look it up from the db. event_buffer 
expects the TI state.
+        # For callback keys there is no TaskInstance row — treat state=None as 
success directly.
         if state is None:
-            state = self._get_task_instance_state(key, session=session)
+            from airflow.models.taskinstancekey import TaskInstanceKey
+
+            if isinstance(key, TaskInstanceKey):
+                from airflow.models.taskinstance import TaskInstance
+
+                filter_for_tis = TaskInstance.filter_for_tis([key])
+                if filter_for_tis is not None:
+                    state = 
session.scalar(select(TaskInstance.state).where(filter_for_tis))
+                else:
+                    state = None
+                state = TaskInstanceState(state) if state else None
+            elif AIRFLOW_V_3_3_PLUS:
+                from airflow.utils.state import CallbackState
+
+                state = CallbackState.SUCCESS

Review Comment:
   From how I understand it the callback state is never updated during the 
running so it will always be in the `QUEUED` state so adding the check wouldnt 
really change the behaviour of the code as far as i am aware



-- 
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]

Reply via email to