feat: implement waitForPods in K8sNodeInitDeployer
This commit is contained in:
@@ -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,12 +64,9 @@ class K8sNodeInitDeployer {
|
||||
}
|
||||
|
||||
private void waitForPods(List<String> nodes) {
|
||||
if ( config.nodeInit.wait == 'Running' ) {
|
||||
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)
|
||||
@@ -79,5 +75,26 @@ class K8sNodeInitDeployer {
|
||||
}
|
||||
}
|
||||
}
|
||||
} 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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user