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
1 Commits
Author SHA1 Message Date
k.rennerandClaude Opus 4.8 3ec270fa89 otbr: strip the CR from ot-ctl state before matching it
#139 landed and did its job: the pod now logs

  otbr: persisted dataset found after 18 attempt(s); activating Thread

and `ot-ctl state` reports `leader`, `ot-ctl br state` reports `running`,
with the OMR prefix fd5f:5689:e6dc:1::/64 published again. The dataset
appeared ~36s after ot-ctl began answering, so the old single-shot check
never stood a chance.

But the attach-confirmation block in that same PR then printed:

  otbr: WARNING Thread not attached after 60s (state=leader)

ot-ctl speaks a serial-console protocol and terminates lines with CRLF, so
`ot-ctl state | head -1` yields `leader\r` -- 7 bytes. That matches no shell
glob, so the `case` fell through to the warning, and the stray CR is
invisible in the log, making the message read as a flat contradiction.

Verified with `od -c` in the live pod (`l e a d e r \r \n`) and by
`case "leader\r" in leader) ...` failing to match while the tr-stripped
value matches. `bash -n` clean, kustomize builds.

The warning was cosmetic -- Thread attached correctly either way -- but a
health line that says the opposite of the truth is worse than no line.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-09 14:18:08 +02:00