diff options
author | Toon Claes <toon@gitlab.com> | 2022-08-25 13:13:51 +0300 |
---|---|---|
committer | Toon Claes <toon@gitlab.com> | 2022-08-25 13:13:51 +0300 |
commit | 7bac586b109eb86702537bd173fb01b7850bdb93 (patch) | |
tree | 31af58552f155bff5485c5a50b41087bb3c8825f /internal | |
parent | b702ffba9655f8d881763c948f06c9e466e958e0 (diff) | |
parent | 30a1aab1fc278b7db30cb485d0ce3f9906d65fdf (diff) |
Merge branch 'ps-remove-drift_threshold_millis' into 'master'
proto: Remove deprecated drift_threshold_millis
Closes #4417
See merge request gitlab-org/gitaly!4843
Diffstat (limited to 'internal')
-rw-r--r-- | internal/gitaly/service/server/clocksynced.go | 9 | ||||
-rw-r--r-- | internal/praefect/service/server/clocksynced.go | 10 |
2 files changed, 8 insertions, 11 deletions
diff --git a/internal/gitaly/service/server/clocksynced.go b/internal/gitaly/service/server/clocksynced.go index 48d4d0b71..d3c64fa02 100644 --- a/internal/gitaly/service/server/clocksynced.go +++ b/internal/gitaly/service/server/clocksynced.go @@ -2,18 +2,17 @@ package server import ( "context" - "time" "gitlab.com/gitlab-org/gitaly/v15/internal/helper" "gitlab.com/gitlab-org/gitaly/v15/proto/go/gitalypb" ) +// ClockSynced returns whether the system clock has an acceptable time drift when compared to NTP service. func (s *server) ClockSynced(_ context.Context, req *gitalypb.ClockSyncedRequest) (*gitalypb.ClockSyncedResponse, error) { - driftThreshold := req.DriftThreshold.AsDuration() - if !req.DriftThreshold.IsValid() || driftThreshold == time.Duration(0) { - driftThreshold = time.Duration(req.DriftThresholdMillis * int64(time.Millisecond)) //nolint:staticcheck + if err := req.DriftThreshold.CheckValid(); err != nil { + return nil, helper.ErrInvalidArgument(err) } - synced, err := helper.CheckClockSync(req.NtpHost, driftThreshold) + synced, err := helper.CheckClockSync(req.NtpHost, req.DriftThreshold.AsDuration()) if err != nil { return nil, err } diff --git a/internal/praefect/service/server/clocksynced.go b/internal/praefect/service/server/clocksynced.go index 9cb984a84..966028ab1 100644 --- a/internal/praefect/service/server/clocksynced.go +++ b/internal/praefect/service/server/clocksynced.go @@ -2,19 +2,17 @@ package server import ( "context" - "time" "gitlab.com/gitlab-org/gitaly/v15/internal/helper" "gitlab.com/gitlab-org/gitaly/v15/proto/go/gitalypb" ) -// ClockSynced checks if system clock is synced. +// ClockSynced returns whether the system clock has an acceptable time drift when compared to NTP service. func (s *Server) ClockSynced(_ context.Context, req *gitalypb.ClockSyncedRequest) (*gitalypb.ClockSyncedResponse, error) { - driftThreshold := req.DriftThreshold.AsDuration() - if !req.DriftThreshold.IsValid() || driftThreshold == time.Duration(0) { - driftThreshold = time.Duration(req.DriftThresholdMillis * int64(time.Millisecond)) //nolint:staticcheck + if err := req.DriftThreshold.CheckValid(); err != nil { + return nil, helper.ErrInvalidArgument(err) } - synced, err := helper.CheckClockSync(req.NtpHost, driftThreshold) + synced, err := helper.CheckClockSync(req.NtpHost, req.DriftThreshold.AsDuration()) if err != nil { return nil, err } |