Commit 540461a
feat(jobs): process-group kill for detached jobs; truncate list COMMAND column (#153)
* feat(jobs): process-group kill for detached jobs; truncate list COMMAND column
Detached jobs now launch via setsid so the user command leads its own
process group (pgid recorded in metadata). `jobs stop` signals the whole
group — covering children like torchrun workers whose leader already
exited and would previously linger holding GPU memory — and only reports
success once no live group member remains. Group identity is verified via
the inherited OKDEV_JOB_ID env marker before signaling, so recycled
pids/pgids are never hit. Containers without setsid and jobs from older
okdev versions fall back to the previous leader-only behavior.
The scan line gains a groupLive count ("<alive>\t<groupLive>\t<json>",
older shapes still parse) so stop's terminal criterion is "metadata
terminal AND group drained"; jobs list --json exposes pgid/groupLive.
jobs list also truncates the COMMAND column to the terminal width on TTY
output (piped output and --json keep the full command) so long training
commands no longer wrap table rows.
Includes a Linux-only end-to-end test (CI) that launches a real process
tree, kills the group through the actual signal script, and asserts every
member is gone.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix(jobs): drop -- before negative pgid in group kill for dash compatibility
dash's kill builtin rejects `kill -SIG -- -pgid` with "Illegal number: -";
the bare "-<pgid>" operand after the signal option works in dash, bash,
zsh, and busybox ash (verified against real process groups in all three
local shells; CI's /bin/sh is dash).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* test(e2e): cover detach runtime-volume logs, group stop, sidecar fallback in kind smoke
Four scenarios on a real pod: detach logs land under /var/okdev/exec;
jobs list --output json reports pgid and live group members; jobs stop
kills the whole process tree (verified by scanning /proc for survivors);
and after crashing the dev container into CrashLoopBackOff, jobs logs
still returns the job's output through the okdev-sidecar fallback.
The container-crash step runs last before teardown since it leaves the
dev container crashlooping. The long sleeps are nominal workloads — the
group kill ends them in seconds, so wall-clock cost is the crash-loop
induction (~30-40s).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>1 parent 6b44386 commit 540461a
10 files changed
Lines changed: 637 additions & 45 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
111 | | - | |
| 111 | + | |
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
| |||
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
136 | | - | |
| 136 | + | |
| 137 | + | |
137 | 138 | | |
138 | 139 | | |
139 | 140 | | |
| |||
167 | 168 | | |
168 | 169 | | |
169 | 170 | | |
170 | | - | |
171 | | - | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
172 | 175 | | |
173 | 176 | | |
174 | 177 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| 26 | + | |
| 27 | + | |
25 | 28 | | |
26 | 29 | | |
27 | 30 | | |
| |||
74 | 77 | | |
75 | 78 | | |
76 | 79 | | |
| 80 | + | |
77 | 81 | | |
78 | 82 | | |
79 | 83 | | |
80 | 84 | | |
81 | 85 | | |
82 | 86 | | |
83 | 87 | | |
84 | | - | |
| 88 | + | |
85 | 89 | | |
86 | 90 | | |
87 | 91 | | |
| |||
223 | 227 | | |
224 | 228 | | |
225 | 229 | | |
| 230 | + | |
| 231 | + | |
226 | 232 | | |
227 | 233 | | |
228 | 234 | | |
| |||
322 | 328 | | |
323 | 329 | | |
324 | 330 | | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
325 | 380 | | |
326 | | - | |
327 | | - | |
| 381 | + | |
| 382 | + | |
328 | 383 | | |
329 | 384 | | |
330 | | - | |
331 | | - | |
332 | | - | |
333 | | - | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
334 | 396 | | |
335 | 397 | | |
336 | 398 | | |
337 | 399 | | |
338 | 400 | | |
339 | 401 | | |
340 | 402 | | |
| 403 | + | |
341 | 404 | | |
342 | 405 | | |
343 | 406 | | |
344 | 407 | | |
345 | 408 | | |
346 | 409 | | |
347 | 410 | | |
348 | | - | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
349 | 422 | | |
350 | 423 | | |
351 | 424 | | |
| |||
407 | 480 | | |
408 | 481 | | |
409 | 482 | | |
410 | | - | |
411 | | - | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
412 | 486 | | |
| 487 | + | |
413 | 488 | | |
414 | 489 | | |
415 | 490 | | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
416 | 497 | | |
417 | 498 | | |
418 | 499 | | |
| |||
422 | 503 | | |
423 | 504 | | |
424 | 505 | | |
| 506 | + | |
425 | 507 | | |
426 | 508 | | |
427 | 509 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
221 | 221 | | |
222 | 222 | | |
223 | 223 | | |
224 | | - | |
225 | | - | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
226 | 230 | | |
227 | 231 | | |
228 | 232 | | |
| |||
388 | 392 | | |
389 | 393 | | |
390 | 394 | | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
391 | 448 | | |
392 | 449 | | |
393 | 450 | | |
| |||
0 commit comments