-
Notifications
You must be signed in to change notification settings - Fork 1.2k
fix(framework): Move Token deletion from PushAppOutputs into UpdateRunStatus #6924
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -367,26 +367,28 @@ def PushAppOutputs( | |
| """Push ServerApp process outputs.""" | ||
| log(DEBUG, "ServerAppIoServicer.PushAppOutputs") | ||
|
|
||
| # Validate the token | ||
| # Validate token and bind request to the token-owned run. | ||
| run_id = self._verify_token(request.token, context) | ||
| if request.run_id != run_id: | ||
| context.abort(grpc.StatusCode.PERMISSION_DENIED, "Invalid token.") | ||
|
|
||
| # Init state and store | ||
| state = self.state_factory.state() | ||
| store = self.objectstore_factory.store() | ||
|
|
||
| # Abort if the run is not running | ||
| abort_if( | ||
| request.run_id, | ||
| run_id, | ||
| [Status.PENDING, Status.STARTING, Status.FINISHED], | ||
| state, | ||
| store, | ||
| context, | ||
| ) | ||
|
|
||
| state.set_serverapp_context(request.run_id, context_from_proto(request.context)) | ||
| state.set_serverapp_context(run_id, context_from_proto(request.context)) | ||
|
|
||
| # Remove the token | ||
| state.delete_token(run_id) | ||
| # Keep token until terminal status is committed. If shutdown finalization fails, | ||
| # heartbeat expiry still needs the token to trigger run finalization fallback. | ||
| return PushAppOutputsResponse() | ||
|
Comment on lines
+390
to
392
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Keeping the token alive in Useful? React with 👍 / 👎. |
||
|
|
||
| def UpdateRunStatus( | ||
|
|
@@ -403,14 +405,32 @@ def UpdateRunStatus( | |
| abort_if(request.run_id, [Status.FINISHED], state, store, context) | ||
|
|
||
| # Update the run status | ||
| state.update_run_status( | ||
| updated = state.update_run_status( | ||
| run_id=request.run_id, new_status=run_status_from_proto(request.run_status) | ||
| ) | ||
| if not updated: | ||
| # Keep token unchanged when the transition fails; it can still expire and | ||
| # trigger heartbeat-based fallback finalization. | ||
| context.abort( | ||
| grpc.StatusCode.FAILED_PRECONDITION, | ||
| f"Failed to update status for run {request.run_id}", | ||
| ) | ||
|
|
||
| # If the run is finished, delete the run from ObjectStore | ||
| # If the run is finished, delete token immediately after status persistence. | ||
| # This prevents expiry cleanup from flipping a completed run while cleanup I/O | ||
| # is still in progress. | ||
| if request.run_status.status == Status.FINISHED: | ||
| # Delete all objects related to the run | ||
| store.delete_objects_in_run(request.run_id) | ||
| state.delete_token(request.run_id) | ||
| try: | ||
| # Delete all objects related to the run | ||
| store.delete_objects_in_run(request.run_id) | ||
| except Exception as exc: # pylint: disable=broad-exception-caught | ||
| log( | ||
| ERROR, | ||
| "Failed to delete objects for run %d: %s", | ||
| request.run_id, | ||
| exc, | ||
| ) | ||
|
|
||
| return UpdateRunStatusResponse() | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.