Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavlo Strokov <pstrokov@gitlab.com>2022-08-05 10:15:33 +0300
committerPavlo Strokov <pstrokov@gitlab.com>2022-08-05 10:37:40 +0300
commitaccb5d5cfcb7c5f43a84433656e664be293b13e1 (patch)
tree3dca23aece4df2c4a19101f0ada46403c9e6dd0f
parent2ccfad3abf2655325fb6f2664d4d9b04e69a2f79 (diff)
proto: Use drift_threshold instead of drift_threshold_millisps-clock-sync-threshold
As drift_threshold_millis field is deprecated we use a newly added drift_threshold field instead. To support backwards compatibility the old drift_threshold_millis is taken into account if there is no value provided for the drift_threshold field. Closes: https://gitlab.com/gitlab-org/gitaly/-/issues/4412
-rw-r--r--internal/gitaly/service/server/clocksynced.go6
-rw-r--r--internal/praefect/checks.go3
-rw-r--r--internal/praefect/service/server/clocksynced.go6
3 files changed, 12 insertions, 3 deletions
diff --git a/internal/gitaly/service/server/clocksynced.go b/internal/gitaly/service/server/clocksynced.go
index 04de4a11a..48d4d0b71 100644
--- a/internal/gitaly/service/server/clocksynced.go
+++ b/internal/gitaly/service/server/clocksynced.go
@@ -9,7 +9,11 @@ import (
)
func (s *server) ClockSynced(_ context.Context, req *gitalypb.ClockSyncedRequest) (*gitalypb.ClockSyncedResponse, error) {
- synced, err := helper.CheckClockSync(req.NtpHost, time.Duration(req.DriftThresholdMillis*int64(time.Millisecond)))
+ driftThreshold := req.DriftThreshold.AsDuration()
+ if !req.DriftThreshold.IsValid() || driftThreshold == time.Duration(0) {
+ driftThreshold = time.Duration(req.DriftThresholdMillis * int64(time.Millisecond)) //nolint:staticcheck
+ }
+ synced, err := helper.CheckClockSync(req.NtpHost, driftThreshold)
if err != nil {
return nil, err
}
diff --git a/internal/praefect/checks.go b/internal/praefect/checks.go
index 32d026d45..218189c6c 100644
--- a/internal/praefect/checks.go
+++ b/internal/praefect/checks.go
@@ -22,6 +22,7 @@ import (
"gitlab.com/gitlab-org/labkit/correlation"
"golang.org/x/sync/errgroup"
"google.golang.org/grpc"
+ "google.golang.org/protobuf/types/known/durationpb"
)
// Severity is a type that indicates the severity of a check
@@ -245,7 +246,7 @@ func NewClockSyncCheck(clockDriftCheck func(ntpHost string, driftThreshold time.
serverServiceClient := gitalypb.NewServerServiceClient(cc)
resp, err := serverServiceClient.ClockSynced(ctx, &gitalypb.ClockSyncedRequest{
- NtpHost: ntpHost, DriftThresholdMillis: driftThreshold.Milliseconds(),
+ NtpHost: ntpHost, DriftThreshold: durationpb.New(driftThreshold),
})
if err != nil {
return fmt.Errorf("gitaly node at %s: %w", node.Address, err)
diff --git a/internal/praefect/service/server/clocksynced.go b/internal/praefect/service/server/clocksynced.go
index 10864843c..9cb984a84 100644
--- a/internal/praefect/service/server/clocksynced.go
+++ b/internal/praefect/service/server/clocksynced.go
@@ -10,7 +10,11 @@ import (
// ClockSynced checks if system clock is synced.
func (s *Server) ClockSynced(_ context.Context, req *gitalypb.ClockSyncedRequest) (*gitalypb.ClockSyncedResponse, error) {
- synced, err := helper.CheckClockSync(req.NtpHost, time.Duration(req.DriftThresholdMillis*int64(time.Millisecond)))
+ driftThreshold := req.DriftThreshold.AsDuration()
+ if !req.DriftThreshold.IsValid() || driftThreshold == time.Duration(0) {
+ driftThreshold = time.Duration(req.DriftThresholdMillis * int64(time.Millisecond)) //nolint:staticcheck
+ }
+ synced, err := helper.CheckClockSync(req.NtpHost, driftThreshold)
if err != nil {
return nil, err
}