From db9e30fd60151d2310ce994a138ef8ae1590f1e4 Mon Sep 17 00:00:00 2001 From: Lehmann-Fabian Date: Tue, 27 Sep 2022 15:47:57 +0200 Subject: [PATCH] Use switch Signed-off-by: Lehmann-Fabian --- .../groovy/nextflow/k8s/client/K8sClient.groovy | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/modules/nextflow/src/main/groovy/nextflow/k8s/client/K8sClient.groovy b/modules/nextflow/src/main/groovy/nextflow/k8s/client/K8sClient.groovy index a1b3915d82..fa7a6d384b 100644 --- a/modules/nextflow/src/main/groovy/nextflow/k8s/client/K8sClient.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/k8s/client/K8sClient.groovy @@ -503,16 +503,12 @@ class K8sClient { def msg = "K8s pod '$podName' execution failed" if( status.reason ) msg += " - reason: ${status.reason}" if( status.message ) msg += " - message: ${status.message}" - if ( 'OutOfcpu' == status.reason && (status.message as String).startsWith("Pod Node didn't have enough resource: cpu,")) { - throw new K8sOutOfCpuException(msg) + switch ( status.reason ) { + case 'OutOfcpu': throw new K8sOutOfCpuException(msg) + case 'OutOfmemory': throw new K8sOutOfMemoryException(msg) + case 'Shutdown': throw new NodeTerminationException(msg) + default: throw new ProcessFailedException(msg) } - if ( 'OutOfmemory' == status.reason && (status.message as String).startsWith("Pod Node didn't have enough resource: memory,") ) { - throw new K8sOutOfMemoryException(msg) - } - final err = status.reason == 'Shutdown' - ? new NodeTerminationException(msg) - : new ProcessFailedException(msg) - throw err } throw new K8sResponseException("K8s undetermined status conditions for pod $podName", resp)