提交 2bf84b15 编写于 作者: T Thomas Stromberg

Make maxClockDesyncSeconds a float for clarity & ease of calling math.Abs

上级 b0d8d7fe
......@@ -20,6 +20,7 @@ import (
"encoding/json"
"flag"
"fmt"
"math"
"net"
"os/exec"
"regexp"
......@@ -49,8 +50,7 @@ import (
var (
// The maximum the guest VM clock is allowed to be ahead and behind. This value is intentionally
// large to allow for inaccurate methodology, but still small enough so that certificates are likely valid.
maximumClockAhead = time.Duration(-2 * time.Millisecond)
maximumClockBehind = time.Duration(2 * time.Millisecond)
maxClockDesyncSeconds = 0.001
)
//This init function is used to set the logtostderr variable to false so that INFO level log info does not clutter the CLI
......@@ -158,8 +158,8 @@ func configureHost(h *host.Host, e *engine.Options) error {
glog.Warningf("Unable to measure system clock delta: %v", err)
return nil
}
if d > maximumClockBehind || d < maximumClockAhead {
glog.Infof("system clock delta is within tolerence: %s", d)
if math.Abs(d.Seconds()) < maxClockDesyncSeconds {
glog.Infof("guest clock delta is within tolerance: %s", d)
return nil
}
if err := adjustGuestClock(h, d); err != nil {
......@@ -188,7 +188,7 @@ func guestClockDelta(h *host.Host) (time.Duration, error) {
if err != nil {
return 0, errors.Wrap(err, "atoi")
}
// In a synced state, "remote" will be ahead of "local" by a few ms
// NOTE: In a synced state, remote is a few hundred ms ahead of local
remote := time.Unix(secs, nsecs)
return remote.Sub(local), nil
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册