Browse Source

Merge "Fix Shipyard wait to catch errors that occur in steps"

Zuul 2 months ago
parent
commit
1a445f3c0b
1 changed files with 28 additions and 16 deletions
  1. 28
    16
      tools/multi_nodes_gate/airship_gate/lib/airship.sh

+ 28
- 16
tools/multi_nodes_gate/airship_gate/lib/airship.sh View File

@@ -93,24 +93,36 @@ shipyard_action_wait() {
93 93
       log "Shipyard action ${action} did not complete in ${timeout} seconds."
94 94
       return 2
95 95
     fi
96
-    RESULT=$(shipyard_cmd --output-format=raw describe "${ACTION_ID}")
97
-    ACTION_STATUS=$(echo "${RESULT}" | jq -r '.action_lifecycle')
98
-    ACTION_RESULT=$(echo "${RESULT}" | jq -r '.dag_status')
99 96
 
100
-    if [[ "${ACTION_STATUS}" == "Complete" ]]
101
-    then
102
-      if [[ "${ACTION_RESULT}" == "success" ]]
103
-      then
104
-        log "Shipyard action ${action} success!"
105
-        return 0
106
-      else
107
-        log "Shipyard action ${action} completed with result ${ACTION_RESULT}"
108
-        echo "${RESULT}" | jq >> "${LOG_FILE}"
109
-        return 1
110
-      fi
111
-    else
112
-      sleep "${poll_time}"
97
+    ACTION_STATUS=$(shipyard_cmd describe "${ACTION_ID}" | grep -i "Lifecycle" | \
98
+            awk '{print $2}')
99
+
100
+    ACTION_STEPS=$(shipyard_cmd describe "${ACTION_ID}" | grep -i "step/" | \
101
+            awk '{print $3}')
102
+
103
+    # Verify lifecycle status
104
+    if [ "${ACTION_STATUS}" == "Failed" ]; then
105
+            echo -e "\n${ACTION_ID} FAILED\n"
106
+            shipyard_cmd describe "${ACTION_ID}"
107
+            exit 1
113 108
     fi
109
+
110
+    if [ "${ACTION_STATUS}" == "Complete" ]; then
111
+            # Verify status of each action step
112
+            for step in ${ACTION_STEPS}; do
113
+              if [ "${step}" == "failed" ]; then
114
+                echo -e "\n${ACTION_ID} FAILED\n"
115
+                shipyard_cmd describe "${ACTION_ID}"
116
+                exit 1
117
+              fi
118
+            done
119
+
120
+            echo -e "\n${ACTION_ID} completed SUCCESSFULLY\n"
121
+            shipyard_cmd describe "${ACTION_ID}"
122
+            exit 0
123
+    fi
124
+
125
+    sleep "${poll_time}"
114 126
   done
115 127
 }
116 128
 

Loading…
Cancel
Save