mirror of
https://github.com/siderolabs/talos.git
synced 2025-09-19 04:41:13 +02:00
This is a complete rewrite of time sync process. Now the time sync process starts early at boot time, and it adapts to configuration changes: * before config is available, `pool.ntp.org` is used * once config is available, configured time servers are used Controller updates same time sync resource as other controllers had dependency on, so they have a chance to wait for the time sync event. Talos services which depend on time now wait on same resource instead of waiting on timed health. New features: * time sync now sticks to the particular time server unless there's an error from that server, and server is changed in that case, this improves time sync accuracy * time sync acts on config changes immediately, so it's possible to reconfigure time sync at any time * there's a new 'epoch' field in time sync resources which allows time-dependent controllers to regenerate certs when there's a big enough jump in time Features to implement later: * apid shouldn't depend on timed, it should be started early and it should regenerate certs on time jump * trustd should be updated in same way Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
27 lines
786 B
Go
27 lines
786 B
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 (
|
|
"syscall"
|
|
"time"
|
|
|
|
"github.com/beevik/ntp"
|
|
|
|
"github.com/talos-systems/talos/internal/pkg/timex"
|
|
)
|
|
|
|
// CurrentTimeFunc provides a function which returns current time.
|
|
type CurrentTimeFunc func() time.Time
|
|
|
|
// QueryFunc provides a function which performs NTP query.
|
|
type QueryFunc func(server string) (*ntp.Response, error)
|
|
|
|
// SetTimeFunc provides a function to set system time.
|
|
type SetTimeFunc func(tv *syscall.Timeval) error
|
|
|
|
// AdjustTimeFunc provides a function to adjust time.
|
|
type AdjustTimeFunc func(buf *syscall.Timex) (state timex.State, err error)
|