From 7d52b47aab58974b399d8ae838af4f5cf04b835d Mon Sep 17 00:00:00 2001 From: jorgee Date: Tue, 7 Oct 2025 10:06:04 +0200 Subject: [PATCH 1/2] save pod logs always Signed-off-by: jorgee --- .../src/main/nextflow/k8s/K8sTaskHandler.groovy | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/plugins/nf-k8s/src/main/nextflow/k8s/K8sTaskHandler.groovy b/plugins/nf-k8s/src/main/nextflow/k8s/K8sTaskHandler.groovy index e98da988cb..664e43e34e 100644 --- a/plugins/nf-k8s/src/main/nextflow/k8s/K8sTaskHandler.groovy +++ b/plugins/nf-k8s/src/main/nextflow/k8s/K8sTaskHandler.groovy @@ -438,7 +438,7 @@ class K8sTaskHandler extends TaskHandler implements FusionAwareTask { task.stderr = errorFile } status = TaskStatus.COMPLETED - savePodLogOnError(task) + savePodLog(task) deletePodIfSuccessful(task) updateTimestamps(state.terminated as Map) determineNode() @@ -448,17 +448,7 @@ class K8sTaskHandler extends TaskHandler implements FusionAwareTask { return false } - protected void savePodLogOnError(TaskRun task) { - if( task.isSuccess() ) - return - - if( errorFile && !errorFile.empty() ) - return - - final session = executor.getSession() - if( session.isAborted() || session.isCancelled() || session.isTerminated() ) - return - + protected void savePodLog(TaskRun task) { try { final stream = useJobResource() ? client.jobLog(podName) From 144a457d75150bb1e483bf8d51998e8b72a76f9c Mon Sep 17 00:00:00 2001 From: jorgee Date: Tue, 7 Oct 2025 10:54:14 +0200 Subject: [PATCH 2/2] change test to save pod always Signed-off-by: jorgee --- .../test/nextflow/k8s/K8sTaskHandlerTest.groovy | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/plugins/nf-k8s/src/test/nextflow/k8s/K8sTaskHandlerTest.groovy b/plugins/nf-k8s/src/test/nextflow/k8s/K8sTaskHandlerTest.groovy index 2f780ceb67..751f65371a 100644 --- a/plugins/nf-k8s/src/test/nextflow/k8s/K8sTaskHandlerTest.groovy +++ b/plugins/nf-k8s/src/test/nextflow/k8s/K8sTaskHandlerTest.groovy @@ -498,7 +498,7 @@ class K8sTaskHandlerTest extends Specification { 1 * handler.updateTimestamps(termState) 1 * handler.readExitFile() >> EXIT_STATUS 1 * handler.deletePodIfSuccessful(task) >> null - 1 * handler.savePodLogOnError(task) >> null + 1 * handler.savePodLog(task) >> null handler.task.exitStatus == EXIT_STATUS handler.task.@stdout == OUT_FILE handler.task.@stderr == ERR_FILE @@ -529,7 +529,7 @@ class K8sTaskHandlerTest extends Specification { 1 * handler.updateTimestamps(termState) 0 * handler.readExitFile() 1 * handler.deletePodIfSuccessful(task) >> null - 1 * handler.savePodLogOnError(task) >> null + 1 * handler.savePodLog(task) >> null handler.task.exitStatus == 137 handler.status == TaskStatus.COMPLETED result == true @@ -803,20 +803,9 @@ class K8sTaskHandlerTest extends Specification { def handler = Spy(new K8sTaskHandler(executor: executor, client: client, podName: POD_NAME)) when: - handler.savePodLogOnError(task) + handler.savePodLog(task) then: - task.isSuccess() >> true - 0 * client.podLog(_) - - when: - handler.savePodLogOnError(task) - then: - task.isSuccess() >> false task.getWorkDir() >> folder - executor.getSession() >> session - session.isTerminated() >> false - session.isCancelled() >> false - session.isAborted() >> false 1 * client.podLog(POD_NAME) >> POD_LOG folder.resolve( TaskRun.CMD_LOG ).text == POD_MESSAGE