From 022b6f9547f51e7549adf33fd6e374906a435515 Mon Sep 17 00:00:00 2001 From: Kevin Trogant Date: Sun, 3 May 2026 11:53:48 +0200 Subject: [PATCH] feat: implement waitForPods in K8sNodeInitDeployer --- .../nextflow/k8s/K8sNodeInitDeployer.groovy | 41 +++++++++++++------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/nextflow/plugins/nf-k8s/src/main/nextflow/k8s/K8sNodeInitDeployer.groovy b/nextflow/plugins/nf-k8s/src/main/nextflow/k8s/K8sNodeInitDeployer.groovy index ac47800..8a34f60 100644 --- a/nextflow/plugins/nf-k8s/src/main/nextflow/k8s/K8sNodeInitDeployer.groovy +++ b/nextflow/plugins/nf-k8s/src/main/nextflow/k8s/K8sNodeInitDeployer.groovy @@ -3,7 +3,6 @@ package nextflow.k8s import nextflow.k8s.client.K8sClient import nextflow.k8s.model.PodHostMount import nextflow.k8s.model.PodSpecBuilder -import nextflow.k8s.model.PodVolumeClaim class K8sNodeInitDeployer { private K8sClient client @@ -65,17 +64,35 @@ class K8sNodeInitDeployer { } private void waitForPods(List nodes) { - for ( String nodeName : nodes ) { - String podName = buildPodName(nodeName) - - // TODO: Support differentiate between wait = running - // and wait = Succeeded - - while( true ) { - sleep 1000 - final state = k8sClient.podState(podName) - if( state && !state.containsKey('waiting') ) { - break + if ( config.nodeInit.wait == 'Running' ) { + for (String nodeName : nodes) { + String podName = buildPodName(nodeName) + while (true) { + sleep 1000 + final state = k8sClient.podState(podName) + if (state && !state.containsKey('waiting')) { + break + } + } + } + } else if ( config.nodeInit.wait == 'Succeeded' ) { + for ( String nodeName : nodes ) { + final String podName = buildPodName(nodeName) + final currentState = client.podState(podName) + if ( currentState && currentState?.running instanceof Map ) { + try { + while (true) { + sleep 10000 + final state = client.podState(podName) + if (state && !(state?.running instanceof Map)) { + println "$podName has changed from running state $state" + break + } + } + } + catch (Exception e) { + println "Caught exception while waiting for ${podName} to stop running" + } } } }