Commit b5b111f
committed
fix(guest): make the gateway checker loop self-recovering
Two changes, one dropping state and one closing the last failure mode
that had no automatic recovery.
Drop reported_degraded. Mirroring gateway state to the host meant the
loop had to remember what the host had been told, and that memory bought
nothing the loop needs: recovery does not depend on it. Boot still
reports the one signal that matters -- this CVM came up without a route.
The cost is that the reported error stays on the VMM after the checker
recovers, until the VM restarts, which is the intended trade.
Add a systemd watchdog. Every recovery path here only runs while the
loop runs, and nothing below the loop could guarantee that: a refresh
that never returns leaves a healthy-looking process that Restart= would
never fire on, and the CVM sits without a route indefinitely. That is
not hypothetical -- a refresh spends most of its time in blocking cmd!
shell-outs, and wg-quick resolves peer endpoints, so a hung DNS lookup
is enough.
tokio::time::timeout cannot fix this: those calls block a runtime worker
with no await point to cancel at. Neither can a watchdog task on another
worker, which would keep pinging while this loop is wedged. The ping has
to come from the loop itself, before the work rather than after, so that
a refresh which never returns stops the pings. systemd then kills and
restarts the service, covering a hang whatever its cause.
Follows the Type=notify + WatchdogSec + sd_notify pattern already used
by dstack-guest-agent. Readiness is reported before the checker decides
whether it has anything to do, so the exit-0 (gateway disabled) and
exit-3 (misconfigured) paths remain a started service that then stopped.
WatchdogSec=600 clears the worst legitimate refresh, which can span KMS
certificate requests plus every configured gateway URL at 60s each.
Verified end to end against a stub notify socket: the process emits
READY=1 at startup and WATCHDOG=1 on each iteration, and stays inert
when the unit does not arm the watchdog, so manual runs still work.1 parent 17d3368 commit b5b111f
6 files changed
Lines changed: 79 additions & 45 deletions
File tree
- dstack
- dstack-util
- src
- os
- common/rootfs
- mkosi/tests
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
36 | 37 | | |
37 | 38 | | |
38 | | - | |
39 | | - | |
40 | | - | |
| 39 | + | |
41 | 40 | | |
42 | 41 | | |
43 | 42 | | |
| |||
279 | 278 | | |
280 | 279 | | |
281 | 280 | | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
282 | 318 | | |
| 319 | + | |
283 | 320 | | |
284 | 321 | | |
285 | 322 | | |
| |||
306 | 343 | | |
307 | 344 | | |
308 | 345 | | |
309 | | - | |
310 | | - | |
311 | | - | |
312 | | - | |
313 | | - | |
314 | | - | |
315 | | - | |
316 | | - | |
317 | | - | |
318 | | - | |
319 | | - | |
320 | | - | |
321 | | - | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
322 | 353 | | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
323 | 363 | | |
324 | 364 | | |
325 | 365 | | |
326 | 366 | | |
327 | 367 | | |
328 | 368 | | |
329 | | - | |
330 | | - | |
331 | | - | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | 369 | | |
336 | 370 | | |
337 | 371 | | |
338 | 372 | | |
339 | | - | |
340 | | - | |
341 | | - | |
342 | | - | |
343 | | - | |
344 | 373 | | |
345 | 374 | | |
346 | 375 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1936 | 1936 | | |
1937 | 1937 | | |
1938 | 1938 | | |
1939 | | - | |
1940 | | - | |
1941 | | - | |
1942 | | - | |
1943 | | - | |
1944 | | - | |
1945 | | - | |
1946 | | - | |
1947 | 1939 | | |
1948 | 1940 | | |
1949 | 1941 | | |
| |||
1974 | 1966 | | |
1975 | 1967 | | |
1976 | 1968 | | |
1977 | | - | |
1978 | | - | |
1979 | | - | |
1980 | | - | |
1981 | | - | |
1982 | | - | |
1983 | | - | |
1984 | | - | |
1985 | 1969 | | |
1986 | 1970 | | |
1987 | 1971 | | |
| |||
2923 | 2907 | | |
2924 | 2908 | | |
2925 | 2909 | | |
2926 | | - | |
| 2910 | + | |
| 2911 | + | |
| 2912 | + | |
| 2913 | + | |
| 2914 | + | |
| 2915 | + | |
2927 | 2916 | | |
2928 | 2917 | | |
2929 | 2918 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
9 | 17 | | |
10 | 18 | | |
11 | 19 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
89 | 95 | | |
90 | 96 | | |
91 | 97 | | |
| |||
0 commit comments