waitForAdapters - do not kill port-forward untill all checks are done
Change-Id: I51b4c3c1f60c885bf7e40629bb73db5159a8dbb2
diff --git a/vars/waitForAdapters.groovy b/vars/waitForAdapters.groovy
index 37620c3..14b8cdb 100644
--- a/vars/waitForAdapters.groovy
+++ b/vars/waitForAdapters.groovy
@@ -33,48 +33,47 @@
sleep 5
adapters=\$(voltctl adapter list -q | wc -l)
done
- ps aux | grep port-forw | grep -v grep | awk '{print \$2}' | xargs --no-run-if-empty kill -9 || true
"""
- // NOTE that we need to wait for LastCommunication to be equal or shorter that 5s
- // as that means the core can talk to the adapters
- // if voltctl can't read LastCommunication we skip this check
- def done = false;
+ // NOTE that we need to wait for LastCommunication to be equal or shorter that 5s
+ // as that means the core can talk to the adapters
+ // if voltctl can't read LastCommunication we skip this check
+ def done = false;
- while (!done) {
- sleep 1
- def adapters = ""
- try {
- adapters = sh (
- script: 'voltctl adapter list --format "{{gosince .LastCommunication}}"',
- returnStdout: true,
- ).trim()
- } catch (err) {
- // in some older versions of voltctl the command results in
- // ERROR: Unexpected error while attempting to format results as table : template: output:1: function "gosince" not defined
- // if that's the case we won't be able to check the timestamp so it's useless to wait
- println("voltctl can't parse LastCommunication, skip waiting")
- done = true
- break
- }
+ while (!done) {
+ sleep 1
+ def adapters = ""
+ try {
+ adapters = sh (
+ script: 'voltctl adapter list --format "{{gosince .LastCommunication}}"',
+ returnStdout: true,
+ ).trim()
+ } catch (err) {
+ // in some older versions of voltctl the command results in
+ // ERROR: Unexpected error while attempting to format results as table : template: output:1: function "gosince" not defined
+ // if that's the case we won't be able to check the timestamp so it's useless to wait
+ println("voltctl can't parse LastCommunication, skip waiting")
+ done = true
+ break
+ }
- def waitingOn = adapters.split( '\n' ).find{since ->
- since = since.replaceAll('s','') //remove seconds from the string
+ def waitingOn = adapters.split( '\n' ).find{since ->
+ since = since.replaceAll('s','') //remove seconds from the string
- // it has to be a single digit
- if (since.length() > 1) {
- return true
- }
- if ((since as Integer) > 5) {
- return true
- }
- return false
- }
- done = (waitingOn == null || waitingOn.length() == 0)
+ // it has to be a single digit
+ if (since.length() > 1) {
+ return true
}
+ if ((since as Integer) > 5) {
+ return true
+ }
+ return false
+ }
+ done = (waitingOn == null || waitingOn.length() == 0)
+ }
- sh """
- set +x
- ps aux | grep port-forw | grep -v grep | awk '{print \$2}' | xargs --no-run-if-empty kill -9 || true
- """
+ sh """
+ set +x
+ ps aux | grep port-forw | grep -v grep | awk '{print \$2}' | xargs --no-run-if-empty kill -9 || true
+ """
}