Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

chore(devbox): raise mutagen ssh connect timeout for devboxes (#99426)

Thiago Salvatore479f28e3d82b
diff --git a/tools/hogli-commands/hogli_commands/devbox/mutagen.py b/tools/hogli-commands/hogli_commands/devbox/mutagen.py
index 274e3e34ed09..38f81bdb3ab2 100644
--- a/tools/hogli-commands/hogli_commands/devbox/mutagen.py
+++ b/tools/hogli-commands/hogli_commands/devbox/mutagen.py
@@ -37,6 +37,7 @@ _MUTAGEN_VERSION = "0.18.1"
# resulting silence tolerance (~30s, comfortably past the ~26s reset cadence).
_SSH_SHIM_DIR = Path.home() / ".hogli" / "mutagen-ssh-shim"
_KEEPALIVE_COUNT = 3
+_CONNECT_TIMEOUT_SECONDS = 60
# Baked at generation time (see ensure_ssh_shim): only when the ssh/scp target is
# a devbox (a `coder.*` host -- the sole thing hogli syncs to) do we bump
@@ -55,6 +56,7 @@ done
args=()
for a in "$@"; do
case "$a" in
+ -oConnectTimeout=*) [ -n "$devbox" ] && a="-oConnectTimeout={connect_timeout}" ;;
-oServerAliveCountMax=*) [ -n "$devbox" ] && a="-oServerAliveCountMax={count}" ;;
esac
args+=("$a")
@@ -271,7 +273,11 @@ def ensure_ssh_shim() -> Path:
_SSH_SHIM_DIR.chmod(0o700)
for name in ("ssh", "scp"):
target = _SSH_SHIM_DIR / name
- content = _SHIM_TEMPLATE.format(count=_KEEPALIVE_COUNT, real=_resolve_real_ssh(name))
+ content = _SHIM_TEMPLATE.format(
+ count=_KEEPALIVE_COUNT,
+ connect_timeout=_CONNECT_TIMEOUT_SECONDS,
+ real=_resolve_real_ssh(name),
+ )
if not target.exists() or target.read_text() != content:
_write_owner_only(target, content)
else:
diff --git a/tools/hogli-commands/hogli_commands/tests/test_devbox.py b/tools/hogli-commands/hogli_commands/tests/test_devbox.py
index 8e892a627a65..b3b5e10618f7 100644
--- a/tools/hogli-commands/hogli_commands/tests/test_devbox.py
+++ b/tools/hogli-commands/hogli_commands/tests/test_devbox.py
@@ -3890,7 +3890,7 @@ class TestKeepaliveShim:
[("coder.devbox-test-user", True), ("[email protected]", False)],
ids=["devbox-host-bumped", "non-devbox-host-untouched"],
)
- def test_shim_rewrites_keepalive_only_for_devbox_hosts(
+ def test_shim_rewrites_ssh_options_only_for_devbox_hosts(
self, monkeypatch: pytest.MonkeyPatch, tmp_path: Path, target: str, bumped: bool
) -> None:
# End-to-end of the generated shim script: run it like mutagen would and
@@ -3920,9 +3920,14 @@ class TestKeepaliveShim:
forwarded = log.read_text().splitlines()
if bumped:
- bump = f"-oServerAliveCountMax={devbox_mutagen._KEEPALIVE_COUNT}"
- assert forwarded == [bump if a.startswith("-oServerAliveCountMax=") else a for a in incoming]
+ rewrites = {
+ "-oServerAliveCountMax=": f"-oServerAliveCountMax={devbox_mutagen._KEEPALIVE_COUNT}",
+ "-oConnectTimeout=": f"-oConnectTimeout={devbox_mutagen._CONNECT_TIMEOUT_SECONDS}",
+ }
+ expected = [next((v for k, v in rewrites.items() if a.startswith(k)), a) for a in incoming]
+ assert forwarded == expected
assert "-oServerAliveCountMax=1" not in forwarded
+ assert "-oConnectTimeout=5" not in forwarded
else:
# Non-devbox ssh must pass through byte-for-byte, keepalive included.
assert forwarded == incoming