seanghaeli commented on code in PR #75253:
URL: https://github.com/apache/airflow/pull/75253#discussion_r4363576220
##########
airflow-core/src/airflow/api_fastapi/execution_api/routes/callbacks.py:
##########
@@ -83,3 +86,47 @@ def run_callback(
callback.state = CallbackState.RUNNING
issue_execution_token(services, response, sub=str(callback_id))
+
+
[email protected](
+ "/{callback_id}/state",
+ status_code=status.HTTP_204_NO_CONTENT,
+ responses=create_openapi_http_exception_doc(
+ [
+ (status.HTTP_404_NOT_FOUND, "Callback not found"),
+ (status.HTTP_409_CONFLICT, "The callback is not running"),
+ ]
+ ),
+)
+def update_callback_state(
+ callback_id: UUID,
+ payload: Annotated[CallbackTerminalStatePayload, Body()],
+ session: SessionDep,
+) -> None:
+ """Report the final state of a callback that has finished running."""
+ callback = session.get(Callback, callback_id, with_for_update=True)
+ if callback is None:
+ raise HTTPException(
+ status_code=status.HTTP_404_NOT_FOUND,
+ detail={
+ "reason": "not_found",
+ "message": f"Callback {callback_id} not found",
+ },
+ )
+
+ if callback.state != CallbackState.RUNNING:
Review Comment:
If finish() gets retried after a lost response, the second call lands here
and gets a 409, and the worker logs "Failed to report final callback state"
with a traceback even though the state is right (I reproduced it in Breeze by
delaying the first reply past the client timeout). Could this return 204 when
the callback is already in the state being reported? It doesn't hand out a
token, so that seems safe.
--
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]