diff --git a/pkg/guestagent/guestagent_linux.go b/pkg/guestagent/guestagent_linux.go index 141d8d9f0f2..8fe3857a68c 100644 --- a/pkg/guestagent/guestagent_linux.go +++ b/pkg/guestagent/guestagent_linux.go @@ -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()) + break + } ticker := time.NewTicker(10 * time.Second) for now := range ticker.C { rtc, err := timesync.GetRTCTime() diff --git a/pkg/guestagent/timesync/timesync_linux.go b/pkg/guestagent/timesync/timesync_linux.go index 3ad02fb5f52..38f88fc8f5e 100644 --- a/pkg/guestagent/timesync/timesync_linux.go +++ b/pkg/guestagent/timesync/timesync_linux.go @@ -1,6 +1,7 @@ package timesync import ( + "errors" "os" "time" @@ -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 {