From 278f23c9d43c6fa1a239d008dfef17eee6be2221 Mon Sep 17 00:00:00 2001 From: Todd Date: Wed, 31 Jan 2024 12:17:27 -0800 Subject: [PATCH] Fix calculating uptime after system sleep (#4332) * Fix calculating uptime after system sleep * Update internal/clientcache/internal/daemon/status_handler.go Co-authored-by: Johan Brandhorst-Satzkorn --------- Co-authored-by: Johan Brandhorst-Satzkorn --- internal/clientcache/internal/daemon/status_handler.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/clientcache/internal/daemon/status_handler.go b/internal/clientcache/internal/daemon/status_handler.go index d96ff9544f..0163b68f19 100644 --- a/internal/clientcache/internal/daemon/status_handler.go +++ b/internal/clientcache/internal/daemon/status_handler.go @@ -123,7 +123,10 @@ func toApiStatus(in *cache.Status, started time.Time, socketAddr, logLocation st } out := &StatusResult{ - Uptime: time.Since(started), + // Round(0) strips the monotonic clock from results which can drift + // by a wide degree from the wall clock in the case where the system + // sleeps. + Uptime: time.Since(started.Round(0)), SocketAddress: socketAddr, Version: version.Get().FullVersionNumber(true), LogLocation: logLocation,