Skip to content

Commit

Permalink
Implement handler terminate
Browse files Browse the repository at this point in the history
Signed-off-by: jorgee <[email protected]>
  • Loading branch information
jorgee committed Dec 4, 2024
1 parent 712deb6 commit 60eab93
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -300,4 +300,13 @@ abstract class TaskHandler {
final workflowId = env.get("TOWER_WORKFLOW_ID")
return workflowId ? "tw-${workflowId}-${name}" : name
}

private volatile boolean terminated

final void terminate() {
if (!terminated) {
terminated = true
kill()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -581,14 +581,7 @@ class TaskPollingMonitor implements TaskMonitor {
catch (Throwable error) {
// At this point NF assumes job is not running, but there could be errors at monitoring that could leave a job running (#5516).
// In this case, NF needs to ensure the job is killed.
if( error !instanceof ProcessException && error !instanceof ProcessRetryableException && error !instanceof CloudSpotTerminationException
&& error !instanceof ProcessEvalException && error !instanceof FailedGuardException) {
try {
handler.kill()
} catch( Throwable t ) {
log.debug("Unable to cancel task ${handler.task.lazyName()} after error", t)
}
}
handler.terminate()
handleException(handler, error)
}
}
Expand Down

0 comments on commit 60eab93

Please sign in to comment.