Skip to content
This repository has been archived by the owner on Apr 29, 2024. It is now read-only.

Commit

Permalink
fix: use deterministic command to determine last boot time
Browse files Browse the repository at this point in the history
  • Loading branch information
eliobischof committed Nov 24, 2021
1 parent de16160 commit 21a8999
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions internal/operator/nodeagent/ensure.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package nodeagent

import (
"bytes"
"fmt"
"io/ioutil"
"os"
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 21a8999

Please # to comment.