From d597b56bb72d820e55a5e84895d9d3cca12d4b89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20=C5=81awniczak?= Date: Thu, 12 Dec 2024 16:16:37 +0100 Subject: [PATCH] chore: PC-15033 Remove triggeredBySLOCreation and Edit (#609) ## Motivation Feature is to be reworked. Removed fields that do nothing to avoid confusion. ## Summary See related PR ## Related changes https://github.com/nobl9/nobl9-go/pull/559 ## Release Notes Removed experimental `TriggeredBySloCreation` and `TriggeredBySloEdit` fields that have no effect. --- internal/manifest/v1alpha/examples/agent.go | 6 +-- internal/manifest/v1alpha/examples/direct.go | 6 +-- .../agent/examples/amazon-prometheus.yaml | 6 --- .../v1alpha/agent/examples/app-dynamics.yaml | 6 --- .../v1alpha/agent/examples/azure-monitor.yaml | 6 --- .../agent/examples/azure-prometheus.yaml | 6 --- .../v1alpha/agent/examples/cloud-watch.yaml | 6 --- manifest/v1alpha/agent/examples/datadog.yaml | 6 --- .../v1alpha/agent/examples/dynatrace.yaml | 6 --- .../v1alpha/agent/examples/elasticsearch.yaml | 6 --- .../examples/google-cloud-monitoring.yaml | 6 --- manifest/v1alpha/agent/examples/graphite.yaml | 6 --- .../v1alpha/agent/examples/honeycomb.yaml | 6 --- .../v1alpha/agent/examples/lightstep.yaml | 6 --- .../v1alpha/agent/examples/logic-monitor.yaml | 6 --- .../v1alpha/agent/examples/new-relic.yaml | 6 --- .../v1alpha/agent/examples/prometheus.yaml | 6 --- manifest/v1alpha/agent/examples/splunk.yaml | 6 --- manifest/v1alpha/agent/validation.go | 16 ------ manifest/v1alpha/agent/validation_test.go | 38 +++----------- manifest/v1alpha/data_sources.go | 52 ------------------- .../v1alpha/direct/examples/app-dynamics.yaml | 6 --- .../direct/examples/azure-monitor.yaml | 6 --- .../direct/examples/azure-prometheus.yaml | 6 --- .../v1alpha/direct/examples/cloud-watch.yaml | 6 --- manifest/v1alpha/direct/examples/datadog.yaml | 6 --- .../v1alpha/direct/examples/dynatrace.yaml | 6 --- .../examples/google-cloud-monitoring.yaml | 6 --- .../v1alpha/direct/examples/honeycomb.yaml | 6 --- .../v1alpha/direct/examples/lightstep.yaml | 6 --- .../direct/examples/logic-monitor.yaml | 6 --- .../v1alpha/direct/examples/new-relic.yaml | 6 --- manifest/v1alpha/direct/examples/splunk.yaml | 6 --- manifest/v1alpha/direct/validation.go | 17 +----- manifest/v1alpha/direct/validation_test.go | 30 +++-------- 35 files changed, 17 insertions(+), 316 deletions(-) diff --git a/internal/manifest/v1alpha/examples/agent.go b/internal/manifest/v1alpha/examples/agent.go index a6a63244..c272cddc 100644 --- a/internal/manifest/v1alpha/examples/agent.go +++ b/internal/manifest/v1alpha/examples/agent.go @@ -67,10 +67,8 @@ func (a agentExample) Generate() v1alphaAgent.Agent { Unit: maxDuration.Unit, } agent.Spec.HistoricalDataRetrieval = &v1alpha.HistoricalDataRetrieval{ - MaxDuration: maxDuration, - DefaultDuration: defaultDuration, - TriggeredBySloCreation: &defaultDuration, - TriggeredBySloEdit: &defaultDuration, + MaxDuration: maxDuration, + DefaultDuration: defaultDuration, } } defaultQueryDelay := v1alpha.GetQueryDelayDefaults()[typ] diff --git a/internal/manifest/v1alpha/examples/direct.go b/internal/manifest/v1alpha/examples/direct.go index e9d7d1b0..71cca515 100644 --- a/internal/manifest/v1alpha/examples/direct.go +++ b/internal/manifest/v1alpha/examples/direct.go @@ -71,10 +71,8 @@ func (d directExample) Generate() v1alphaDirect.Direct { Unit: maxDuration.Unit, } direct.Spec.HistoricalDataRetrieval = &v1alpha.HistoricalDataRetrieval{ - MaxDuration: maxDuration, - DefaultDuration: defaultDuration, - TriggeredBySloCreation: &defaultDuration, - TriggeredBySloEdit: &defaultDuration, + MaxDuration: maxDuration, + DefaultDuration: defaultDuration, } } defaultQueryDelay := v1alpha.GetQueryDelayDefaults()[typ] diff --git a/manifest/v1alpha/agent/examples/amazon-prometheus.yaml b/manifest/v1alpha/agent/examples/amazon-prometheus.yaml index c3c8e79f..b313726c 100644 --- a/manifest/v1alpha/agent/examples/amazon-prometheus.yaml +++ b/manifest/v1alpha/agent/examples/amazon-prometheus.yaml @@ -17,12 +17,6 @@ spec: defaultDuration: value: 15 unit: Day - triggeredBySloCreation: - value: 15 - unit: Day - triggeredBySloEdit: - value: 15 - unit: Day queryDelay: value: 1 unit: Second diff --git a/manifest/v1alpha/agent/examples/app-dynamics.yaml b/manifest/v1alpha/agent/examples/app-dynamics.yaml index ae2f63fb..fe739fa3 100644 --- a/manifest/v1alpha/agent/examples/app-dynamics.yaml +++ b/manifest/v1alpha/agent/examples/app-dynamics.yaml @@ -16,12 +16,6 @@ spec: defaultDuration: value: 15 unit: Day - triggeredBySloCreation: - value: 15 - unit: Day - triggeredBySloEdit: - value: 15 - unit: Day queryDelay: value: 2 unit: Minute diff --git a/manifest/v1alpha/agent/examples/azure-monitor.yaml b/manifest/v1alpha/agent/examples/azure-monitor.yaml index 8ccccab4..a1a8ec66 100644 --- a/manifest/v1alpha/agent/examples/azure-monitor.yaml +++ b/manifest/v1alpha/agent/examples/azure-monitor.yaml @@ -16,12 +16,6 @@ spec: defaultDuration: value: 15 unit: Day - triggeredBySloCreation: - value: 15 - unit: Day - triggeredBySloEdit: - value: 15 - unit: Day queryDelay: value: 6 unit: Minute diff --git a/manifest/v1alpha/agent/examples/azure-prometheus.yaml b/manifest/v1alpha/agent/examples/azure-prometheus.yaml index 2dc6c2cb..171431ef 100644 --- a/manifest/v1alpha/agent/examples/azure-prometheus.yaml +++ b/manifest/v1alpha/agent/examples/azure-prometheus.yaml @@ -17,12 +17,6 @@ spec: defaultDuration: value: 15 unit: Day - triggeredBySloCreation: - value: 15 - unit: Day - triggeredBySloEdit: - value: 15 - unit: Day queryDelay: value: 1 unit: Second diff --git a/manifest/v1alpha/agent/examples/cloud-watch.yaml b/manifest/v1alpha/agent/examples/cloud-watch.yaml index accc831b..ed032506 100644 --- a/manifest/v1alpha/agent/examples/cloud-watch.yaml +++ b/manifest/v1alpha/agent/examples/cloud-watch.yaml @@ -15,12 +15,6 @@ spec: defaultDuration: value: 7 unit: Day - triggeredBySloCreation: - value: 7 - unit: Day - triggeredBySloEdit: - value: 7 - unit: Day queryDelay: value: 2 unit: Minute diff --git a/manifest/v1alpha/agent/examples/datadog.yaml b/manifest/v1alpha/agent/examples/datadog.yaml index 19569da3..88862514 100644 --- a/manifest/v1alpha/agent/examples/datadog.yaml +++ b/manifest/v1alpha/agent/examples/datadog.yaml @@ -16,12 +16,6 @@ spec: defaultDuration: value: 15 unit: Day - triggeredBySloCreation: - value: 15 - unit: Day - triggeredBySloEdit: - value: 15 - unit: Day queryDelay: value: 2 unit: Minute diff --git a/manifest/v1alpha/agent/examples/dynatrace.yaml b/manifest/v1alpha/agent/examples/dynatrace.yaml index 0d255117..7eab1e5d 100644 --- a/manifest/v1alpha/agent/examples/dynatrace.yaml +++ b/manifest/v1alpha/agent/examples/dynatrace.yaml @@ -16,12 +16,6 @@ spec: defaultDuration: value: 14 unit: Day - triggeredBySloCreation: - value: 14 - unit: Day - triggeredBySloEdit: - value: 14 - unit: Day queryDelay: value: 3 unit: Minute diff --git a/manifest/v1alpha/agent/examples/elasticsearch.yaml b/manifest/v1alpha/agent/examples/elasticsearch.yaml index e09bd909..693930df 100644 --- a/manifest/v1alpha/agent/examples/elasticsearch.yaml +++ b/manifest/v1alpha/agent/examples/elasticsearch.yaml @@ -16,12 +16,6 @@ spec: defaultDuration: value: 15 unit: Day - triggeredBySloCreation: - value: 15 - unit: Day - triggeredBySloEdit: - value: 15 - unit: Day queryDelay: value: 2 unit: Minute diff --git a/manifest/v1alpha/agent/examples/google-cloud-monitoring.yaml b/manifest/v1alpha/agent/examples/google-cloud-monitoring.yaml index 64b00a14..0e7e555d 100644 --- a/manifest/v1alpha/agent/examples/google-cloud-monitoring.yaml +++ b/manifest/v1alpha/agent/examples/google-cloud-monitoring.yaml @@ -15,12 +15,6 @@ spec: defaultDuration: value: 15 unit: Day - triggeredBySloCreation: - value: 15 - unit: Day - triggeredBySloEdit: - value: 15 - unit: Day queryDelay: value: 3 unit: Minute diff --git a/manifest/v1alpha/agent/examples/graphite.yaml b/manifest/v1alpha/agent/examples/graphite.yaml index ff538a4d..89e94087 100644 --- a/manifest/v1alpha/agent/examples/graphite.yaml +++ b/manifest/v1alpha/agent/examples/graphite.yaml @@ -16,12 +16,6 @@ spec: defaultDuration: value: 15 unit: Day - triggeredBySloCreation: - value: 15 - unit: Day - triggeredBySloEdit: - value: 15 - unit: Day queryDelay: value: 2 unit: Minute diff --git a/manifest/v1alpha/agent/examples/honeycomb.yaml b/manifest/v1alpha/agent/examples/honeycomb.yaml index 0d386356..dd3f2e7f 100644 --- a/manifest/v1alpha/agent/examples/honeycomb.yaml +++ b/manifest/v1alpha/agent/examples/honeycomb.yaml @@ -15,12 +15,6 @@ spec: defaultDuration: value: 3 unit: Day - triggeredBySloCreation: - value: 3 - unit: Day - triggeredBySloEdit: - value: 3 - unit: Day queryDelay: value: 6 unit: Minute diff --git a/manifest/v1alpha/agent/examples/lightstep.yaml b/manifest/v1alpha/agent/examples/lightstep.yaml index 042e84d9..7e5718e0 100644 --- a/manifest/v1alpha/agent/examples/lightstep.yaml +++ b/manifest/v1alpha/agent/examples/lightstep.yaml @@ -18,12 +18,6 @@ spec: defaultDuration: value: 15 unit: Day - triggeredBySloCreation: - value: 15 - unit: Day - triggeredBySloEdit: - value: 15 - unit: Day queryDelay: value: 3 unit: Minute diff --git a/manifest/v1alpha/agent/examples/logic-monitor.yaml b/manifest/v1alpha/agent/examples/logic-monitor.yaml index ea43cec9..b441cf30 100644 --- a/manifest/v1alpha/agent/examples/logic-monitor.yaml +++ b/manifest/v1alpha/agent/examples/logic-monitor.yaml @@ -16,12 +16,6 @@ spec: defaultDuration: value: 15 unit: Day - triggeredBySloCreation: - value: 15 - unit: Day - triggeredBySloEdit: - value: 15 - unit: Day queryDelay: value: 3 unit: Minute diff --git a/manifest/v1alpha/agent/examples/new-relic.yaml b/manifest/v1alpha/agent/examples/new-relic.yaml index 9ae597dc..a0362d60 100644 --- a/manifest/v1alpha/agent/examples/new-relic.yaml +++ b/manifest/v1alpha/agent/examples/new-relic.yaml @@ -16,12 +16,6 @@ spec: defaultDuration: value: 15 unit: Day - triggeredBySloCreation: - value: 15 - unit: Day - triggeredBySloEdit: - value: 15 - unit: Day queryDelay: value: 2 unit: Minute diff --git a/manifest/v1alpha/agent/examples/prometheus.yaml b/manifest/v1alpha/agent/examples/prometheus.yaml index d6841a3e..e2b5645a 100644 --- a/manifest/v1alpha/agent/examples/prometheus.yaml +++ b/manifest/v1alpha/agent/examples/prometheus.yaml @@ -16,12 +16,6 @@ spec: defaultDuration: value: 15 unit: Day - triggeredBySloCreation: - value: 15 - unit: Day - triggeredBySloEdit: - value: 15 - unit: Day queryDelay: value: 1 unit: Second diff --git a/manifest/v1alpha/agent/examples/splunk.yaml b/manifest/v1alpha/agent/examples/splunk.yaml index 3aa77175..36ccff33 100644 --- a/manifest/v1alpha/agent/examples/splunk.yaml +++ b/manifest/v1alpha/agent/examples/splunk.yaml @@ -16,12 +16,6 @@ spec: defaultDuration: value: 15 unit: Day - triggeredBySloCreation: - value: 15 - unit: Day - triggeredBySloEdit: - value: 15 - unit: Day queryDelay: value: 6 unit: Minute diff --git a/manifest/v1alpha/agent/validation.go b/manifest/v1alpha/agent/validation.go index 9dfe89a4..892582e6 100644 --- a/manifest/v1alpha/agent/validation.go +++ b/manifest/v1alpha/agent/validation.go @@ -418,22 +418,6 @@ var historicalDataRetrievalValidationRule = govy.NewRule(func(spec Spec) error { *maxDurationAllowed.Value, maxDurationAllowed.Unit)) } - if spec.HistoricalDataRetrieval.TriggeredBySloCreation != nil && - spec.HistoricalDataRetrieval.TriggeredBySloCreation.BiggerThan(maxDurationAllowed) { - return govy.NewPropertyError( - "historicalDataRetrieval.triggeredBySloCreation", - spec.HistoricalDataRetrieval.TriggeredBySloCreation, - errors.Errorf("must be less than or equal to %d %s", - *maxDurationAllowed.Value, maxDurationAllowed.Unit)) - } - if spec.HistoricalDataRetrieval.TriggeredBySloEdit != nil && - spec.HistoricalDataRetrieval.TriggeredBySloEdit.BiggerThan(maxDurationAllowed) { - return govy.NewPropertyError( - "historicalDataRetrieval.triggeredBySloEdit", - spec.HistoricalDataRetrieval.TriggeredBySloEdit, - errors.Errorf("must be less than or equal to %d %s", - *maxDurationAllowed.Value, maxDurationAllowed.Unit)) - } return nil }) diff --git a/manifest/v1alpha/agent/validation_test.go b/manifest/v1alpha/agent/validation_test.go index b9def42f..75092dd9 100644 --- a/manifest/v1alpha/agent/validation_test.go +++ b/manifest/v1alpha/agent/validation_test.go @@ -232,10 +232,8 @@ func TestValidateSpec_HistoricalDataRetrieval(t *testing.T) { } { agent := validAgent(v1alpha.Prometheus) agent.Spec.HistoricalDataRetrieval = &v1alpha.HistoricalDataRetrieval{ - MaxDuration: v1alpha.HistoricalRetrievalDuration{Unit: unit, Value: ptr(0)}, - DefaultDuration: v1alpha.HistoricalRetrievalDuration{Unit: unit, Value: ptr(0)}, - TriggeredBySloCreation: &v1alpha.HistoricalRetrievalDuration{Unit: unit, Value: ptr(0)}, - TriggeredBySloEdit: &v1alpha.HistoricalRetrievalDuration{Unit: unit, Value: ptr(0)}, + MaxDuration: v1alpha.HistoricalRetrievalDuration{Unit: unit, Value: ptr(0)}, + DefaultDuration: v1alpha.HistoricalRetrievalDuration{Unit: unit, Value: ptr(0)}, } err := validate(agent) testutils.AssertNoError(t, agent, err) @@ -359,10 +357,8 @@ func TestValidateSpec_HistoricalDataRetrieval(t *testing.T) { } { agent := validAgent(v1alpha.Prometheus) agent.Spec.HistoricalDataRetrieval = &v1alpha.HistoricalDataRetrieval{ - MaxDuration: v1alpha.HistoricalRetrievalDuration{Value: ptr(10), Unit: unit}, - DefaultDuration: v1alpha.HistoricalRetrievalDuration{Value: ptr(10), Unit: unit}, - TriggeredBySloCreation: &v1alpha.HistoricalRetrievalDuration{Value: ptr(10), Unit: unit}, - TriggeredBySloEdit: &v1alpha.HistoricalRetrievalDuration{Value: ptr(10), Unit: unit}, + MaxDuration: v1alpha.HistoricalRetrievalDuration{Value: ptr(10), Unit: unit}, + DefaultDuration: v1alpha.HistoricalRetrievalDuration{Value: ptr(10), Unit: unit}, } err := validate(agent) testutils.AssertNoError(t, agent, err) @@ -379,14 +375,6 @@ func TestValidateSpec_HistoricalDataRetrieval(t *testing.T) { Value: ptr(10), Unit: v1alpha.HRDHour, }, - TriggeredBySloCreation: &v1alpha.HistoricalRetrievalDuration{ - Value: ptr(10), - Unit: v1alpha.HRDHour, - }, - TriggeredBySloEdit: &v1alpha.HistoricalRetrievalDuration{ - Value: ptr(10), - Unit: v1alpha.HRDHour, - }, } err := validate(agent) testutils.AssertContainsErrors(t, agent, err, 1, testutils.ExpectedError{ @@ -394,7 +382,7 @@ func TestValidateSpec_HistoricalDataRetrieval(t *testing.T) { Message: "historical data retrieval is not supported for Generic Agent", }) }) - t.Run("data retrieval default, triggeredBySloCreation and TriggeredBySloEdit larger than max", + t.Run("data retrieval default, defaultDuration larger than max", func(t *testing.T) { agent := validAgent(v1alpha.Prometheus) agent.Spec.HistoricalDataRetrieval = &v1alpha.HistoricalDataRetrieval{ @@ -406,25 +394,11 @@ func TestValidateSpec_HistoricalDataRetrieval(t *testing.T) { Value: ptr(2), Unit: v1alpha.HRDHour, }, - TriggeredBySloCreation: &v1alpha.HistoricalRetrievalDuration{ - Value: ptr(10), - Unit: v1alpha.HRDHour, - }, - TriggeredBySloEdit: &v1alpha.HistoricalRetrievalDuration{ - Value: ptr(10), - Unit: v1alpha.HRDHour, - }, } err := validate(agent) - testutils.AssertContainsErrors(t, agent, err, 3, testutils.ExpectedError{ + testutils.AssertContainsErrors(t, agent, err, 1, testutils.ExpectedError{ Prop: "spec.historicalDataRetrieval.defaultDuration", Message: "must be less than or equal to 'maxDuration' (1 Hour)", - }, testutils.ExpectedError{ - Prop: "spec.historicalDataRetrieval.triggeredBySloCreation", - Message: "must be less than or equal to 'maxDuration' (1 Hour)", - }, testutils.ExpectedError{ - Prop: "spec.historicalDataRetrieval.triggeredBySloEdit", - Message: "must be less than or equal to 'maxDuration' (1 Hour)", }) }) t.Run("data retrieval max greater than max allowed", func(t *testing.T) { diff --git a/manifest/v1alpha/data_sources.go b/manifest/v1alpha/data_sources.go index e34c3a5e..f2badc95 100644 --- a/manifest/v1alpha/data_sources.go +++ b/manifest/v1alpha/data_sources.go @@ -238,20 +238,12 @@ type HistoricalDataRetrieval struct { MinimumAgentVersion string `json:"minimumAgentVersion,omitempty"` MaxDuration HistoricalRetrievalDuration `json:"maxDuration" validate:"required"` DefaultDuration HistoricalRetrievalDuration `json:"defaultDuration" validate:"required"` - // TriggeredBySloCreation is not supported yet, applying it will have no effect - TriggeredBySloCreation *HistoricalRetrievalDuration `json:"triggeredBySloCreation,omitempty"` - // TriggeredBySloEdit is not supported yet, applying it will have no effect - TriggeredBySloEdit *HistoricalRetrievalDuration `json:"triggeredBySloEdit,omitempty"` } func HistoricalDataRetrievalValidation() govy.Validator[HistoricalDataRetrieval] { return govy.New[HistoricalDataRetrieval]( govy.For(govy.GetSelf[HistoricalDataRetrieval]()). Rules(defaultDataRetrievalDurationValidation), - govy.For(govy.GetSelf[HistoricalDataRetrieval]()). - Rules(triggeredBySloCreationValidation), - govy.For(govy.GetSelf[HistoricalDataRetrieval]()). - Rules(triggeredBySloEditValidation), govy.For(func(h HistoricalDataRetrieval) HistoricalRetrievalDuration { return h.MaxDuration }). WithName("maxDuration"). Required(). @@ -260,14 +252,6 @@ func HistoricalDataRetrievalValidation() govy.Validator[HistoricalDataRetrieval] WithName("defaultDuration"). Required(). Include(historicalRetrievalDurationValidation), - govy.ForPointer(func(h HistoricalDataRetrieval) *HistoricalRetrievalDuration { return h.TriggeredBySloCreation }). - WithName("triggeredByCreation"). - OmitEmpty(). - Include(historicalRetrievalDurationValidation), - govy.ForPointer(func(h HistoricalDataRetrieval) *HistoricalRetrievalDuration { return h.TriggeredBySloEdit }). - WithName("triggeredByEdit"). - OmitEmpty(). - Include(historicalRetrievalDurationValidation), ) } @@ -299,42 +283,6 @@ var defaultDataRetrievalDurationValidation = govy.NewRule( return nil }) -var triggeredBySloCreationValidation = govy.NewRule( - func(dataRetrieval HistoricalDataRetrieval) error { - if dataRetrieval.TriggeredBySloCreation != nil && - dataRetrieval.TriggeredBySloCreation.BiggerThan(dataRetrieval.MaxDuration) { - var maxDurationValue int - if dataRetrieval.MaxDuration.Value != nil { - maxDurationValue = *dataRetrieval.MaxDuration.Value - } - return govy.NewPropertyError( - "triggeredBySloCreation", - dataRetrieval.TriggeredBySloCreation, - errors.Errorf( - "must be less than or equal to 'maxDuration' (%d %s)", - maxDurationValue, dataRetrieval.MaxDuration.Unit)) - } - return nil - }) - -var triggeredBySloEditValidation = govy.NewRule( - func(dataRetrieval HistoricalDataRetrieval) error { - if dataRetrieval.TriggeredBySloEdit != nil && - dataRetrieval.TriggeredBySloEdit.BiggerThan(dataRetrieval.MaxDuration) { - var maxDurationValue int - if dataRetrieval.MaxDuration.Value != nil { - maxDurationValue = *dataRetrieval.MaxDuration.Value - } - return govy.NewPropertyError( - "triggeredBySloEdit", - dataRetrieval.TriggeredBySloEdit, - errors.Errorf( - "must be less than or equal to 'maxDuration' (%d %s)", - maxDurationValue, dataRetrieval.MaxDuration.Unit)) - } - return nil - }) - // HistoricalRetrievalDuration struct was previously called Duration. However, this name was too generic // since we also needed to introduce a Duration struct for QueryDelay, which allowed for different time units. // Time travel is allowed for days/hours/minutes, and query delay can be set to minutes/seconds. Separating those two diff --git a/manifest/v1alpha/direct/examples/app-dynamics.yaml b/manifest/v1alpha/direct/examples/app-dynamics.yaml index 7658b0ed..c1b963f4 100644 --- a/manifest/v1alpha/direct/examples/app-dynamics.yaml +++ b/manifest/v1alpha/direct/examples/app-dynamics.yaml @@ -20,12 +20,6 @@ spec: defaultDuration: value: 15 unit: Day - triggeredBySloCreation: - value: 15 - unit: Day - triggeredBySloEdit: - value: 15 - unit: Day queryDelay: value: 2 unit: Minute diff --git a/manifest/v1alpha/direct/examples/azure-monitor.yaml b/manifest/v1alpha/direct/examples/azure-monitor.yaml index 7a3dfd7d..fa40fd6f 100644 --- a/manifest/v1alpha/direct/examples/azure-monitor.yaml +++ b/manifest/v1alpha/direct/examples/azure-monitor.yaml @@ -18,12 +18,6 @@ spec: defaultDuration: value: 15 unit: Day - triggeredBySloCreation: - value: 15 - unit: Day - triggeredBySloEdit: - value: 15 - unit: Day queryDelay: value: 6 unit: Minute diff --git a/manifest/v1alpha/direct/examples/azure-prometheus.yaml b/manifest/v1alpha/direct/examples/azure-prometheus.yaml index 36aa340b..a9451c7e 100644 --- a/manifest/v1alpha/direct/examples/azure-prometheus.yaml +++ b/manifest/v1alpha/direct/examples/azure-prometheus.yaml @@ -19,12 +19,6 @@ spec: defaultDuration: value: 15 unit: Day - triggeredBySloCreation: - value: 15 - unit: Day - triggeredBySloEdit: - value: 15 - unit: Day queryDelay: value: 1 unit: Second diff --git a/manifest/v1alpha/direct/examples/cloud-watch.yaml b/manifest/v1alpha/direct/examples/cloud-watch.yaml index f6f11fdc..a84b018c 100644 --- a/manifest/v1alpha/direct/examples/cloud-watch.yaml +++ b/manifest/v1alpha/direct/examples/cloud-watch.yaml @@ -16,12 +16,6 @@ spec: defaultDuration: value: 7 unit: Day - triggeredBySloCreation: - value: 7 - unit: Day - triggeredBySloEdit: - value: 7 - unit: Day queryDelay: value: 2 unit: Minute diff --git a/manifest/v1alpha/direct/examples/datadog.yaml b/manifest/v1alpha/direct/examples/datadog.yaml index a3d29f41..71de31ca 100644 --- a/manifest/v1alpha/direct/examples/datadog.yaml +++ b/manifest/v1alpha/direct/examples/datadog.yaml @@ -18,12 +18,6 @@ spec: defaultDuration: value: 15 unit: Day - triggeredBySloCreation: - value: 15 - unit: Day - triggeredBySloEdit: - value: 15 - unit: Day queryDelay: value: 2 unit: Minute diff --git a/manifest/v1alpha/direct/examples/dynatrace.yaml b/manifest/v1alpha/direct/examples/dynatrace.yaml index 85748694..52e0235d 100644 --- a/manifest/v1alpha/direct/examples/dynatrace.yaml +++ b/manifest/v1alpha/direct/examples/dynatrace.yaml @@ -17,12 +17,6 @@ spec: defaultDuration: value: 14 unit: Day - triggeredBySloCreation: - value: 14 - unit: Day - triggeredBySloEdit: - value: 14 - unit: Day queryDelay: value: 3 unit: Minute diff --git a/manifest/v1alpha/direct/examples/google-cloud-monitoring.yaml b/manifest/v1alpha/direct/examples/google-cloud-monitoring.yaml index c88de6f8..a0dede52 100644 --- a/manifest/v1alpha/direct/examples/google-cloud-monitoring.yaml +++ b/manifest/v1alpha/direct/examples/google-cloud-monitoring.yaml @@ -16,12 +16,6 @@ spec: defaultDuration: value: 15 unit: Day - triggeredBySloCreation: - value: 15 - unit: Day - triggeredBySloEdit: - value: 15 - unit: Day queryDelay: value: 3 unit: Minute diff --git a/manifest/v1alpha/direct/examples/honeycomb.yaml b/manifest/v1alpha/direct/examples/honeycomb.yaml index a0105782..d2d32289 100644 --- a/manifest/v1alpha/direct/examples/honeycomb.yaml +++ b/manifest/v1alpha/direct/examples/honeycomb.yaml @@ -16,12 +16,6 @@ spec: defaultDuration: value: 3 unit: Day - triggeredBySloCreation: - value: 3 - unit: Day - triggeredBySloEdit: - value: 3 - unit: Day queryDelay: value: 6 unit: Minute diff --git a/manifest/v1alpha/direct/examples/lightstep.yaml b/manifest/v1alpha/direct/examples/lightstep.yaml index 9126e757..14491c33 100644 --- a/manifest/v1alpha/direct/examples/lightstep.yaml +++ b/manifest/v1alpha/direct/examples/lightstep.yaml @@ -19,12 +19,6 @@ spec: defaultDuration: value: 15 unit: Day - triggeredBySloCreation: - value: 15 - unit: Day - triggeredBySloEdit: - value: 15 - unit: Day queryDelay: value: 3 unit: Minute diff --git a/manifest/v1alpha/direct/examples/logic-monitor.yaml b/manifest/v1alpha/direct/examples/logic-monitor.yaml index 96c008fd..5e06fa22 100644 --- a/manifest/v1alpha/direct/examples/logic-monitor.yaml +++ b/manifest/v1alpha/direct/examples/logic-monitor.yaml @@ -18,12 +18,6 @@ spec: defaultDuration: value: 15 unit: Day - triggeredBySloCreation: - value: 15 - unit: Day - triggeredBySloEdit: - value: 15 - unit: Day queryDelay: value: 3 unit: Minute diff --git a/manifest/v1alpha/direct/examples/new-relic.yaml b/manifest/v1alpha/direct/examples/new-relic.yaml index 68a6b587..5c143b11 100644 --- a/manifest/v1alpha/direct/examples/new-relic.yaml +++ b/manifest/v1alpha/direct/examples/new-relic.yaml @@ -17,12 +17,6 @@ spec: defaultDuration: value: 15 unit: Day - triggeredBySloCreation: - value: 15 - unit: Day - triggeredBySloEdit: - value: 15 - unit: Day queryDelay: value: 2 unit: Minute diff --git a/manifest/v1alpha/direct/examples/splunk.yaml b/manifest/v1alpha/direct/examples/splunk.yaml index 9340f8ee..3edd492e 100644 --- a/manifest/v1alpha/direct/examples/splunk.yaml +++ b/manifest/v1alpha/direct/examples/splunk.yaml @@ -17,12 +17,6 @@ spec: defaultDuration: value: 15 unit: Day - triggeredBySloCreation: - value: 15 - unit: Day - triggeredBySloEdit: - value: 15 - unit: Day queryDelay: value: 6 unit: Minute diff --git a/manifest/v1alpha/direct/validation.go b/manifest/v1alpha/direct/validation.go index 595ba004..38949dfc 100644 --- a/manifest/v1alpha/direct/validation.go +++ b/manifest/v1alpha/direct/validation.go @@ -367,22 +367,7 @@ var historicalDataRetrievalValidationRule = govy.NewRule(func(spec Spec) error { errors.Errorf("must be less than or equal to %d %s", *maxDurationAllowed.Value, maxDurationAllowed.Unit)) } - if spec.HistoricalDataRetrieval.TriggeredBySloCreation != nil && - spec.HistoricalDataRetrieval.TriggeredBySloCreation.BiggerThan(maxDurationAllowed) { - return govy.NewPropertyError( - "historicalDataRetrieval.triggeredBySloCreation", - spec.HistoricalDataRetrieval.TriggeredBySloCreation, - errors.Errorf("must be less than or equal to %d %s", - *maxDurationAllowed.Value, maxDurationAllowed.Unit)) - } - if spec.HistoricalDataRetrieval.TriggeredBySloEdit != nil && - spec.HistoricalDataRetrieval.TriggeredBySloEdit.BiggerThan(maxDurationAllowed) { - return govy.NewPropertyError( - "historicalDataRetrieval.triggeredBySloEdit", - spec.HistoricalDataRetrieval.TriggeredBySloEdit, - errors.Errorf("must be less than or equal to %d %s", - *maxDurationAllowed.Value, maxDurationAllowed.Unit)) - } + return nil }) diff --git a/manifest/v1alpha/direct/validation_test.go b/manifest/v1alpha/direct/validation_test.go index e027d173..ac8fd311 100644 --- a/manifest/v1alpha/direct/validation_test.go +++ b/manifest/v1alpha/direct/validation_test.go @@ -262,10 +262,8 @@ func TestValidateSpec_HistoricalDataRetrieval(t *testing.T) { } { direct := validDirect(v1alpha.Datadog) direct.Spec.HistoricalDataRetrieval = &v1alpha.HistoricalDataRetrieval{ - MaxDuration: v1alpha.HistoricalRetrievalDuration{Unit: unit, Value: ptr(0)}, - DefaultDuration: v1alpha.HistoricalRetrievalDuration{Unit: unit, Value: ptr(0)}, - TriggeredBySloCreation: &v1alpha.HistoricalRetrievalDuration{Unit: unit, Value: ptr(0)}, - TriggeredBySloEdit: &v1alpha.HistoricalRetrievalDuration{Unit: unit, Value: ptr(0)}, + MaxDuration: v1alpha.HistoricalRetrievalDuration{Unit: unit, Value: ptr(0)}, + DefaultDuration: v1alpha.HistoricalRetrievalDuration{Unit: unit, Value: ptr(0)}, } err := validate(direct) testutils.AssertNoError(t, direct, err) @@ -389,10 +387,8 @@ func TestValidateSpec_HistoricalDataRetrieval(t *testing.T) { } { direct := validDirect(v1alpha.Datadog) direct.Spec.HistoricalDataRetrieval = &v1alpha.HistoricalDataRetrieval{ - MaxDuration: v1alpha.HistoricalRetrievalDuration{Value: ptr(10), Unit: unit}, - DefaultDuration: v1alpha.HistoricalRetrievalDuration{Value: ptr(10), Unit: unit}, - TriggeredBySloCreation: &v1alpha.HistoricalRetrievalDuration{Value: ptr(10), Unit: unit}, - TriggeredBySloEdit: &v1alpha.HistoricalRetrievalDuration{Value: ptr(10), Unit: unit}, + MaxDuration: v1alpha.HistoricalRetrievalDuration{Value: ptr(10), Unit: unit}, + DefaultDuration: v1alpha.HistoricalRetrievalDuration{Value: ptr(10), Unit: unit}, } err := validate(direct) testutils.AssertNoError(t, direct, err) @@ -416,7 +412,7 @@ func TestValidateSpec_HistoricalDataRetrieval(t *testing.T) { Message: "historical data retrieval is not supported for Instana Direct", }) }) - t.Run("data retrieval default, triggeredBySloCreation and TriggeredBySloEdit larger than max", + t.Run("data retrieval default, defaultDuration larger than max", func(t *testing.T) { direct := validDirect(v1alpha.Datadog) direct.Spec.HistoricalDataRetrieval = &v1alpha.HistoricalDataRetrieval{ @@ -428,25 +424,11 @@ func TestValidateSpec_HistoricalDataRetrieval(t *testing.T) { Value: ptr(2), Unit: v1alpha.HRDHour, }, - TriggeredBySloCreation: &v1alpha.HistoricalRetrievalDuration{ - Value: ptr(10), - Unit: v1alpha.HRDHour, - }, - TriggeredBySloEdit: &v1alpha.HistoricalRetrievalDuration{ - Value: ptr(10), - Unit: v1alpha.HRDHour, - }, } err := validate(direct) - testutils.AssertContainsErrors(t, direct, err, 3, testutils.ExpectedError{ + testutils.AssertContainsErrors(t, direct, err, 1, testutils.ExpectedError{ Prop: "spec.historicalDataRetrieval.defaultDuration", Message: "must be less than or equal to 'maxDuration' (1 Hour)", - }, testutils.ExpectedError{ - Prop: "spec.historicalDataRetrieval.triggeredBySloCreation", - Message: "must be less than or equal to 'maxDuration' (1 Hour)", - }, testutils.ExpectedError{ - Prop: "spec.historicalDataRetrieval.triggeredBySloEdit", - Message: "must be less than or equal to 'maxDuration' (1 Hour)", }) }) t.Run("data retrieval max greater than max allowed", func(t *testing.T) {