Commit 967e90d
committed
fix: prevent orphan VMM via socket tiebreaker + status one-shot default
Closes #48 and #49 — both were triggers for orphan cocoon/CH processes
observed on cocoonset-gke-private (8 alive CH/FC without DB entries,
plus 4-day-old cocoon-CLI watchers from prior vk-cocoon restarts).
#49: vm rm --force could clean the DB but leave CH running when the
pidfile/cmdline check returned a false negative (stale pidfile, recycled
PID, manual rundir tampering). Add Backend.IsAPISocketLive as a
pidfile-independent tiebreaker (utils.CheckSocket) and call it in
DeleteAll after the stop step. Fires unconditionally — AF_UNIX has no
TIME_WAIT and TerminateProcess only returns nil after full pid reap, so
a successful stop guarantees the listener is gone; firing also catches
the pidfd_linux.go's own VerifyProcessCmdline false-negative path that
otherwise returns (true, nil) without sending a signal.
#48: cocoon vm status defaulted to a 5s polling loop. When invoked from
a shell that disconnected without SIGHUP propagation (sudo wrapper,
bash -c pipeline, tmux killed without huponexit), the loop survived
indefinitely — observed 21-day-old orphans on prod. Add --watch flag;
default is one-shot snapshot via statusOnce. --event still implies
streaming events. statusOnce + List share a renderVMList helper so the
JSON/table/empty-list branch lives in one place.1 parent 0324e80 commit 967e90d
4 files changed
Lines changed: 62 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
165 | 165 | | |
166 | 166 | | |
167 | 167 | | |
168 | | - | |
| 168 | + | |
169 | 169 | | |
170 | 170 | | |
171 | | - | |
172 | | - | |
173 | | - | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
174 | 175 | | |
175 | 176 | | |
176 | 177 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
59 | 69 | | |
60 | 70 | | |
61 | 71 | | |
62 | 72 | | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
69 | 76 | | |
70 | 77 | | |
71 | 78 | | |
| |||
79 | 86 | | |
80 | 87 | | |
81 | 88 | | |
| 89 | + | |
| 90 | + | |
82 | 91 | | |
83 | 92 | | |
84 | 93 | | |
85 | 94 | | |
86 | 95 | | |
87 | 96 | | |
88 | | - | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
89 | 100 | | |
| 101 | + | |
90 | 102 | | |
91 | 103 | | |
92 | 104 | | |
93 | | - | |
94 | | - | |
95 | 105 | | |
96 | 106 | | |
97 | 107 | | |
| |||
105 | 115 | | |
106 | 116 | | |
107 | 117 | | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
108 | 129 | | |
109 | 130 | | |
110 | 131 | | |
| |||
266 | 287 | | |
267 | 288 | | |
268 | 289 | | |
| 290 | + | |
269 | 291 | | |
270 | 292 | | |
271 | 293 | | |
272 | 294 | | |
273 | 295 | | |
274 | 296 | | |
275 | 297 | | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
276 | 302 | | |
277 | 303 | | |
278 | 304 | | |
279 | | - | |
| 305 | + | |
280 | 306 | | |
281 | 307 | | |
282 | | - | |
| 308 | + | |
283 | 309 | | |
284 | 310 | | |
285 | | - | |
| 311 | + | |
286 | 312 | | |
287 | 313 | | |
288 | 314 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
28 | 43 | | |
29 | 44 | | |
30 | 45 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
67 | 71 | | |
68 | 72 | | |
69 | 73 | | |
| |||
0 commit comments