Skip to content

Commit

Permalink
Use a common interface for temporary problems that should cause a ree…
Browse files Browse the repository at this point in the history
…xecution

Signed-off-by: Lehmann-Fabian <[email protected]>
  • Loading branch information
Lehmann-Fabian committed Sep 27, 2022
1 parent db9e30f commit 49791d4
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ package nextflow.exception
import groovy.transform.InheritConstructors

@InheritConstructors
class K8sOutOfCpuException extends RuntimeException {
class K8sOutOfCpuException extends RuntimeException implements TemporaryProblem {
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ package nextflow.exception
import groovy.transform.InheritConstructors

@InheritConstructors
class K8sOutOfMemoryException extends RuntimeException {
class K8sOutOfMemoryException extends RuntimeException implements TemporaryProblem {
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ import groovy.transform.InheritConstructors
*/
@InheritConstructors
@CompileStatic
class NodeTerminationException extends Exception {
class NodeTerminationException extends Exception implements TemporaryProblem {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package nextflow.exception

/**
* Exceptions implementing this interface will always lead to a retry
*/
interface TemporaryProblem {
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
*/
package nextflow.processor

import nextflow.exception.K8sOutOfCpuException
import nextflow.exception.K8sOutOfMemoryException

import static nextflow.processor.ErrorStrategy.*

Expand Down Expand Up @@ -63,7 +61,7 @@ import nextflow.dag.NodeMarker
import nextflow.exception.FailedGuardException
import nextflow.exception.MissingFileException
import nextflow.exception.MissingValueException
import nextflow.exception.NodeTerminationException
import nextflow.exception.TemporaryProblem
import nextflow.exception.ProcessException
import nextflow.exception.ProcessFailedException
import nextflow.exception.ProcessUnrecoverableException
Expand Down Expand Up @@ -974,16 +972,10 @@ class TaskProcessor {
// -- do not recoverable error, just re-throw it
if( error instanceof Error ) throw error

boolean temporaryProblem = (error instanceof TemporaryProblem || error?.cause instanceof TemporaryProblem)
// -- retry without increasing the error counts
if( task && (error.cause instanceof NodeTerminationException
|| error.cause instanceof CloudSpotTerminationException
|| error instanceof K8sOutOfCpuException
|| error instanceof K8sOutOfMemoryException
) ) {
if( error.cause instanceof NodeTerminationException
|| error instanceof K8sOutOfCpuException
|| error instanceof K8sOutOfMemoryException
)
if( task && ( temporaryProblem || error.cause instanceof CloudSpotTerminationException ) ) {
if( temporaryProblem )
log.info "[$task.hashLog] NOTE: ${error.message} -- Execution is retried"
else
log.info "[$task.hashLog] NOTE: ${error.message} -- Cause: ${error.cause.message} -- Execution is retried"
Expand Down

0 comments on commit 49791d4

Please sign in to comment.