talos/internal/pkg/ntp/consts.go
Andrey Smirnov a2233bfe46
fix: improve NTP sync process
Fixes #4425

* add more logging for responses and sync process
* adjust time sync constants
* change the way poll interval is chosen (increasing on good sync,
decreasing on variation)
* filter out spikes

Based on flow in https://github.com/systemd/systemd/blob/main/src/timesync/timesyncd-manager.c

Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
2021-11-11 20:39:07 +03:00

26 lines
1.1 KiB
Go

// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
package ntp
import "time"
const (
// MinAllowablePoll is the minimum time allowed for a client to query a time server.
MinAllowablePoll = 32 * time.Second
// MaxAllowablePoll is the maximum allowed interval for querying a time server.
MaxAllowablePoll = 2048 * time.Second
// RetryPoll is the interval between retries if the error is not Kiss-o-Death.
RetryPoll = time.Second
// AdjustTimeLimit is a maximum time drift to compensate via adjtimex().
//
// Deltas smaller than AdjustTimeLimit are gradually adjusted (slewed) to approach the network time.
// Deltas larger than AdjustTimeLimit are set by letting the system time jump.
AdjustTimeLimit = 400 * time.Millisecond
// EpochLimit is a minimum time difference to signal that change as epoch change.
EpochLimit = 15 * time.Minute
// ExpectedAccuracy is the expected time sync accuracy, used to adjust poll interval.
ExpectedAccuracy = 200 * time.Millisecond
)