otbr: strip the CR from ot-ctl state before matching it #140

Merged
k.renner merged 1 commits from fix/otbr-state-crlf into master 2026-07-09 12:21:45 +00:00
+8 -1
View File
@@ -145,9 +145,16 @@ spec:
# exists to prevent. Note the trailing `|| true`: this script
# runs under `set -e`, so a bare failing test would kill the
# container rather than log a warning.
#
# `tr -d '\r'` is load-bearing. ot-ctl speaks a serial-console
# protocol and terminates lines with CRLF, so `ot-ctl state`
# yields `leader\r` (7 bytes). That matches no shell glob, and
# the stray CR is invisible in logs — the first cut of this
# block printed "WARNING Thread not attached (state=leader)"
# while Thread was, in fact, the leader.
STATE=""
for i in $(seq 1 30); do
STATE=$(ot-ctl state 2>/dev/null | head -1 || true)
STATE=$(ot-ctl state 2>/dev/null | head -1 | tr -d '\r' || true)
case "$STATE" in
leader|router|child)
echo "otbr: Thread attached as ${STATE}"