Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions internal/pkg/agent/application/monitoring/v1_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@
defaultMetricsCollectionInterval = 60 * time.Second

// metricset stream failure threshold before the stream is marked as DEGRADED
// to avoid marking the agent degraded for transient errors, we set the default threshold to 2
defaultMetricsStreamFailureThreshold = uint(2)
// to avoid marking the agent degraded for transient errors, we set the default threshold to 5
defaultMetricsStreamFailureThreshold = uint(5)
)

var (
Expand Down Expand Up @@ -164,14 +164,14 @@
case uint:
failureThreshold = &policyValue
case int:
unsignedValue := uint(policyValue)

Check failure on line 167 in internal/pkg/agent/application/monitoring/v1_monitor.go

View workflow job for this annotation

GitHub Actions / lint (ubuntu-latest)

G115: integer overflow conversion int -> uint (gosec)

Check failure on line 167 in internal/pkg/agent/application/monitoring/v1_monitor.go

View workflow job for this annotation

GitHub Actions / lint (macos-latest)

G115: integer overflow conversion int -> uint (gosec)
failureThreshold = &unsignedValue
case string:
parsedPolicyValue, err := strconv.Atoi(policyValue)
if err != nil {
return nil, fmt.Errorf("failed to convert policy failure threshold string to int: %w", err)
}
uintPolicyValue := uint(parsedPolicyValue)

Check failure on line 174 in internal/pkg/agent/application/monitoring/v1_monitor.go

View workflow job for this annotation

GitHub Actions / lint (ubuntu-latest)

G115: integer overflow conversion int -> uint (gosec)

Check failure on line 174 in internal/pkg/agent/application/monitoring/v1_monitor.go

View workflow job for this annotation

GitHub Actions / lint (macos-latest)

G115: integer overflow conversion int -> uint (gosec)
failureThreshold = &uintPolicyValue
default:
return nil, fmt.Errorf("unsupported type for policy failure threshold: %T", policyFailureThresholdRaw)
Expand Down
12 changes: 6 additions & 6 deletions internal/pkg/agent/application/monitoring/v1_monitor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ func TestMonitoringConfigMetricsFailureThreshold(t *testing.T) {
agentInfo, err := info.NewAgentInfo(context.Background(), false)
require.NoError(t, err, "Error creating agent info")

sampleFiveErrorsStreamThreshold := uint(5)
sampleSevenErrorsStreamThreshold := uint(7)
sampleTenErrorsStreamThreshold := uint(10)

tcs := []struct {
Expand Down Expand Up @@ -307,7 +307,7 @@ func TestMonitoringConfigMetricsFailureThreshold(t *testing.T) {
HTTP: &monitoringcfg.MonitoringHTTPConfig{
Enabled: false,
},
FailureThreshold: &sampleFiveErrorsStreamThreshold,
FailureThreshold: &sampleSevenErrorsStreamThreshold,
},
},
policy: map[string]any{
Expand All @@ -323,7 +323,7 @@ func TestMonitoringConfigMetricsFailureThreshold(t *testing.T) {
"default": map[string]any{},
},
},
expectedThreshold: sampleFiveErrorsStreamThreshold,
expectedThreshold: sampleSevenErrorsStreamThreshold,
},
{
name: "policy failure threshold uint",
Expand All @@ -334,7 +334,7 @@ func TestMonitoringConfigMetricsFailureThreshold(t *testing.T) {
HTTP: &monitoringcfg.MonitoringHTTPConfig{
Enabled: false,
},
FailureThreshold: &sampleFiveErrorsStreamThreshold,
FailureThreshold: &sampleSevenErrorsStreamThreshold,
},
},
policy: map[string]any{
Expand Down Expand Up @@ -362,7 +362,7 @@ func TestMonitoringConfigMetricsFailureThreshold(t *testing.T) {
HTTP: &monitoringcfg.MonitoringHTTPConfig{
Enabled: false,
},
FailureThreshold: &sampleFiveErrorsStreamThreshold,
FailureThreshold: &sampleSevenErrorsStreamThreshold,
},
},
policy: map[string]any{
Expand Down Expand Up @@ -390,7 +390,7 @@ func TestMonitoringConfigMetricsFailureThreshold(t *testing.T) {
HTTP: &monitoringcfg.MonitoringHTTPConfig{
Enabled: false,
},
FailureThreshold: &sampleFiveErrorsStreamThreshold,
FailureThreshold: &sampleSevenErrorsStreamThreshold,
},
},
policy: map[string]any{
Expand Down
Loading