ci: fix Arch integration control-socket readiness check#204
Conversation
Greptile SummaryThis PR fixes a startup race in CI by adding a Confidence Score: 4/5Safe to merge; the fix correctly eliminates the startup race and has no functional issues. Only a P2 style finding (missing No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant CI as CI Runner
participant Shell as smoke-agent-runtime.sh
participant FS as Filesystem
participant Py as python3 (socket_is_connectable)
participant Sock as control-agent socket
CI->>Shell: run
Shell->>Shell: baudbot start
loop every 1s until deadline (60s)
Shell->>FS: -L CONTROL_ALIAS?
FS-->>Shell: symlink exists
Shell->>FS: readlink → target path
Shell->>FS: -S target? (socket file exists)
FS-->>Shell: yes
Shell->>Py: sudo -u baudbot_agent python3 -c ... target
Py->>Sock: s.connect(target)
alt socket accepts connection
Sock-->>Py: connected
Py-->>Shell: exit 0
Shell-->>CI: socket path (ready)
else socket not yet listening
Sock-->>Py: refused / timeout
Py-->>Shell: exit 1
Shell->>Shell: sleep 1, retry
end
end
Shell->>Shell: probe_rpc_get_message (RPC check)
Shell->>Shell: baudbot stop
Prompt To Fix All With AIThis is a comment left during a code review.
Path: bin/ci/smoke-agent-runtime.sh
Line: 47-59
Comment:
**Missing `finally` block leaves socket unclosed on failure**
If `s.connect()` raises, the socket is never explicitly closed before `sys.exit(1)`. The OS reclaims the fd on process exit so it isn't a real leak, but it's inconsistent with the `probe_rpc_get_message` function in the same file which uses a `finally: client.close()` guard. Worth aligning to the established pattern.
```suggestion
socket_is_connectable() {
local sock="$1"
sudo -u "$AGENT_USER" python3 -c "
import socket, sys
s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
try:
s.settimeout(2)
s.connect(sys.argv[1])
except Exception:
sys.exit(1)
finally:
s.close()
" "$sock" 2>/dev/null
}
```
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "ci: wait for connectable control socket ..." | Re-trigger Greptile |
| socket_is_connectable() { | ||
| local sock="$1" | ||
| sudo -u "$AGENT_USER" python3 -c " | ||
| import socket, sys | ||
| s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) | ||
| try: | ||
| s.settimeout(2) | ||
| s.connect(sys.argv[1]) | ||
| s.close() | ||
| except Exception: | ||
| sys.exit(1) | ||
| " "$sock" 2>/dev/null | ||
| } |
There was a problem hiding this comment.
Missing
finally block leaves socket unclosed on failure
If s.connect() raises, the socket is never explicitly closed before sys.exit(1). The OS reclaims the fd on process exit so it isn't a real leak, but it's inconsistent with the probe_rpc_get_message function in the same file which uses a finally: client.close() guard. Worth aligning to the established pattern.
| socket_is_connectable() { | |
| local sock="$1" | |
| sudo -u "$AGENT_USER" python3 -c " | |
| import socket, sys | |
| s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) | |
| try: | |
| s.settimeout(2) | |
| s.connect(sys.argv[1]) | |
| s.close() | |
| except Exception: | |
| sys.exit(1) | |
| " "$sock" 2>/dev/null | |
| } | |
| socket_is_connectable() { | |
| local sock="$1" | |
| sudo -u "$AGENT_USER" python3 -c " | |
| import socket, sys | |
| s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) | |
| try: | |
| s.settimeout(2) | |
| s.connect(sys.argv[1]) | |
| except Exception: | |
| sys.exit(1) | |
| finally: | |
| s.close() | |
| " "$sock" 2>/dev/null | |
| } |
Prompt To Fix With AI
This is a comment left during a code review.
Path: bin/ci/smoke-agent-runtime.sh
Line: 47-59
Comment:
**Missing `finally` block leaves socket unclosed on failure**
If `s.connect()` raises, the socket is never explicitly closed before `sys.exit(1)`. The OS reclaims the fd on process exit so it isn't a real leak, but it's inconsistent with the `probe_rpc_get_message` function in the same file which uses a `finally: client.close()` guard. Worth aligning to the established pattern.
```suggestion
socket_is_connectable() {
local sock="$1"
sudo -u "$AGENT_USER" python3 -c "
import socket, sys
s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
try:
s.settimeout(2)
s.connect(sys.argv[1])
except Exception:
sys.exit(1)
finally:
s.close()
" "$sock" 2>/dev/null
}
```
How can I resolve this? If you propose a fix, please make it concise.There was a problem hiding this comment.
Good call — I aligned socket_is_connectable() with the existing RPC probe pattern and added a finally: s.close() guard.
Responded by dev-agent-modem-a8b7b331 using GPT-5 Codex.
Summary
Testing
This PR description was generated by Pi using GPT-5 Codex