From 0e6ed90aaa9f49b52c6159242c410c1c12906623 Mon Sep 17 00:00:00 2001 From: Roger Coll Date: Thu, 19 Oct 2023 11:17:54 +0200 Subject: [PATCH 1/2] NR-170460: set default NTP timeout to 5s --- pkg/config/defaults.go | 4 ++-- pkg/metrics/host_test.go | 2 +- pkg/metrics/ntp_test.go | 10 +++++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pkg/config/defaults.go b/pkg/config/defaults.go index 4ae21ff01..41f72049b 100644 --- a/pkg/config/defaults.go +++ b/pkg/config/defaults.go @@ -111,8 +111,8 @@ var ( defaultRegisterMaxRetryBoSecs = 60 defaultNtpPool = []string{} // i.e: []string{"time.cloudflare.com"} defaultNtpEnabled = false - defaultNtpInterval = uint(15) // minutes - defaultNtpTimeout = uint(5000) // millisecods + defaultNtpInterval = uint(15) // minutes + defaultNtpTimeout = uint(5) // seconds ) // Default internal values diff --git a/pkg/metrics/host_test.go b/pkg/metrics/host_test.go index d3468b49b..4d37f1479 100644 --- a/pkg/metrics/host_test.go +++ b/pkg/metrics/host_test.go @@ -11,7 +11,7 @@ import ( ) func TestHostSample_CachedNtpOffset(t *testing.T) { - timeout := uint(5000) + timeout := uint(5) interval := uint(15) ntpMonitor := NewNtp([]string{"one"}, timeout, interval) ntpMonitor.ntpQuery = ntpQueryMock([]ntpResp{ diff --git a/pkg/metrics/ntp_test.go b/pkg/metrics/ntp_test.go index 68f8bc1b7..89a64d6a1 100644 --- a/pkg/metrics/ntp_test.go +++ b/pkg/metrics/ntp_test.go @@ -155,7 +155,7 @@ func TestOffset_Interval(t *testing.T) { } func TestOffset_OffsetAverage(t *testing.T) { - timeout := uint(5000) + timeout := uint(5) interval := uint(15) ntpMonitor := NewNtp([]string{"one", "two", "three"}, timeout, interval) ntpMonitor.ntpQuery = ntpQueryMock([]ntpResp{ @@ -179,7 +179,7 @@ func TestOffset_OffsetAverage(t *testing.T) { } func TestOffset_AnyHostErrorShouldNotReturnError(t *testing.T) { - timeout := uint(5000) + timeout := uint(5) interval := uint(15) ntpMonitor := NewNtp([]string{"one", "two", "three"}, timeout, interval) ntpMonitor.ntpQuery = ntpQueryMock([]ntpResp{ @@ -202,7 +202,7 @@ func TestOffset_AnyHostErrorShouldNotReturnError(t *testing.T) { } func TestOffset_AllHostErrorShouldReturnError(t *testing.T) { - timeout := uint(5000) + timeout := uint(5) interval := uint(15) ntpMonitor := NewNtp([]string{"one", "two", "three"}, timeout, interval) ntpMonitor.ntpQuery = ntpQueryMock([]ntpResp{ @@ -225,7 +225,7 @@ func TestOffset_AllHostErrorShouldReturnError(t *testing.T) { func TestOffset_InvalidNtpResponse(t *testing.T) { t.Parallel() - timeout := uint(5000) + timeout := uint(5) interval := uint(15) ntpMonitor := NewNtp([]string{"one", "two", "three"}, timeout, interval) ntpMonitor.ntpQuery = ntpQueryMock([]ntpResp{ @@ -251,7 +251,7 @@ func TestOffset_InvalidNtpResponse(t *testing.T) { func TestOffset_AnyHostInvalidShouldNotReturnError(t *testing.T) { t.Parallel() - timeout := uint(5000) + timeout := uint(5) interval := uint(15) ntpMonitor := NewNtp([]string{"one", "two", "three"}, timeout, interval) ntpMonitor.ntpQuery = ntpQueryMock([]ntpResp{ From 88ffc8227c47103bd94d530c21508456bd5330db Mon Sep 17 00:00:00 2001 From: Roger Coll Date: Thu, 19 Oct 2023 11:32:10 +0200 Subject: [PATCH 2/2] NR-170460: avoid magic number linter for defaults --- pkg/config/defaults.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/config/defaults.go b/pkg/config/defaults.go index 41f72049b..c25d93020 100644 --- a/pkg/config/defaults.go +++ b/pkg/config/defaults.go @@ -35,7 +35,7 @@ const ( // Default configurable values // -//nolint:gochecknoglobals +//nolint:gochecknoglobals,gomnd var ( // public DefaultContainerCacheMetadataLimit = 60