fix: stdbuf -oL on the tr pipe (1.0.0-58)
Some checks are pending
Security scan / pip-audit (push) Waiting to run
Security scan / bandit (push) Waiting to run
Security scan / gitleaks (push) Waiting to run
Security scan / mypy (push) Waiting to run

1.0.0-57's tr-pipe fix delivered \n-terminated progress lines but
tr's stdout is block-buffered (4 KB chunks) when its destination
is a pipe — and the SSH channel is a pipe. At ~50 bytes per badblocks
progress line, that means ~80 lines accumulate (~6 minutes at our
throughput) before tr flushes anything.

stdbuf -oL forces tr's stdout to line-buffered mode. Each \n now
triggers a flush. Progress lines reach asyncssh as they happen.
This commit is contained in:
Brandon Walter 2026-05-13 10:29:03 -07:00
parent 7c3873dd5e
commit 129f233e0a
2 changed files with 6 additions and 6 deletions

View file

@ -124,11 +124,11 @@ def _build_badblocks_cmd(devname: str) -> str:
f"-p {settings.surface_validate_passes} " f"-p {settings.surface_validate_passes} "
f"/dev/{devname} 2>&1" f"/dev/{devname} 2>&1"
) )
# The outer pipeline lets tr translate \\b → \\n. Single quotes # The outer pipeline lets tr translate \\b → \\n. stdbuf -oL forces
# around the inner script prevent the host shell from interpreting # tr's stdout to line-buffered mode; without it tr's stdout is
# $$. The tr argument uses $'\\b' / $'\\n' escapes — POSIX shells # block-buffered (4 KB chunks) when its destination is a pipe,
# interpret these as the literal backspace and newline bytes. # which delays each progress line by ~6 minutes at our throughput.
return f"sh -c '{inner}' | tr '\\b' '\\n'" return f"sh -c '{inner}' | stdbuf -oL tr '\\b' '\\n'"
from . import kill from . import kill
from ._common import ( from ._common import (

View file

@ -86,7 +86,7 @@ class Settings(BaseSettings):
ssh_key: str = "" # PEM private key content (paste full key including headers) ssh_key: str = "" # PEM private key content (paste full key including headers)
# Application version — used by the /api/v1/updates/check endpoint # Application version — used by the /api/v1/updates/check endpoint
app_version: str = "1.0.0-57" app_version: str = "1.0.0-58"
# ---- Authentication (1.0.0-22) ---- # ---- Authentication (1.0.0-22) ----
# session_secret: HMAC key for signing session cookies. Empty = generate # session_secret: HMAC key for signing session cookies. Empty = generate