Skip to content

Commit

Permalink
NR-170460: fix default NTP timeout to 5 seconds (#1744)
Browse files Browse the repository at this point in the history
* NR-170460: set default NTP timeout to 5s

* NR-170460: avoid magic number linter for defaults
  • Loading branch information
rogercoll committed Oct 19, 2023
1 parent 220eafd commit 4d395a8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions pkg/config/defaults.go
Expand Up @@ -35,7 +35,7 @@ const (

// Default configurable values
//
//nolint:gochecknoglobals
//nolint:gochecknoglobals,gomnd
var (
// public
DefaultContainerCacheMetadataLimit = 60
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pkg/metrics/host_test.go
Expand Up @@ -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{
Expand Down
10 changes: 5 additions & 5 deletions pkg/metrics/ntp_test.go
Expand Up @@ -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{
Expand All @@ -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{
Expand All @@ -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{
Expand All @@ -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{
Expand All @@ -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{
Expand Down

0 comments on commit 4d395a8

Please sign in to comment.