Skip to content

Commit 0af12f8

Browse files
authored
Improve NPD validation diagnostics
1 parent 92f521c commit 0af12f8

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

hack/e2e/lib/validate.sh

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ validate_npd_status() {
8383
local timeout="${E2E_NODE_JOIN_TIMEOUT}"
8484
local elapsed=0
8585
local npd_condition_jsonpath='{.status.conditions[?(@.type=="KernelDeadlock")].status}'
86+
local condition_error="${E2E_WORK_DIR}/npd-condition-${vm_name}.err"
8687
local quoted_timeout
8788

8889
log_info "Validating node-problem-detector on '${vm_name}'..."
@@ -97,16 +98,22 @@ validate_npd_status() {
9798
set -euo pipefail
9899
99100
deadline=$((SECONDS + E2E_NODE_JOIN_TIMEOUT))
100-
active_machine_error="/tmp/aks-flex-node-e2e-active-machine.err"
101+
active_machine_error="/tmp/aks-flex-node-e2e-active-machine-$$.err"
102+
status_error="/tmp/aks-flex-node-e2e-npd-status-$$.err"
101103
while true; do
102-
active_machine="$(sudo python3 - <<'PY' 2>"${active_machine_error}" || true
104+
if [[ ! -f /etc/aks-flex-node/daemon-state.json ]]; then
105+
active_machine=""
106+
echo "/etc/aks-flex-node/daemon-state.json is missing" > "${active_machine_error}"
107+
else
108+
active_machine="$(sudo python3 - <<'PY' 2>"${active_machine_error}" || true
103109
import json
104110
with open("/etc/aks-flex-node/daemon-state.json", encoding="utf-8") as state:
105111
print(json.load(state).get("activeMachine", ""))
106112
PY
107113
)"
114+
fi
108115
if [[ -n "${active_machine}" ]] && machinectl show "${active_machine}" &>/dev/null; then
109-
status="$(sudo systemd-run --machine="${active_machine}" --quiet --pipe systemctl is-active node-problem-detector.service 2>/dev/null || true)"
116+
status="$(sudo systemd-run --machine="${active_machine}" --quiet --pipe systemctl is-active node-problem-detector.service 2>"${status_error}" || true)"
110117
if [[ "${status}" == "active" ]]; then
111118
echo "node-problem-detector.service is active in ${active_machine}"
112119
exit 0
@@ -118,6 +125,9 @@ PY
118125
if [[ -s "${active_machine_error}" ]]; then
119126
cat "${active_machine_error}"
120127
fi
128+
if [[ -s "${status_error}" ]]; then
129+
cat "${status_error}"
130+
fi
121131
machinectl list --no-pager || true
122132
if [[ -n "${active_machine:-}" ]]; then
123133
sudo systemd-run --machine="${active_machine}" --quiet --pipe systemctl status node-problem-detector.service --no-pager -l || true
@@ -132,7 +142,7 @@ REMOTE
132142

133143
local kernel_deadlock
134144
while [[ "${elapsed}" -lt "${timeout}" ]]; do
135-
kernel_deadlock="$(kubectl get node "${vm_name}" -o jsonpath="${npd_condition_jsonpath}" 2>/dev/null || true)"
145+
kernel_deadlock="$(kubectl get node "${vm_name}" -o jsonpath="${npd_condition_jsonpath}" 2>"${condition_error}" || true)"
136146
if [[ "${kernel_deadlock}" == "False" ]]; then
137147
log_success "node-problem-detector is active and reporting on '${vm_name}'"
138148
return 0
@@ -144,6 +154,9 @@ REMOTE
144154
done
145155

146156
log_error "node-problem-detector did not report KernelDeadlock=False on '${vm_name}' within ${timeout}s"
157+
if [[ -s "${condition_error}" ]]; then
158+
cat "${condition_error}" >&2
159+
fi
147160
kubectl describe node "${vm_name}" 2>&1 || true
148161
return 1
149162
}

0 commit comments

Comments
 (0)