Commit 4948f20
committed
🤖 Fix SSH exec timeout with ControlMaster socket reuse
## Problem
SSH commands with timeout could run indefinitely on remote hosts despite
client-side timeouts. When ControlMaster multiplexing was enabled, killing
the local SSH client didn't terminate the remote command—it continued
running under the shared master connection.
## Solution
**Three-layer timeout protection:**
1. **Client-side timeout** - SIGKILL after timeout expires (immediate local cleanup)
2. **Remote-side timeout** - Wrap commands with `timeout -s KILL` utility
3. **SSH connection timeout** - ConnectTimeout + ServerAlive* options
Remote timeout is set to `timeout + 1s` to ensure local timeout normally
fires first for cleaner error handling. Uses BusyBox-compatible syntax
(`-s KILL`) for Alpine Linux compatibility.
**ControlMaster always enabled** - Socket reuse now works for all operations,
including timed commands. This preserves 50-200ms performance savings per
operation from connection pooling.
## Testing
- Added timeout integration test for both local and SSH runtimes
- Verifies `sleep 10` with 1s timeout completes in ~1s (not 10s)
- All 88 integration tests pass
- 807 unit tests pass (4 pre-existing gitService failures unrelated)
## Impact
Commands with timeout now properly terminate on remote hosts while
maintaining the performance benefits of SSH connection multiplexing.1 parent 71e965c commit 4948f20
2 files changed
+59
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
101 | | - | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
102 | 111 | | |
103 | 112 | | |
104 | | - | |
| 113 | + | |
105 | 114 | | |
106 | 115 | | |
107 | 116 | | |
| |||
125 | 134 | | |
126 | 135 | | |
127 | 136 | | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
128 | 143 | | |
129 | 144 | | |
130 | 145 | | |
131 | 146 | | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
132 | 161 | | |
133 | 162 | | |
134 | 163 | | |
| |||
175 | 204 | | |
176 | 205 | | |
177 | 206 | | |
178 | | - | |
| 207 | + | |
179 | 208 | | |
180 | 209 | | |
181 | 210 | | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
188 | 215 | | |
189 | 216 | | |
190 | 217 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
145 | 168 | | |
146 | 169 | | |
147 | 170 | | |
| |||
0 commit comments