Repository navigation
run-testbox: count established sshd connections as activity on macOS - #19
Merged
Merged
Conversation
macOS has no ss, so an open SSH session never reset the idle timer there. Fall back to netstat, and match the VM's sshd port (22) instead of RUNNER_SSH_PORT, the host's public port that iptables/pf forward to it. Co-authored-by: Codesmith Staging <codesmith-bot@users.noreply.github.com>
Contributor
Author
|
Live proof on staging testboxes running this branch (
Each testbox stayed up through the whole SSH session (on main it would have stopped about 2 minutes after the last activity), then shut down within the 2-minute timeout after the session closed. Both runs passed. |
aayushshah15
marked this pull request as ready for review
October 24, 2026 18:03
aayushshah15
requested review from
mrhether,
pbardea,
piob-io and
shreyas-blacksmith
October 24, 2026 19:01
pbardea
approved these changes
Oct 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
An open SSH session on a macOS testbox never reset the idle timer, because the idle loop only looked for connections with
ss, which macOS does not have. The loop now falls back tonetstaton macOS, so an interactive session or a longrsynckeeps a Mac testbox alive just like the activity marker does.The port changes on Linux too
The old check grepped for
RUNNER_SSH_PORT, which begin-testbox copies fromBLACKSMITH_SSH_PORT. That is the host's public port (e.g. 64000). The host agent forwards it to port 22 in the VM: iptables DNAT on Linux and a pfrdrrule on macOS (FastActions/faagent/vm/ssh.gocallstunnelMgr.Expose(ctx, vmID, vmIP, 22, ...);agent/tunnel/manager.goandagent/tunnel/proxy_manager.go). Inside the VM, the sshd socket's local port is always 22, sogrep ":64000\b"only matched by coincidence (a peer ephemeral port that happened to equal the public port). In practice the Linux SSH signal never fired and the marker file carried all activity detection.The new check matches what the VM sees: established sockets whose local port is 22. It ignores the runner's own outbound connections to port 22 (e.g.
gitover SSH to GitHub), because those have 22 as the peer port, not the local one. On Linux an open SSH session now keeps the testbox alive, which matches the existing comment's stated intent.bash -e safety
ssh_connectedonly runs as anifcondition, so a probe that finds nothing returns false without aborting the loop. Thessbranch tests captured output instead of piping intogrep -q, which underpipefailcan fail on SIGPIPE even when it matched.Validation on a real
blacksmith-6vcpu-macos-26runner: useblacksmith/web adds a copy ofssh_connectedto.github/scripts/testbox-macos-check.sh, opens a TCP connection to sshd, asserts it is detected, closes it, and asserts it is no longer detected. On Linux thessbranch was checked against a held loopback connection. Do not move thev2tag until after merge.Need help on this PR? Tag
@codesmith-botwith what you need.Before, the box shut down at the 2-minute mark with the SSH session still open. After, the open session kept it alive, and it shut down 2 minutes after the last tick that saw the session.
Merge-base
This PR
5661ca52Also checked · 2 match
Proof on
5661ca52Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is enabled. (Staging)