Skip to content

Commit 17d3368

Browse files
committed
revert(guest): keep gateway error reporting fire-and-forget
Checking notify's result meant the loop had to carry a third state -- degraded, and the host may or may not know -- so the two flag flips grew into two nested matches and doubled the body of the refresh arm. That is a lot of machinery for a host-API blip that the next transition into or out of the degraded state reports again anyway. Back to notify_q, with the tradeoff written down where the flag is seeded. The observe() and startup-registration changes from the previous commit stand.
1 parent d6df97e commit 17d3368

1 file changed

Lines changed: 12 additions & 25 deletions

File tree

dstack/dstack-util/src/gateway_checker.rs

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,11 @@ pub async fn cmd_gateway_checker(args: GatewayCheckerArgs) -> Result<()> {
311311
// config here means boot-time registration failed and already reported it,
312312
// so the first success owes the host a retraction. Assuming health instead
313313
// would leave that boot error on screen forever after we recover.
314+
//
315+
// Reporting is deliberately fire-and-forget. Tracking delivery would mean
316+
// carrying a third state ("degraded, and the host may or may not know")
317+
// through the loop to cover a host-API blip that the next refresh cycle
318+
// already re-reports on the way in or out of the degraded state.
314319
let config_present = wg_config_present();
315320
let mut reported_degraded = !config_present;
316321
let mut checker = Checker::starting(now_secs(), config_present);
@@ -322,37 +327,19 @@ pub async fn cmd_gateway_checker(args: GatewayCheckerArgs) -> Result<()> {
322327
Ok(()) => {
323328
info!("dstack-gateway refresh succeeded");
324329
if reported_degraded {
325-
// Flip the flag only once the host has actually taken
326-
// the retraction. notify_q swallows the error, so a
327-
// host-API blip would strand a stale gateway error on
328-
// the VMM for the life of the VM. Empty body resets
329-
// the host's boot_error field.
330-
match vmm.notify("boot.error", "").await {
331-
Ok(()) => {
332-
info!("dstack-gateway route restored; cleared the reported error");
333-
reported_degraded = false;
334-
}
335-
Err(error) => {
336-
warn!("failed to retract the gateway error: {error:#}");
337-
}
338-
}
330+
info!("dstack-gateway route restored; clearing the reported error");
331+
// Empty body resets the host's boot_error field.
332+
vmm.notify_q("boot.error", "").await;
333+
reported_degraded = false;
339334
}
340335
true
341336
}
342337
Err(error) => {
343338
warn!("dstack-gateway refresh failed: {error:#}");
344339
if !reported_degraded {
345-
// Same reasoning in reverse: a report the host never
346-
// received must be retried, not marked as delivered.
347-
match vmm
348-
.notify("boot.error", &gateway_unavailable_message(&error))
349-
.await
350-
{
351-
Ok(()) => reported_degraded = true,
352-
Err(error) => {
353-
warn!("failed to report the gateway outage: {error:#}");
354-
}
355-
}
340+
vmm.notify_q("boot.error", &gateway_unavailable_message(&error))
341+
.await;
342+
reported_degraded = true;
356343
}
357344
false
358345
}

0 commit comments

Comments
 (0)