Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pkg/guestagent/guestagent_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,11 @@ const deltaLimit = 2 * time.Second

func (a *agent) fixSystemTimeSkew() {
for {
ok, err := timesync.HasRTC()
if !ok {
logrus.Warnf("fixSystemTimeSkew: error: %s", err.Error())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use logrus.WithError

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can add it, just didn't know if it was required (the other code is not using it yet)

break
}
ticker := time.NewTicker(10 * time.Second)
for now := range ticker.C {
rtc, err := timesync.GetRTCTime()
Expand Down
6 changes: 6 additions & 0 deletions pkg/guestagent/timesync/timesync_linux.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package timesync

import (
"errors"
"os"
"time"

Expand All @@ -9,6 +10,11 @@ import (

const rtc = "/dev/rtc"

func HasRTC() (bool, error) {
_, err := os.Stat(rtc)
return !errors.Is(err, os.ErrNotExist), err
}

func GetRTCTime() (t time.Time, err error) {
f, err := os.Open(rtc)
if err != nil {
Expand Down
Loading