Distinguish timeout from cancellation in logs

This commit is contained in:
riccardom
2026-06-22 19:08:07 +02:00
parent ea08b3d2dc
commit c2a046ac8c
3 changed files with 48 additions and 1 deletions
+7 -1
View File
@@ -2,6 +2,7 @@ package system
import (
"context"
"errors"
"net/netip"
"strings"
"time"
@@ -194,7 +195,12 @@ func GetInfoWithChecksTimeout(ctx context.Context, timeout time.Duration, checks
case info := <-infoCh:
return info, true
case <-ctx.Done():
log.Warnf("gathering system info with checks timed out after %s", timeout)
if errors.Is(ctx.Err(), context.DeadlineExceeded) {
log.Warnf("gathering system info with checks timed out after %s", timeout)
} else {
// Parent context canceled (e.g. shutdown), not a timeout.
log.Warnf("gathering system info with checks canceled: %v", ctx.Err())
}
return nil, false
}
}