devzone 0.50.1 → 0.50.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.devcontainer/agent-pod.sh +30 -0
- package/package.json +1 -1
|
@@ -79,11 +79,38 @@ agent_pod_wait() {
|
|
|
79
79
|
|
|
80
80
|
# --- Keep the log of the session ---
|
|
81
81
|
|
|
82
|
+
# Init containers run before the agent: their log goes first, so a refused
|
|
83
|
+
# session shows the guard message. A failing `kubectl logs -c` is not fatal.
|
|
82
84
|
agent_pod_fetch_logs() {
|
|
83
85
|
local pod_name="$1" journal_file="$2"
|
|
86
|
+
local init_name
|
|
87
|
+
while IFS= read -r init_name; do
|
|
88
|
+
[ -n "$init_name" ] || continue
|
|
89
|
+
echo "=== init container ${init_name} ===" >>"$journal_file"
|
|
90
|
+
kubectl logs "$pod_name" -c "$init_name" >>"$journal_file" 2>/dev/null || true
|
|
91
|
+
done <<EOF
|
|
92
|
+
$(kubectl get pod "$pod_name" -o jsonpath='{.spec.initContainers[*].name}' 2>/dev/null || true)
|
|
93
|
+
EOF
|
|
84
94
|
kubectl logs "$pod_name" >>"$journal_file" 2>/dev/null || true
|
|
85
95
|
}
|
|
86
96
|
|
|
97
|
+
# Names the init container that stopped the pod on stderr: the launcher already
|
|
98
|
+
# shows the end of the log, which contains the message of the guard. Only the
|
|
99
|
+
# init containers that actually failed (exit code different from 0) are named.
|
|
100
|
+
agent_pod_init_failure() {
|
|
101
|
+
local pod_name="$1"
|
|
102
|
+
local cause name code
|
|
103
|
+
cause="$(kubectl get pod "$pod_name" -o jsonpath='{range .status.initContainerStatuses[?(@.state.terminated.exitCode)]}{.name}{" "}{.state.terminated.exitCode}{"\n"}{end}' 2>/dev/null)" || true
|
|
104
|
+
[ -n "$cause" ] || return 0
|
|
105
|
+
while IFS=' ' read -r name code; do
|
|
106
|
+
[ -n "$name" ] || continue
|
|
107
|
+
[ "${code:-0}" != 0 ] || continue
|
|
108
|
+
echo "devzone agent --pod : init container ${name} failed (exit ${code})" >&2
|
|
109
|
+
done <<EOF
|
|
110
|
+
${cause}
|
|
111
|
+
EOF
|
|
112
|
+
}
|
|
113
|
+
|
|
87
114
|
# Last lines of the log on stderr: the cause of a failure is there.
|
|
88
115
|
agent_pod_show_tail() {
|
|
89
116
|
local journal_file="$1"
|
|
@@ -198,6 +225,9 @@ agent_pod_lancer() {
|
|
|
198
225
|
phase="$(agent_pod_wait "$pod_name")" || rc=$?
|
|
199
226
|
agent_pod_fetch_logs "$pod_name" "$journal_file"
|
|
200
227
|
echo "=== end of agent session in pod (phase: ${phase:-Unknown})" >>"$journal_file"
|
|
228
|
+
if [ "$rc" -ne 0 ] || [ "$phase" = "Failed" ]; then
|
|
229
|
+
agent_pod_init_failure "$pod_name"
|
|
230
|
+
fi
|
|
201
231
|
agent_pod_show_tail "$journal_file"
|
|
202
232
|
|
|
203
233
|
if [ "$rc" -ne 0 ]; then
|