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


##########
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:
   And there is no state row in callback states for the db because there is a 
lot more cases that tasks can be than callbacks with callbacks only having 6 
potential states and tasks having 12ish potential states.



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