Repository navigation
Commit 03e41d2
authored
fix(DM01-6341): catch K8s API timeout in kube_job to prevent crash loop (#651)
* fix(DM01-6341): catch K8s API timeout in kube_job to prevent crash loop
When K8s API is slow (e.g. during NodeOS upgrade), requests.post() in
kube_job() raises ReadTimeout. This was uncaught and propagated out of
handle() since schedule() was outside the try/except block, crashing
the scheduler process (95 restarts observed in 2 days).
- Wrap requests.post() in kube_job() with try/except Timeout; return
False so the job stays queued and is retried on the next tick
- Move assign_cluster() and schedule() inside the existing try/except
in handle() so no uncaught exception can escape to main()
* fix(DM01-6341): address code review findings
- Broaden exception catch from Timeout to RequestException to also
handle ConnectionError during K8s API unavailability
- Return True on 409 in kube_job() so a job is not stuck queued when
a previous POST succeeded but the response timed out
- Move update_cluster_state() inside the try/except block in handle()
to eliminate a remaining uncaught exception path
* revert: move update_cluster_state() back outside try/except
* fix(DM01-6341): move pipeline/function invocation controllers to background threads
handle_pipeline_invocations() and handle_function_invocations() make
live K8s API calls every tick, blocking handle_orphaned_jobs() and
schedule() when K8s API is slow. Move them to dedicated background
threads (same pattern as nodes/pipelines cache refresh) so the main
scheduling loop is never blocked by CRD controller sync latency.
sleep is placed after handle() to prevent concurrent runs if a single
iteration takes longer than the sleep interval.1 parent 06aa9f0 commit 03e41d2
1 file changed
Lines changed: 42 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
588 | 588 | | |
589 | 589 | | |
590 | 590 | | |
591 | | - | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
592 | 608 | | |
593 | 609 | | |
594 | 610 | | |
| |||
767 | 783 | | |
768 | 784 | | |
769 | 785 | | |
770 | | - | |
771 | | - | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
772 | 797 | | |
773 | 798 | | |
774 | 799 | | |
| |||
1372 | 1397 | | |
1373 | 1398 | | |
1374 | 1399 | | |
| 1400 | + | |
| 1401 | + | |
| 1402 | + | |
1375 | 1403 | | |
1376 | 1404 | | |
1377 | 1405 | | |
1378 | 1406 | | |
1379 | | - | |
1380 | | - | |
1381 | 1407 | | |
1382 | 1408 | | |
1383 | | - | |
1384 | | - | |
1385 | 1409 | | |
1386 | | - | |
1387 | | - | |
1388 | | - | |
1389 | | - | |
1390 | | - | |
1391 | | - | |
1392 | | - | |
| 1410 | + | |
| 1411 | + | |
| 1412 | + | |
| 1413 | + | |
1393 | 1414 | | |
1394 | | - | |
1395 | | - | |
1396 | | - | |
1397 | | - | |
| 1415 | + | |
| 1416 | + | |
| 1417 | + | |
| 1418 | + | |
1398 | 1419 | | |
1399 | | - | |
| 1420 | + | |
| 1421 | + | |
| 1422 | + | |
1400 | 1423 | | |
1401 | 1424 | | |
1402 | 1425 | | |
| |||
0 commit comments