Skip to content

Do not record a canceled job as an error when its outputs are missing - #258

Open
PaulHax wants to merge 1 commit into
girder:masterfrom
PaulHax:cancel-not-error
Open

Do not record a canceled job as an error when its outputs are missing#258
PaulHax wants to merge 1 commit into
girder:masterfrom
PaulHax:cancel-not-error

Conversation

@PaulHax

@PaulHax PaulHax commented Jul 18, 2026

Copy link
Copy Markdown

Item 3 of #256.

Cancelling a running CLI job today ends with the job marked ERROR, not CANCELED:

  1. The cancel stops the container mid-run, so it never writes its declared output files.
  2. girder_worker's Task.__call__ then applies the girder_result_hooks upload transforms anyway.
  3. GirderUploadVolumePathToFolder.transform raises FileNotFoundError on the missing output path.
  4. That exception fails the task through the generic failure path, and the job is recorded as ERROR with a FileNotFoundError traceback in its log.

To reproduce: submit any CLI with a file output, cancel it while the container is running, and watch the final status.

The fix: the run task returns an empty result tuple when task.canceled, so the upload hooks are skipped and girder_worker's normal revoked handling records the job as CANCELED. Only task.canceled gates the skip — a real failure (container exits without writing outputs, no cancel) still goes down the error path unchanged.

One supporting change: cancellation is latched per task request. The base canceled property re-inspects the broker on every read, so a single timed-out inspection after the docker loop already observed the cancel would flip it back to False and send the canceled task down the missing-output error path anyway. The run task reads only the latch after the container returns (a cancel can only have stopped the container through the docker loop's polling, which reads the property), so successful runs pay no extra broker round-trip.

Tests included.

Related: #228 and #183 mark stuck or old jobs as canceled after the fact; this fixes the cause by not turning a cancel into an error in the first place.

Cancelling a running CLI job stops the container, but the output upload
result hooks still ran and raised FileNotFoundError for the outputs the
stopped container never wrote, so a user-requested cancel was recorded
as a failed job.  Return an empty result tuple from the run task when
the task was canceled so the result hooks are skipped, and propagate
the parent result from DirectDockerTask.__call__.

Cancellation is latched per task request: the base property performs a
fresh broker inspection on every read, and one failed inspection after
the docker loop already observed the cancel would otherwise send the
canceled task down the missing-output error path anyway.  The run task
reads only the latch after the container returns -- a cancel can only
have stopped the container through the docker loop's polling, so this
adds no broker round-trip to successful runs.  Real CLI failures are
unaffected: the output upload path only changes when the task was
actually canceled.
@PaulHax PaulHax mentioned this pull request Jul 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant