diff --git a/api/external/api.go b/api/external/api.go index 59802ab5e..a63579979 100644 --- a/api/external/api.go +++ b/api/external/api.go @@ -11,6 +11,7 @@ type Describable interface { GetIcon() string GetName() string GetLabels() map[string]string + GetTransformDeleteStrategy() string } type WithType interface { diff --git a/api/v1/checks.go b/api/v1/checks.go index 5df6ce171..5db0c512b 100644 --- a/api/v1/checks.go +++ b/api/v1/checks.go @@ -15,6 +15,11 @@ import ( "k8s.io/client-go/kubernetes" ) +const ( + OnTransformMarkHealthy = "MarkHealthy" + OnTransformMarkUnhealthy = "MarkUnhealthy" +) + type checkContext interface { context.Context HydrateConnectionByURL(connectionName string) (*models.Connection, error) diff --git a/api/v1/common.go b/api/v1/common.go index f37f15876..464543e34 100644 --- a/api/v1/common.go +++ b/api/v1/common.go @@ -280,6 +280,8 @@ type Description struct { Icon string `yaml:"icon,omitempty" json:"icon,omitempty" template:"true"` // Labels for the check Labels Labels `yaml:"labels,omitempty" json:"labels,omitempty"` + // Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + TransformDeleteStrategy string `yaml:"transformDeleteStrategy,omitempty" json:"transformDeleteStrategy,omitempty"` } func (d Description) String() string { @@ -305,6 +307,10 @@ func (d Description) GetLabels() map[string]string { return d.Labels } +func (d Description) GetTransformDeleteStrategy() string { + return d.TransformDeleteStrategy +} + type Connection struct { // Connection name e.g. connection://http/google Connection string `yaml:"connection,omitempty" json:"connection,omitempty"` diff --git a/checks/common.go b/checks/common.go index 4d4708bcf..73ff71fbf 100644 --- a/checks/common.go +++ b/checks/common.go @@ -84,6 +84,7 @@ func transform(ctx *context.Context, in *pkg.CheckResult) ([]*pkg.CheckResult, e t.Name = def(t.Name, in.Check.GetName()) t.Type = def(t.Type, in.Check.GetType()) t.Endpoint = def(t.Endpoint, in.Check.GetEndpoint()) + t.TransformDeleteStrategy = def(t.TransformDeleteStrategy, in.Check.GetTransformDeleteStrategy()) r := t.ToCheckResult() r.Canary = in.Canary r.Canary.Namespace = def(t.Namespace, r.Canary.Namespace) @@ -96,6 +97,7 @@ func transform(ctx *context.Context, in *pkg.CheckResult) ([]*pkg.CheckResult, e // We use this label to set the transformed column to true // This label is used and then removed in pkg.FromV1 function r.Canary.Labels["transformed"] = "true" //nolint:goconst + r.Transformed = true results = append(results, &r) } diff --git a/config/deploy/crd.yaml b/config/deploy/crd.yaml index d1298ca64..f7011d872 100644 --- a/config/deploy/crd.yaml +++ b/config/deploy/crd.yaml @@ -150,6 +150,9 @@ spec: template: type: string type: object + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string url: description: Connection url, interpolated with username,password type: string @@ -308,6 +311,9 @@ spec: template: type: string type: object + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string usePathStyle: description: 'Use path style path: http://s3.amazonaws.com/BUCKET/KEY instead of http://BUCKET.s3.amazonaws.com/KEY' type: boolean @@ -450,6 +456,9 @@ spec: template: type: string type: object + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string usePathStyle: description: 'Use path style path: http://s3.amazonaws.com/BUCKET/KEY instead of http://BUCKET.s3.amazonaws.com/KEY' type: boolean @@ -550,6 +559,9 @@ spec: template: type: string type: object + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string variables: additionalProperties: type: string @@ -694,6 +706,9 @@ spec: template: type: string type: object + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string usePathStyle: description: 'Use path style path: http://s3.amazonaws.com/BUCKET/KEY instead of http://BUCKET.s3.amazonaws.com/KEY' type: boolean @@ -753,6 +768,9 @@ spec: template: type: string type: object + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string required: - name - query @@ -841,6 +859,9 @@ spec: name: description: Name of the check type: string + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string required: - image - name @@ -867,6 +888,9 @@ spec: type: string password: type: string + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string username: type: string required: @@ -972,6 +996,9 @@ spec: template: type: string type: object + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string required: - name type: object @@ -1011,6 +1038,9 @@ spec: type: integer timeout: type: integer + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string required: - name type: object @@ -1098,6 +1128,9 @@ spec: name: description: Name of the check type: string + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string required: - image - name @@ -1181,6 +1214,9 @@ spec: name: description: Name of the check type: string + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string required: - image - name @@ -1272,6 +1308,9 @@ spec: template: type: string type: object + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string required: - name type: object @@ -1380,6 +1419,9 @@ spec: type: boolean timeOut: type: integer + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string usePathStyle: description: 'Use path style path: http://s3.amazonaws.com/BUCKET/KEY instead of http://BUCKET.s3.amazonaws.com/KEY' type: boolean @@ -1478,6 +1520,9 @@ spec: template: type: string type: object + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string url: description: Connection url, interpolated with username,password type: string @@ -1619,6 +1664,9 @@ spec: template: type: string type: object + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string required: - name - script @@ -1962,6 +2010,9 @@ spec: template: type: string type: object + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string required: - name - path @@ -2050,6 +2101,9 @@ spec: template: type: string type: object + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string required: - name - query @@ -2137,6 +2191,9 @@ spec: type: string project: type: string + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string required: - name type: object @@ -2299,6 +2356,9 @@ spec: template: type: string type: object + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string url: description: Connection url, interpolated with username,password type: string @@ -2361,6 +2421,9 @@ spec: thresholdMillis: format: int64 type: integer + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string required: - name type: object @@ -2437,6 +2500,9 @@ spec: items: type: string type: array + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string required: - jmx - name @@ -2500,6 +2566,9 @@ spec: template: type: string type: object + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string required: - name - spec @@ -2583,6 +2652,9 @@ spec: template: type: string type: object + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string required: - kind - name @@ -2640,6 +2712,9 @@ spec: type: object skipTLSVerify: type: boolean + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string url: description: Connection url, interpolated with username,password type: string @@ -2726,6 +2801,9 @@ spec: type: object type: object type: object + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string url: description: Connection url, interpolated with username,password type: string @@ -2847,6 +2925,9 @@ spec: template: type: string type: object + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string url: description: Connection url, interpolated with username,password type: string @@ -2968,6 +3049,9 @@ spec: template: type: string type: object + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string url: description: Connection url, interpolated with username,password type: string @@ -3071,6 +3155,9 @@ spec: schedule_timeout: format: int64 type: integer + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string required: - name - podSpec @@ -3164,6 +3251,9 @@ spec: template: type: string type: object + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string url: description: Connection url, interpolated with username,password type: string @@ -3264,6 +3354,9 @@ spec: type: integer spec: type: string + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string required: - name type: object @@ -3354,6 +3447,9 @@ spec: template: type: string type: object + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string url: description: Connection url, interpolated with username,password type: string @@ -3476,6 +3572,9 @@ spec: template: type: string type: object + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string url: description: Connection url, interpolated with username,password type: string @@ -3565,6 +3664,9 @@ spec: type: object type: object type: object + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string url: description: Connection url, interpolated with username,password type: string @@ -3722,6 +3824,9 @@ spec: type: object type: object type: object + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string required: - maxAge - name @@ -3819,6 +3924,9 @@ spec: skipTLSVerify: description: Skip TLS verify when connecting to aws type: boolean + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string usePathStyle: description: 'Use path style path: http://s3.amazonaws.com/BUCKET/KEY instead of http://BUCKET.s3.amazonaws.com/KEY' type: boolean @@ -3853,6 +3961,9 @@ spec: thresholdMillis: format: int64 type: integer + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string required: - name type: object diff --git a/config/deploy/manifests.yaml b/config/deploy/manifests.yaml index 67ee9e654..aa16e94ab 100644 --- a/config/deploy/manifests.yaml +++ b/config/deploy/manifests.yaml @@ -150,6 +150,9 @@ spec: template: type: string type: object + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string url: description: Connection url, interpolated with username,password type: string @@ -308,6 +311,9 @@ spec: template: type: string type: object + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string usePathStyle: description: 'Use path style path: http://s3.amazonaws.com/BUCKET/KEY instead of http://BUCKET.s3.amazonaws.com/KEY' type: boolean @@ -450,6 +456,9 @@ spec: template: type: string type: object + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string usePathStyle: description: 'Use path style path: http://s3.amazonaws.com/BUCKET/KEY instead of http://BUCKET.s3.amazonaws.com/KEY' type: boolean @@ -550,6 +559,9 @@ spec: template: type: string type: object + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string variables: additionalProperties: type: string @@ -694,6 +706,9 @@ spec: template: type: string type: object + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string usePathStyle: description: 'Use path style path: http://s3.amazonaws.com/BUCKET/KEY instead of http://BUCKET.s3.amazonaws.com/KEY' type: boolean @@ -753,6 +768,9 @@ spec: template: type: string type: object + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string required: - name - query @@ -841,6 +859,9 @@ spec: name: description: Name of the check type: string + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string required: - image - name @@ -867,6 +888,9 @@ spec: type: string password: type: string + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string username: type: string required: @@ -972,6 +996,9 @@ spec: template: type: string type: object + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string required: - name type: object @@ -1011,6 +1038,9 @@ spec: type: integer timeout: type: integer + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string required: - name type: object @@ -1098,6 +1128,9 @@ spec: name: description: Name of the check type: string + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string required: - image - name @@ -1181,6 +1214,9 @@ spec: name: description: Name of the check type: string + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string required: - image - name @@ -1272,6 +1308,9 @@ spec: template: type: string type: object + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string required: - name type: object @@ -1380,6 +1419,9 @@ spec: type: boolean timeOut: type: integer + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string usePathStyle: description: 'Use path style path: http://s3.amazonaws.com/BUCKET/KEY instead of http://BUCKET.s3.amazonaws.com/KEY' type: boolean @@ -1478,6 +1520,9 @@ spec: template: type: string type: object + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string url: description: Connection url, interpolated with username,password type: string @@ -1619,6 +1664,9 @@ spec: template: type: string type: object + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string required: - name - script @@ -1962,6 +2010,9 @@ spec: template: type: string type: object + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string required: - name - path @@ -2050,6 +2101,9 @@ spec: template: type: string type: object + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string required: - name - query @@ -2137,6 +2191,9 @@ spec: type: string project: type: string + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string required: - name type: object @@ -2299,6 +2356,9 @@ spec: template: type: string type: object + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string url: description: Connection url, interpolated with username,password type: string @@ -2361,6 +2421,9 @@ spec: thresholdMillis: format: int64 type: integer + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string required: - name type: object @@ -2437,6 +2500,9 @@ spec: items: type: string type: array + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string required: - jmx - name @@ -2500,6 +2566,9 @@ spec: template: type: string type: object + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string required: - name - spec @@ -2583,6 +2652,9 @@ spec: template: type: string type: object + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string required: - kind - name @@ -2640,6 +2712,9 @@ spec: type: object skipTLSVerify: type: boolean + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string url: description: Connection url, interpolated with username,password type: string @@ -2726,6 +2801,9 @@ spec: type: object type: object type: object + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string url: description: Connection url, interpolated with username,password type: string @@ -2847,6 +2925,9 @@ spec: template: type: string type: object + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string url: description: Connection url, interpolated with username,password type: string @@ -2968,6 +3049,9 @@ spec: template: type: string type: object + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string url: description: Connection url, interpolated with username,password type: string @@ -3071,6 +3155,9 @@ spec: schedule_timeout: format: int64 type: integer + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string required: - name - podSpec @@ -3164,6 +3251,9 @@ spec: template: type: string type: object + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string url: description: Connection url, interpolated with username,password type: string @@ -3264,6 +3354,9 @@ spec: type: integer spec: type: string + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string required: - name type: object @@ -3354,6 +3447,9 @@ spec: template: type: string type: object + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string url: description: Connection url, interpolated with username,password type: string @@ -3476,6 +3572,9 @@ spec: template: type: string type: object + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string url: description: Connection url, interpolated with username,password type: string @@ -3565,6 +3664,9 @@ spec: type: object type: object type: object + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string url: description: Connection url, interpolated with username,password type: string @@ -3722,6 +3824,9 @@ spec: type: object type: object type: object + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string required: - maxAge - name @@ -3819,6 +3924,9 @@ spec: skipTLSVerify: description: Skip TLS verify when connecting to aws type: boolean + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string usePathStyle: description: 'Use path style path: http://s3.amazonaws.com/BUCKET/KEY instead of http://BUCKET.s3.amazonaws.com/KEY' type: boolean @@ -3853,6 +3961,9 @@ spec: thresholdMillis: format: int64 type: integer + transformDeleteStrategy: + description: Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is + type: string required: - name type: object diff --git a/config/schemas/canary.schema.json b/config/schemas/canary.schema.json index 225d7af56..b22f5c0b7 100644 --- a/config/schemas/canary.schema.json +++ b/config/schemas/canary.schema.json @@ -47,6 +47,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, @@ -121,6 +124,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, @@ -182,6 +188,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, @@ -254,6 +263,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, @@ -671,6 +683,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "connection": { "type": "string" }, @@ -749,6 +764,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "query": { "type": "string" } @@ -792,6 +810,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "image": { "type": "string" }, @@ -826,6 +847,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "image": { "type": "string" }, @@ -857,6 +881,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "server": { "type": "string" }, @@ -905,6 +932,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, @@ -941,6 +971,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "image": { "type": "string" }, @@ -975,6 +1008,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "image": { "type": "string" }, @@ -1003,6 +1039,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, @@ -1048,6 +1087,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "connection": { "type": "string" }, @@ -1117,6 +1159,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, @@ -1195,6 +1240,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, @@ -1234,6 +1282,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, @@ -1362,6 +1413,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, @@ -1402,6 +1456,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, @@ -1489,6 +1546,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "chartmuseum": { "type": "string" }, @@ -1522,6 +1582,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "endpoint": { "type": "string" }, @@ -1571,6 +1634,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "jmx": { "$ref": "#/$defs/EnvVar" }, @@ -1617,6 +1683,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "testResults": { "type": "string" }, @@ -1656,6 +1725,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, @@ -1705,6 +1777,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "connection": { "type": "string" }, @@ -1792,6 +1867,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "connection": { "type": "string" }, @@ -1825,6 +1903,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, @@ -1873,6 +1954,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, @@ -1921,6 +2005,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "namespaceNamePrefix": { "type": "string" }, @@ -2095,6 +2182,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, @@ -2178,6 +2268,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "namespace": { "type": "string" }, @@ -2253,6 +2346,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, @@ -2301,6 +2397,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, @@ -2350,6 +2449,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "connection": { "type": "string" }, @@ -2404,6 +2506,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "connection": { "type": "string" }, @@ -2455,6 +2560,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "connection": { "type": "string" }, @@ -2566,6 +2674,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "endpoint": { "type": "string" }, diff --git a/config/schemas/component.schema.json b/config/schemas/component.schema.json index ae87b1661..b93d262b2 100644 --- a/config/schemas/component.schema.json +++ b/config/schemas/component.schema.json @@ -47,6 +47,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, @@ -121,6 +124,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, @@ -182,6 +188,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, @@ -254,6 +263,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, @@ -577,6 +589,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "connection": { "type": "string" }, @@ -892,6 +907,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "query": { "type": "string" } @@ -953,6 +971,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "image": { "type": "string" }, @@ -987,6 +1008,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "image": { "type": "string" }, @@ -1018,6 +1042,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "server": { "type": "string" }, @@ -1066,6 +1093,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, @@ -1120,6 +1150,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "image": { "type": "string" }, @@ -1154,6 +1187,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "image": { "type": "string" }, @@ -1182,6 +1218,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, @@ -1227,6 +1266,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "connection": { "type": "string" }, @@ -1296,6 +1338,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, @@ -1374,6 +1419,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, @@ -1413,6 +1461,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, @@ -1574,6 +1625,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, @@ -1614,6 +1668,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, @@ -1701,6 +1758,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "chartmuseum": { "type": "string" }, @@ -1734,6 +1794,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "endpoint": { "type": "string" }, @@ -1783,6 +1846,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "jmx": { "$ref": "#/$defs/EnvVar" }, @@ -1829,6 +1895,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "testResults": { "type": "string" }, @@ -1868,6 +1937,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, @@ -1917,6 +1989,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "connection": { "type": "string" }, @@ -2054,6 +2129,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "connection": { "type": "string" }, @@ -2087,6 +2165,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, @@ -2135,6 +2216,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, @@ -2183,6 +2267,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "namespaceNamePrefix": { "type": "string" }, @@ -2357,6 +2444,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, @@ -2440,6 +2530,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "namespace": { "type": "string" }, @@ -2515,6 +2608,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, @@ -2563,6 +2659,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, @@ -2684,6 +2783,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "connection": { "type": "string" }, @@ -2756,6 +2858,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "connection": { "type": "string" }, @@ -2807,6 +2912,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "connection": { "type": "string" }, @@ -2962,6 +3070,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "endpoint": { "type": "string" }, diff --git a/config/schemas/health_alertmanager.schema.json b/config/schemas/health_alertmanager.schema.json index 93a6c0009..0750a9f58 100644 --- a/config/schemas/health_alertmanager.schema.json +++ b/config/schemas/health_alertmanager.schema.json @@ -17,6 +17,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, diff --git a/config/schemas/health_awsconfig.schema.json b/config/schemas/health_awsconfig.schema.json index b14fd834c..3a57569b3 100644 --- a/config/schemas/health_awsconfig.schema.json +++ b/config/schemas/health_awsconfig.schema.json @@ -17,6 +17,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, diff --git a/config/schemas/health_awsconfigrule.schema.json b/config/schemas/health_awsconfigrule.schema.json index 245ec69bc..12b54f0fa 100644 --- a/config/schemas/health_awsconfigrule.schema.json +++ b/config/schemas/health_awsconfigrule.schema.json @@ -17,6 +17,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, diff --git a/config/schemas/health_azuredevops.schema.json b/config/schemas/health_azuredevops.schema.json index b231f3825..86cd8b81f 100644 --- a/config/schemas/health_azuredevops.schema.json +++ b/config/schemas/health_azuredevops.schema.json @@ -17,6 +17,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, diff --git a/config/schemas/health_cloudwatch.schema.json b/config/schemas/health_cloudwatch.schema.json index dac455c88..9f892b571 100644 --- a/config/schemas/health_cloudwatch.schema.json +++ b/config/schemas/health_cloudwatch.schema.json @@ -17,6 +17,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "connection": { "type": "string" }, diff --git a/config/schemas/health_configdb.schema.json b/config/schemas/health_configdb.schema.json index 8db4cbad5..a1f2e1187 100644 --- a/config/schemas/health_configdb.schema.json +++ b/config/schemas/health_configdb.schema.json @@ -26,6 +26,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "query": { "type": "string" } diff --git a/config/schemas/health_containerdPull.schema.json b/config/schemas/health_containerdPull.schema.json index 073ebc88e..30046aa79 100644 --- a/config/schemas/health_containerdPull.schema.json +++ b/config/schemas/health_containerdPull.schema.json @@ -44,6 +44,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "image": { "type": "string" }, diff --git a/config/schemas/health_containerdPush.schema.json b/config/schemas/health_containerdPush.schema.json index d2c9ad260..94d2c9092 100644 --- a/config/schemas/health_containerdPush.schema.json +++ b/config/schemas/health_containerdPush.schema.json @@ -17,6 +17,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "image": { "type": "string" }, diff --git a/config/schemas/health_databasebackupcheck.schema.json b/config/schemas/health_databasebackupcheck.schema.json index 707174a84..7d9689502 100644 --- a/config/schemas/health_databasebackupcheck.schema.json +++ b/config/schemas/health_databasebackupcheck.schema.json @@ -32,6 +32,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, diff --git a/config/schemas/health_dns.schema.json b/config/schemas/health_dns.schema.json index b042bd535..3ae071368 100644 --- a/config/schemas/health_dns.schema.json +++ b/config/schemas/health_dns.schema.json @@ -17,6 +17,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "server": { "type": "string" }, diff --git a/config/schemas/health_dockerPull.schema.json b/config/schemas/health_dockerPull.schema.json index 5bf82ae0f..a54fd8adc 100644 --- a/config/schemas/health_dockerPull.schema.json +++ b/config/schemas/health_dockerPull.schema.json @@ -44,6 +44,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "image": { "type": "string" }, diff --git a/config/schemas/health_dockerPush.schema.json b/config/schemas/health_dockerPush.schema.json index 598c86e57..0ed2eff18 100644 --- a/config/schemas/health_dockerPush.schema.json +++ b/config/schemas/health_dockerPush.schema.json @@ -44,6 +44,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "image": { "type": "string" }, diff --git a/config/schemas/health_dynatrace.schema.json b/config/schemas/health_dynatrace.schema.json index 8ca1b569f..c36f42d43 100644 --- a/config/schemas/health_dynatrace.schema.json +++ b/config/schemas/health_dynatrace.schema.json @@ -32,6 +32,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, diff --git a/config/schemas/health_ec2.schema.json b/config/schemas/health_ec2.schema.json index 4a7cd4420..532d7f8e0 100644 --- a/config/schemas/health_ec2.schema.json +++ b/config/schemas/health_ec2.schema.json @@ -32,6 +32,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "connection": { "type": "string" }, diff --git a/config/schemas/health_elasticsearch.schema.json b/config/schemas/health_elasticsearch.schema.json index 16a9311df..f055e9ac4 100644 --- a/config/schemas/health_elasticsearch.schema.json +++ b/config/schemas/health_elasticsearch.schema.json @@ -32,6 +32,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, diff --git a/config/schemas/health_exec.schema.json b/config/schemas/health_exec.schema.json index ffe2b7f99..42bddf638 100644 --- a/config/schemas/health_exec.schema.json +++ b/config/schemas/health_exec.schema.json @@ -17,6 +17,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, diff --git a/config/schemas/health_folder.schema.json b/config/schemas/health_folder.schema.json index 6f6ec1b01..d2ffe53d8 100644 --- a/config/schemas/health_folder.schema.json +++ b/config/schemas/health_folder.schema.json @@ -89,6 +89,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, diff --git a/config/schemas/health_github.schema.json b/config/schemas/health_github.schema.json index 38e996a23..6ca869779 100644 --- a/config/schemas/health_github.schema.json +++ b/config/schemas/health_github.schema.json @@ -59,6 +59,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, diff --git a/config/schemas/health_helm.schema.json b/config/schemas/health_helm.schema.json index e7bb864df..2a666e68b 100644 --- a/config/schemas/health_helm.schema.json +++ b/config/schemas/health_helm.schema.json @@ -71,6 +71,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "chartmuseum": { "type": "string" }, diff --git a/config/schemas/health_http.schema.json b/config/schemas/health_http.schema.json index 2a703be73..f6de92a2c 100644 --- a/config/schemas/health_http.schema.json +++ b/config/schemas/health_http.schema.json @@ -59,6 +59,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, diff --git a/config/schemas/health_icmp.schema.json b/config/schemas/health_icmp.schema.json index 4571a895b..c13a464c3 100644 --- a/config/schemas/health_icmp.schema.json +++ b/config/schemas/health_icmp.schema.json @@ -17,6 +17,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "endpoint": { "type": "string" }, diff --git a/config/schemas/health_jmeter.schema.json b/config/schemas/health_jmeter.schema.json index dfbcb3c42..83be3a7f6 100644 --- a/config/schemas/health_jmeter.schema.json +++ b/config/schemas/health_jmeter.schema.json @@ -59,6 +59,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "jmx": { "$ref": "#/$defs/EnvVar" }, diff --git a/config/schemas/health_junit.schema.json b/config/schemas/health_junit.schema.json index 388e7a2ed..feface113 100644 --- a/config/schemas/health_junit.schema.json +++ b/config/schemas/health_junit.schema.json @@ -17,6 +17,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "testResults": { "type": "string" }, diff --git a/config/schemas/health_kubernetes.schema.json b/config/schemas/health_kubernetes.schema.json index 1a1673ad7..5e4714c06 100644 --- a/config/schemas/health_kubernetes.schema.json +++ b/config/schemas/health_kubernetes.schema.json @@ -17,6 +17,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, diff --git a/config/schemas/health_ldap.schema.json b/config/schemas/health_ldap.schema.json index 715f818d1..f1646f795 100644 --- a/config/schemas/health_ldap.schema.json +++ b/config/schemas/health_ldap.schema.json @@ -59,6 +59,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "connection": { "type": "string" }, diff --git a/config/schemas/health_mongodb.schema.json b/config/schemas/health_mongodb.schema.json index 965c98918..584fcf642 100644 --- a/config/schemas/health_mongodb.schema.json +++ b/config/schemas/health_mongodb.schema.json @@ -67,6 +67,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "connection": { "type": "string" }, diff --git a/config/schemas/health_mssql.schema.json b/config/schemas/health_mssql.schema.json index 6c8d42c87..c637c9052 100644 --- a/config/schemas/health_mssql.schema.json +++ b/config/schemas/health_mssql.schema.json @@ -67,6 +67,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, diff --git a/config/schemas/health_mysql.schema.json b/config/schemas/health_mysql.schema.json index 987204f58..a3896526a 100644 --- a/config/schemas/health_mysql.schema.json +++ b/config/schemas/health_mysql.schema.json @@ -67,6 +67,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, diff --git a/config/schemas/health_namespace.schema.json b/config/schemas/health_namespace.schema.json index dcb159224..67e2b51cf 100644 --- a/config/schemas/health_namespace.schema.json +++ b/config/schemas/health_namespace.schema.json @@ -25,6 +25,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "namespaceNamePrefix": { "type": "string" }, diff --git a/config/schemas/health_opensearch.schema.json b/config/schemas/health_opensearch.schema.json index b7aa49707..670f57de4 100644 --- a/config/schemas/health_opensearch.schema.json +++ b/config/schemas/health_opensearch.schema.json @@ -67,6 +67,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, diff --git a/config/schemas/health_pod.schema.json b/config/schemas/health_pod.schema.json index e10d25557..462f4dd7d 100644 --- a/config/schemas/health_pod.schema.json +++ b/config/schemas/health_pod.schema.json @@ -25,6 +25,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "namespace": { "type": "string" }, diff --git a/config/schemas/health_postgres.schema.json b/config/schemas/health_postgres.schema.json index 82bf8296a..da46bd050 100644 --- a/config/schemas/health_postgres.schema.json +++ b/config/schemas/health_postgres.schema.json @@ -67,6 +67,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, diff --git a/config/schemas/health_prometheus.schema.json b/config/schemas/health_prometheus.schema.json index b4dcab392..7108b93dc 100644 --- a/config/schemas/health_prometheus.schema.json +++ b/config/schemas/health_prometheus.schema.json @@ -67,6 +67,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, diff --git a/config/schemas/health_redis.schema.json b/config/schemas/health_redis.schema.json index 153d4cc4b..6af8af4b7 100644 --- a/config/schemas/health_redis.schema.json +++ b/config/schemas/health_redis.schema.json @@ -67,6 +67,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "connection": { "type": "string" }, diff --git a/config/schemas/health_restic.schema.json b/config/schemas/health_restic.schema.json index 83ac6f824..598f2f9d5 100644 --- a/config/schemas/health_restic.schema.json +++ b/config/schemas/health_restic.schema.json @@ -67,6 +67,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "connection": { "type": "string" }, diff --git a/config/schemas/health_s3.schema.json b/config/schemas/health_s3.schema.json index f5ef1d382..59b0e78ad 100644 --- a/config/schemas/health_s3.schema.json +++ b/config/schemas/health_s3.schema.json @@ -67,6 +67,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "connection": { "type": "string" }, diff --git a/config/schemas/health_tcp.schema.json b/config/schemas/health_tcp.schema.json index 473faac56..58e408c0b 100644 --- a/config/schemas/health_tcp.schema.json +++ b/config/schemas/health_tcp.schema.json @@ -25,6 +25,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "endpoint": { "type": "string" }, diff --git a/config/schemas/topology.schema.json b/config/schemas/topology.schema.json index c33ab0b94..2dd823626 100644 --- a/config/schemas/topology.schema.json +++ b/config/schemas/topology.schema.json @@ -47,6 +47,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, @@ -121,6 +124,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, @@ -182,6 +188,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, @@ -254,6 +263,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, @@ -577,6 +589,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "connection": { "type": "string" }, @@ -862,6 +877,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "query": { "type": "string" } @@ -923,6 +941,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "image": { "type": "string" }, @@ -957,6 +978,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "image": { "type": "string" }, @@ -988,6 +1012,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "server": { "type": "string" }, @@ -1036,6 +1063,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, @@ -1090,6 +1120,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "image": { "type": "string" }, @@ -1124,6 +1157,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "image": { "type": "string" }, @@ -1152,6 +1188,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, @@ -1197,6 +1236,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "connection": { "type": "string" }, @@ -1266,6 +1308,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, @@ -1344,6 +1389,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, @@ -1383,6 +1431,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, @@ -1544,6 +1595,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, @@ -1584,6 +1638,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, @@ -1671,6 +1728,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "chartmuseum": { "type": "string" }, @@ -1704,6 +1764,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "endpoint": { "type": "string" }, @@ -1753,6 +1816,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "jmx": { "$ref": "#/$defs/EnvVar" }, @@ -1799,6 +1865,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "testResults": { "type": "string" }, @@ -1838,6 +1907,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, @@ -1887,6 +1959,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "connection": { "type": "string" }, @@ -2024,6 +2099,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "connection": { "type": "string" }, @@ -2057,6 +2135,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, @@ -2105,6 +2186,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, @@ -2153,6 +2237,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "namespaceNamePrefix": { "type": "string" }, @@ -2327,6 +2414,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, @@ -2410,6 +2500,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "namespace": { "type": "string" }, @@ -2485,6 +2578,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, @@ -2533,6 +2629,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "test": { "$ref": "#/$defs/Template" }, @@ -2654,6 +2753,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "connection": { "type": "string" }, @@ -2726,6 +2828,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "connection": { "type": "string" }, @@ -2777,6 +2882,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "connection": { "type": "string" }, @@ -2932,6 +3040,9 @@ "labels": { "$ref": "#/$defs/Labels" }, + "transformDeleteStrategy": { + "type": "string" + }, "endpoint": { "type": "string" }, diff --git a/pkg/api.go b/pkg/api.go index 3a0b4aadb..cb2a0b8a3 100644 --- a/pkg/api.go +++ b/pkg/api.go @@ -401,6 +401,7 @@ type CheckResult struct { Message string Error string Metrics []Metric + Transformed bool // Check is the configuration Check external.Check Canary v1.Canary @@ -450,22 +451,23 @@ func (generic GenericCheck) GetEndpoint() string { } type TransformedCheckResult struct { - Start time.Time `json:"start,omitempty"` - Pass bool `json:"pass,omitempty"` - Invalid bool `json:"invalid,omitempty"` - Detail interface{} `json:"detail,omitempty"` - Data map[string]interface{} `json:"data,omitempty"` - Duration int64 `json:"duration,omitempty"` - Description string `json:"description,omitempty"` - DisplayType string `json:"displayType,omitempty"` - Message string `json:"message,omitempty"` - Error string `json:"error,omitempty"` - Name string `json:"name,omitempty"` - Labels map[string]string `json:"labels,omitempty"` - Namespace string `json:"namespace,omitempty"` - Icon string `json:"icon,omitempty"` - Type string `json:"type,omitempty"` - Endpoint string `json:"endpoint,omitempty"` + Start time.Time `json:"start,omitempty"` + Pass bool `json:"pass,omitempty"` + Invalid bool `json:"invalid,omitempty"` + Detail interface{} `json:"detail,omitempty"` + Data map[string]interface{} `json:"data,omitempty"` + Duration int64 `json:"duration,omitempty"` + Description string `json:"description,omitempty"` + DisplayType string `json:"displayType,omitempty"` + Message string `json:"message,omitempty"` + Error string `json:"error,omitempty"` + Name string `json:"name,omitempty"` + Labels map[string]string `json:"labels,omitempty"` + Namespace string `json:"namespace,omitempty"` + Icon string `json:"icon,omitempty"` + Type string `json:"type,omitempty"` + Endpoint string `json:"endpoint,omitempty"` + TransformDeleteStrategy string `json:"transformDeleteStrategy,omitempty"` } func (t TransformedCheckResult) ToCheckResult() CheckResult { @@ -486,10 +488,11 @@ func (t TransformedCheckResult) ToCheckResult() CheckResult { Error: t.Error, Check: GenericCheck{ Description: v1.Description{ - Description: t.Description, - Name: t.Name, - Icon: t.Icon, - Labels: labels, + Description: t.Description, + Name: t.Name, + Icon: t.Icon, + Labels: labels, + TransformDeleteStrategy: t.TransformDeleteStrategy, }, Type: t.Type, Endpoint: t.Endpoint, diff --git a/pkg/controllers/canary_controller.go b/pkg/controllers/canary_controller.go index 219570518..7213499f0 100644 --- a/pkg/controllers/canary_controller.go +++ b/pkg/controllers/canary_controller.go @@ -21,9 +21,6 @@ import ( "time" "github.com/flanksource/canary-checker/pkg/db" - "github.com/flanksource/canary-checker/pkg/metrics" - "github.com/flanksource/canary-checker/pkg/utils" - "github.com/google/uuid" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -98,32 +95,11 @@ func (r *CanaryReconciler) Reconcile(ctx gocontext.Context, req ctrl.Request) (c return ctrl.Result{}, r.Update(ctx, canary) } - c, checks, changed, err := db.PersistCanary(*canary, "kubernetes/"+string(canary.ObjectMeta.UID)) + _, checks, changed, err := db.PersistCanary(*canary, "kubernetes/"+string(canary.ObjectMeta.UID)) if err != nil { return ctrl.Result{Requeue: true}, err } - var checkIDs []string - for _, id := range checks { - checkIDs = append(checkIDs, id) - } - - dbCheckIds := getCheckIDsForCanary(c.ID) - // delete checks which are no longer in the canary - // fetching the checkIds present in the db but not present on the canary - toRemoveCheckIDs := utils.SetDifference(dbCheckIds, checkIDs) - // delete the check and update the cron for now - if len(toRemoveCheckIDs) > 0 { - logger.Info("removing checks from canary", "checkIDs", toRemoveCheckIDs) - if err := db.DeleteChecks(toRemoveCheckIDs); err != nil { - logger.Error(err, "failed to delete checks") - } - metrics.UnregisterGauge(toRemoveCheckIDs) - if err := canaryJobs.SyncCanaryJob(*canary); err != nil { - logger.Error(err, "failed to sync canary job") - } - } - // Sync jobs if canary is created or updated if canary.Generation == 1 || changed { if err := canaryJobs.SyncCanaryJob(*canary); err != nil { @@ -162,7 +138,7 @@ func (r *CanaryReconciler) Report() { var canary v1.Canary err := r.Get(gocontext.Background(), payload.NamespacedName, &canary) if err != nil { - r.Log.Error(err, "failed to get canary", "canary", canary.Name) + r.Log.Error(err, "failed to get canary", "canary", payload.NamespacedName) continue } @@ -202,12 +178,3 @@ func (r *CanaryReconciler) includeNamespace(namespace string) bool { } return false } - -func getCheckIDsForCanary(canaryID uuid.UUID) []string { - checks, _ := db.GetAllActiveChecksForCanary(canaryID) - var checkIDs []string - for _, check := range checks { - checkIDs = append(checkIDs, check.ID.String()) - } - return checkIDs -} diff --git a/pkg/db/canary.go b/pkg/db/canary.go index 6a7f798c2..dbd2b0642 100644 --- a/pkg/db/canary.go +++ b/pkg/db/canary.go @@ -100,14 +100,32 @@ func PersistCheck(check pkg.Check, canaryID uuid.UUID) (uuid.UUID, error) { "deleted_at": nil, } - tx := Gorm.Clauses(clause.OnConflict{ - Columns: []clause.Column{{Name: "canary_id"}, {Name: "type"}, {Name: "name"}, {Name: "agent_id"}}, - DoUpdates: clause.Assignments(assignments), - }).Create(&check) - if tx.Error != nil { - return uuid.Nil, tx.Error + if err := Gorm.Clauses( + clause.OnConflict{ + Columns: []clause.Column{{Name: "canary_id"}, {Name: "type"}, {Name: "name"}, {Name: "agent_id"}}, + DoUpdates: clause.Assignments(assignments), + }, + ).Create(&check).Error; err != nil { + return uuid.Nil, err + } + + // There are cases where we may receive a transformed check with a nil uuid + // We then explicitly query for that ID using the unique fields we have + if check.ID == uuid.Nil { + var err error + var idStr string + if err := Gorm.Table("checks").Select("id").Where("canary_id = ? AND type = ? AND name = ? AND agent_id = ?", check.CanaryID, check.Type, check.Name, uuid.Nil).Find(&idStr).Error; err != nil { + return uuid.Nil, err + } + check.ID, err = uuid.Parse(idStr) + if err != nil { + return uuid.Nil, err + } } + if check.ID == uuid.Nil { + return check.ID, fmt.Errorf("received nil check id for canary:%s", canaryID) + } return check.ID, nil } @@ -121,19 +139,46 @@ func GetTransformedCheckIDs(canaryID string) ([]string, error) { return ids, err } -func UpdateChecksStatus(ids []string, status models.CheckHealthStatus) error { +func AddCheckStatuses(ids []string, status models.CheckHealthStatus) error { if len(ids) == 0 { return nil } - if !utils.Contains(models.CheckHealthStatuses, status) { + if status == "" || !utils.Contains(models.CheckHealthStatuses, status) { return fmt.Errorf("invalid check health status: %s", status) } + checkStatus := false + if status == models.CheckStatusHealthy { + checkStatus = true + } + + var objs []*models.CheckStatus + for _, id := range ids { + if checkID, err := uuid.Parse(id); err != nil { + objs = append(objs, &models.CheckStatus{ + CheckID: checkID, + Time: time.Now().UTC().Format(time.RFC3339), + CreatedAt: time.Now(), + Status: checkStatus, + }) + } + } + return Gorm.Table("check_statuses"). + Create(objs). + Error +} + +func RemoveTransformedChecks(ids []string) error { + if len(ids) == 0 { + return nil + } + updates := map[string]any{ + "deleted_at": gorm.Expr("NOW()"), + } + return Gorm.Table("checks"). Where("id in (?)", ids). - Updates(map[string]any{ - "status": status, - "deleted_at": gorm.Expr("NOW()"), - }). + Where("transformed = true"). + Updates(updates). Error } @@ -174,8 +219,8 @@ func DeleteCheckComponentRelationshipsForCanary(id string, deleteTime time.Time) return Gorm.Table("check_component_relationships").Where("canary_id = ?", id).UpdateColumn("deleted_at", deleteTime).Error } -func DeleteChecks(id []string) error { - return Gorm.Table("checks").Where("id IN (?)", id).UpdateColumn("deleted_at", time.Now()).Error +func DeleteNonTransformedChecks(id []string) error { + return Gorm.Table("checks").Where("id IN (?) and transformed = false", id).UpdateColumn("deleted_at", time.Now()).Error } func GetCanary(id string) (pkg.Canary, error) { @@ -276,8 +321,20 @@ func PersistCanary(canary v1.Canary, source string) (*pkg.Canary, map[string]str } } - var checks = make(map[string]string) + var oldCheckIDs []string + err = Gorm. + Table("checks"). + Select("id"). + Where("canary_id = ? AND deleted_at IS NULL AND transformed = false", model.ID). + Scan(&oldCheckIDs). + Error + if err != nil { + logger.Errorf("Error fetching existing checks for canary:%s", model.ID) + return nil, nil, changed, err + } + var checks = make(map[string]string) + var newCheckIDs []string for _, config := range canary.Spec.GetAllChecks() { check := pkg.FromExternalCheck(model, config) // not creating the new check if already exists in the status @@ -290,9 +347,20 @@ func PersistCanary(canary v1.Canary, source string) (*pkg.Canary, map[string]str if err != nil { logger.Errorf("error persisting check", err) } + newCheckIDs = append(newCheckIDs, id.String()) checks[config.GetName()] = id.String() } + // Delete non-transformed checks which are no longer in the canary + // fetching the checkIds present in the db but not present on the canary + checkIDsToRemove := utils.SetDifference(oldCheckIDs, newCheckIDs) + if len(checkIDsToRemove) > 0 { + logger.Infof("removing checks from canary:%s with ids %v", model.ID, checkIDsToRemove) + if err := DeleteNonTransformedChecks(checkIDsToRemove); err != nil { + logger.Errorf("failed to delete non transformed checks: %v", err) + } + metrics.UnregisterGauge(checkIDsToRemove) + } return &model, checks, changed, nil } diff --git a/pkg/jobs/canary/canary_jobs.go b/pkg/jobs/canary/canary_jobs.go index deae5d86b..b655f3180 100644 --- a/pkg/jobs/canary/canary_jobs.go +++ b/pkg/jobs/canary/canary_jobs.go @@ -53,9 +53,8 @@ type CanaryJob struct { Kubernetes kubernetes.Interface Canary v1.Canary DBCanary pkg.Canary - // model pkg.Canary - LogPass bool - LogFail bool + LogPass bool + LogFail bool } func (job CanaryJob) GetNamespacedName() types.NamespacedName { @@ -66,15 +65,16 @@ var minimumTimeBetweenCanaryRuns = 10 * time.Second var canaryLastRuntimes = sync.Map{} func (job CanaryJob) Run() { - val, _ := concurrentJobLocks.LoadOrStore(job.Canary.GetPersistedID(), &sync.Mutex{}) + canaryID := job.DBCanary.ID.String() + val, _ := concurrentJobLocks.LoadOrStore(canaryID, &sync.Mutex{}) lock, ok := val.(*sync.Mutex) if !ok { - logger.Warnf("expected mutex but got %T for canary(id=%s)", lock, job.Canary.GetPersistedID()) + logger.Warnf("expected mutex but got %T for canary(id=%s)", lock, canaryID) return } if !lock.TryLock() { - logger.Debugf("config (id=%s) is already running. skipping this run ...", job.Canary.GetPersistedID()) + logger.Debugf("config (id=%s) is already running. skipping this run ...", canaryID) return } defer lock.Unlock() @@ -82,38 +82,62 @@ func (job CanaryJob) Run() { lastRunDelta := minimumTimeBetweenCanaryRuns // Get last runtime from sync map var lastRuntime time.Time - if lastRuntimeVal, exists := canaryLastRuntimes.Load(job.Canary.GetPersistedID()); exists { + if lastRuntimeVal, exists := canaryLastRuntimes.Load(canaryID); exists { lastRuntime = lastRuntimeVal.(time.Time) lastRunDelta = time.Since(lastRuntime) } // Skip run if job ran too recently if lastRunDelta < minimumTimeBetweenCanaryRuns { - logger.Infof("Skipping Canary[%s]:%s since it last ran %.2f seconds ago", job.Canary.GetPersistedID(), job.GetNamespacedName(), lastRunDelta.Seconds()) + logger.Infof("Skipping Canary[%s]:%s since it last ran %.2f seconds ago", canaryID, job.GetNamespacedName(), lastRunDelta.Seconds()) return } // Get transformed checks before and after, and then delete the olds ones that are not in new set - existingTransformedChecks, _ := db.GetTransformedCheckIDs(job.Canary.GetPersistedID()) - var newChecksCreated []string + existingTransformedChecks, _ := db.GetTransformedCheckIDs(canaryID) + var transformedChecksCreated []string + // Transformed checks have a delete strategy + // On deletion they can either be marked healthy, unhealthy or left as is + checkIDDeleteStrategyMap := make(map[string]string) results := checks.RunChecks(job.NewContext()) for _, result := range results { if job.LogPass && result.Pass || job.LogFail && !result.Pass { logger.Infof(result.String()) } - checkIDsAdded := cache.PostgresCache.Add(pkg.FromV1(result.Canary, result.Check), pkg.FromResult(*result)) - newChecksCreated = append(newChecksCreated, checkIDsAdded...) + transformedChecksAdded := cache.PostgresCache.Add(pkg.FromV1(result.Canary, result.Check), pkg.FromResult(*result)) + transformedChecksCreated = append(transformedChecksCreated, transformedChecksAdded...) + for _, checkID := range transformedChecksAdded { + checkIDDeleteStrategyMap[checkID] = result.Check.GetTransformDeleteStrategy() + } } job.updateStatusAndEvent(results) - // Checks which are not present now should be marked as healthy - checksToMarkHealthy := utils.SetDifference(existingTransformedChecks, newChecksCreated) - if err := db.UpdateChecksStatus(checksToMarkHealthy, models.CheckStatusHealthy); err != nil { - logger.Errorf("error deleting transformed checks for canary %s: %v", job.Canary.GetPersistedID(), err) + checkDeleteStrategyGroup := make(map[string][]string) + checksToRemove := utils.SetDifference(existingTransformedChecks, transformedChecksCreated) + if len(checksToRemove) > 0 && len(transformedChecksCreated) > 0 { + for _, checkID := range checksToRemove { + strategy := checkIDDeleteStrategyMap[checkID] + // Empty status by default does not effect check status + var status string + if strategy == v1.OnTransformMarkHealthy { + status = models.CheckStatusHealthy + } else if strategy == v1.OnTransformMarkUnhealthy { + status = models.CheckStatusUnhealthy + } + checkDeleteStrategyGroup[status] = append(checkDeleteStrategyGroup[status], checkID) + } + for status, checkIDs := range checkDeleteStrategyGroup { + if err := db.AddCheckStatuses(checkIDs, models.CheckHealthStatus(status)); err != nil { + logger.Errorf("error adding statuses for transformed checks") + } + if err := db.RemoveTransformedChecks(checkIDs); err != nil { + logger.Errorf("error deleting transformed checks for canary %s: %v", canaryID, err) + } + } } // Update last runtime map - canaryLastRuntimes.Store(job.Canary.GetPersistedID(), time.Now()) + canaryLastRuntimes.Store(canaryID, time.Now()) } func (job *CanaryJob) NewContext() *context.Context { @@ -217,7 +241,7 @@ type CanaryStatusPayload struct { func findCronEntry(id string) *cron.Entry { for _, entry := range CanaryScheduler.Entries() { - if entry.Job.(CanaryJob).Canary.GetPersistedID() == id { + if entry.Job.(CanaryJob).DBCanary.ID.String() == id { return &entry } } @@ -264,7 +288,6 @@ func SyncCanaryJob(canary v1.Canary) error { if err != nil { return err } - job := CanaryJob{ Client: Kommons, Kubernetes: Kubernetes, @@ -275,7 +298,7 @@ func SyncCanaryJob(canary v1.Canary) error { } updateTime, exists := canaryUpdateTimeCache.Load(dbCanary.ID.String()) - entry := findCronEntry(canary.GetPersistedID()) + entry := findCronEntry(dbCanary.ID.String()) if !exists || dbCanary.UpdatedAt.After(updateTime.(time.Time)) || entry == nil { // Remove entry if it exists if entry != nil { diff --git a/pkg/metrics/metrics.go b/pkg/metrics/metrics.go index 89db1bb9f..9f78977cd 100644 --- a/pkg/metrics/metrics.go +++ b/pkg/metrics/metrics.go @@ -140,7 +140,9 @@ func Record(canary v1.Canary, result *pkg.CheckResult) (_uptime pkg.Uptime, _lat return _uptime, _latency } if canary.GetCheckID(result.Check.GetName()) == "" { - logger.Warnf("%s/%s/%s returned a result for a check that does not exist", canary.Namespace, canary.Name, result.Check.GetName()) + if val := result.Canary.Labels["transformed"]; val != "true" { + logger.Warnf("%s/%s/%s returned a result for a check that does not exist", canary.Namespace, canary.Name, result.Check.GetName()) + } return _uptime, _latency } canaryNamespace := canary.Namespace