Skip to content

Agent Mesh

deploy: the SDK canary verdict carries the per-router detail

Antonio Ojea88aa0607c4ca
diff --git a/.github/k8s/sam-sdk-canary-template.yaml b/.github/k8s/sam-sdk-canary-template.yaml
index de68e2e6..e1b619db 100644
--- a/.github/k8s/sam-sdk-canary-template.yaml
+++ b/.github/k8s/sam-sdk-canary-template.yaml
@@ -244,8 +244,8 @@ data:
REACHABLE=${SAM_CANARY_DIR:-/var/run/sam}/reachable
verdict() {
- printf '{"canary":"%s","ok":%s,"agent_peer":"%s","call_s":%d,"error":"%s"}\n' \
- "$CANARY" "$1" "${AGENT_PEER:-}" "$2" "$(printf '%s' "$3" | tr -d '"\n' | cut -c1-300)"
+ printf '{"canary":"%s","ok":%s,"agent_peer":"%s","call_s":%d,"error":"%s","detail":"%s"}\n' \
+ "$CANARY" "$1" "${AGENT_PEER:-}" "$2" "$(printf '%s' "$3" | tr -d '"\n' | cut -c1-300)" "$(printf '%s' "${4:-}" | tr -d '"' | tr '\n' ' ' | cut -c1-600)"
}
# The line naming the error: Node prints it before the stack trace and
@@ -254,6 +254,16 @@ data:
printf '%s\n' "$1" | grep -m1 -E '^[A-Za-z_.]*(Error|Exception)\b' || printf '%s' "$1" | tail -c 200
}
+ # What the SDKs put under the error line: one indented line per address
+ # or router tried and why it failed (NO_RESERVATION, a closed stream, a
+ # refused handshake). Only lines after the error line count, so neither
+ # Python's source frames nor Node's throw site are taken; Node's stack
+ # frames ("at ...") and its error-list brackets are dropped too.
+ detail() {
+ printf '%s\n' "$1" | sed -n '/^[A-Za-z_.]*\(Error\|Exception\)\b/,$p' | tail -n +2 \
+ | grep -E '^[[:space:]]+[^[:space:]]' | grep -vE '^[[:space:]]+(at |\[errors\]|\]|\}|code:|\[cause\])' | sed 's/^[[:space:]]*//; s/,$//' | head -8
+ }
+
while :; do
AGENT_PEER=$(grep -o 'accepting a2a://agent as [^ ]*' "$LOG" 2>/dev/null | tail -1 | cut -d' ' -f4)
if [ -z "$AGENT_PEER" ]; then
@@ -268,7 +278,7 @@ data:
sleep "$INTERVAL"
else
rm -f "$REACHABLE"
- verdict false $(( $(date +%s) - start )) "$(reason "$out")"
+ verdict false $(( $(date +%s) - start )) "$(reason "$out")" "$(detail "$out")"
# A failed call is retried soon; the readiness probe already shows it.
sleep 30
fi