wjddn279 commented on code in PR #66141:
URL: https://github.com/apache/airflow/pull/66141#discussion_r3218791155
##########
airflow-core/src/airflow/jobs/scheduler_job_runner.py:
##########
@@ -1261,17 +1261,30 @@ def process_executor_events(
)
continue
+ # Callback state transitions are now driven by the supervisor
through
+ # the Execution API (POST /callbacks/{id}/run, PATCH
/callbacks/{id}/state).
+ # The in-process events from the executor are kept as a fallback
safety
+ # net for cases where the supervisor crashed before reporting a
terminal state
+
+ need_to_modify = False
+
if state == CallbackState.RUNNING:
- callback.state = CallbackState.RUNNING
cls.logger().info("Callback %s is currently running",
callback_id)
elif state == CallbackState.SUCCESS:
- callback.state = CallbackState.SUCCESS
cls.logger().info("Callback %s completed successfully",
callback_id)
+ if callback.state == CallbackState.RUNNING:
+ callback.state = CallbackState.SUCCESS
+ need_to_modify = True
elif state == CallbackState.FAILED:
- callback.state = CallbackState.FAILED
- callback.output = str(info) if info else "Execution failed"
- cls.logger().error("Callback %s failed: %s", callback_id,
callback.output)
- session.add(callback)
+ callback_output = str(info) if info else "Execution failed"
+ cls.logger().error("Callback %s failed: %s", callback_id,
callback_output)
+ if callback.state == CallbackState.RUNNING:
+ callback.state = CallbackState.FAILED
+ callback.output = callback_output
+ need_to_modify = True
Review Comment:
Confirmed, good catch. Updated the logic so a callback in `QUEUED` state can
also be advanced to `FAILED/SUCCESS` by an executor event. Since a callback is
guaranteed to be in `QUEUED` state by the time the worker can emit an executor
event, the other states (`PENDING / SCHEDULED`) are deliberately excluded from
the whitelist. Added tests covering the new transitions 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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]