From 21a8999369270439ca81921a4b529c793149b98b Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Wed, 24 Nov 2021 09:59:33 +0100 Subject: [PATCH] fix: use deterministic command to determine last boot time --- internal/operator/nodeagent/ensure.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/internal/operator/nodeagent/ensure.go b/internal/operator/nodeagent/ensure.go index a91e71746..2d6a25d2a 100644 --- a/internal/operator/nodeagent/ensure.go +++ b/internal/operator/nodeagent/ensure.go @@ -1,6 +1,7 @@ package nodeagent import ( + "bytes" "fmt" "io/ioutil" "os" @@ -70,14 +71,12 @@ func prepareQuery( defer persistReadyness(curr.NodeIsReady) - dateTime, err := exec.Command("uptime", "-s").CombinedOutput() + dateTime, err := exec.Command("last", "reboot", "-F", "-n", "1").CombinedOutput() if err != nil { return noop, err } - //dateTime := strings.Fields(string(who))[2:] - //str := strings.Join(dateTime, " ") + ":00" - t, err := time.Parse("2006-01-02 15:04:05", strings.TrimSuffix(string(dateTime), "\n")) + t, err := time.Parse(time.ANSIC, strings.Join(strings.Fields(string(bytes.Split(dateTime, []byte("\n"))[0]))[4:9], " ")) if err != nil { return noop, err }