feat: implement waitForPods in K8sNodeInitDeployer

This commit is contained in:
2026-05-03 11:53:48 +02:00
parent aba1324935
commit 022b6f9547

View File

@@ -3,7 +3,6 @@ package nextflow.k8s
import nextflow.k8s.client.K8sClient import nextflow.k8s.client.K8sClient
import nextflow.k8s.model.PodHostMount import nextflow.k8s.model.PodHostMount
import nextflow.k8s.model.PodSpecBuilder import nextflow.k8s.model.PodSpecBuilder
import nextflow.k8s.model.PodVolumeClaim
class K8sNodeInitDeployer { class K8sNodeInitDeployer {
private K8sClient client private K8sClient client
@@ -65,17 +64,35 @@ class K8sNodeInitDeployer {
} }
private void waitForPods(List<String> nodes) { private void waitForPods(List<String> nodes) {
for ( String nodeName : nodes ) { if ( config.nodeInit.wait == 'Running' ) {
String podName = buildPodName(nodeName) for (String nodeName : nodes) {
String podName = buildPodName(nodeName)
// TODO: Support differentiate between wait = running while (true) {
// and wait = Succeeded sleep 1000
final state = k8sClient.podState(podName)
while( true ) { if (state && !state.containsKey('waiting')) {
sleep 1000 break
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"
}
} }
} }
} }