From 083f1bfcc2977a09ad24e9dbe0948719c4aaf7a2 Mon Sep 17 00:00:00 2001 From: Moshe Immerman Date: Wed, 20 Dec 2023 18:28:46 +0200 Subject: [PATCH 1/6] chore: remove obsolete push mode --- cmd/root.go | 4 +-- cmd/serve.go | 18 +++-------- pkg/jobs/canary/canary_jobs.go | 4 --- pkg/push/queue.go | 59 ---------------------------------- 4 files changed, 7 insertions(+), 78 deletions(-) delete mode 100644 pkg/push/queue.go diff --git a/cmd/root.go b/cmd/root.go index f649e76b3..5abd9e666 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -68,14 +68,14 @@ func ServerFlags(flags *pflag.FlagSet) { _ = flags.MarkDeprecated("devGuiPort", "") _ = flags.MarkDeprecated("metricsPort", "Extra metrics server removed") _ = flags.MarkDeprecated("dev", "") + _ = flags.MarkDeprecated("push-servers", "") + _ = flags.MarkDeprecated("pull-servers", "") flags.StringVar(&publicEndpoint, "public-endpoint", publicEndpoint, "Host on which the health dashboard is exposed. Could be used for generting-links, redirects etc.") flags.StringSliceVar(&runner.IncludeCanaries, "include-check", []string{}, "Run matching canaries - useful for debugging") flags.StringSliceVar(&runner.IncludeTypes, "include-type", []string{}, "Check type to disable") flags.StringSliceVar(&runner.IncludeNamespaces, "include-namespace", []string{}, "Check type to disable") flags.IntVar(&cache.DefaultCacheCount, "maxStatusCheckCount", 5, "Maximum number of past checks in the in memory cache") - flags.StringSliceVar(&pushServers, "push-servers", []string{}, "push check results to multiple canary servers") - flags.StringSliceVar(&pullServers, "pull-servers", []string{}, "push check results to multiple canary servers") flags.StringVar(&runner.RunnerName, "name", "local", "Server name shown in aggregate dashboard") flags.StringVar(&prometheus.PrometheusURL, "prometheus", "", "URL of the prometheus server that is scraping this instance") flags.StringVar(&db.ConnectionString, "db", "DB_URL", "Connection string for the postgres database. Use embedded:///path/to/dir to use the embedded database") diff --git a/cmd/serve.go b/cmd/serve.go index 27b50efc6..7b8aa0e10 100644 --- a/cmd/serve.go +++ b/cmd/serve.go @@ -23,18 +23,16 @@ import ( "github.com/flanksource/canary-checker/pkg/db" "github.com/flanksource/canary-checker/pkg/jobs" canaryJobs "github.com/flanksource/canary-checker/pkg/jobs/canary" + "github.com/flanksource/duty" "github.com/flanksource/canary-checker/pkg/runner" - "github.com/flanksource/canary-checker/pkg/push" - "github.com/flanksource/canary-checker/pkg/api" "github.com/flanksource/canary-checker/pkg/cache" "github.com/flanksource/canary-checker/pkg/prometheus" commonsCtx "github.com/flanksource/commons/context" "github.com/flanksource/commons/logger" dutyContext "github.com/flanksource/duty/context" - "github.com/flanksource/duty/models" prom "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promhttp" "github.com/spf13/cobra" @@ -64,12 +62,6 @@ func setup() { } cache.PostgresCache = cache.NewPostgresCache(db.Pool) - push.AddServers(pushServers) - - if err := models.SetPropertiesInDBFromFile(db.Gorm, propertiesFile); err != nil { - logger.Fatalf("Error setting properties in database: %v", err) - } - kommonsClient, k8s, err := pkg.NewKommonsClient() if err != nil { logger.Warnf("failed to get kommons client, checks that read kubernetes configs will fail: %v", err) @@ -81,7 +73,10 @@ func setup() { WithKommons(kommonsClient). WithNamespace(runner.WatchNamespace) - go push.Start() + if err := duty.UpdatePropertiesFromFile(apicontext.DefaultContext, propertiesFile); err != nil { + logger.Fatalf("Error setting properties in database: %v", err) + } + } func postgrestResponseModifier(r *http.Response) error { @@ -123,9 +118,6 @@ func serve() { // PostgREST needs to know how it is exposed to create the correct links db.HTTPEndpoint = publicEndpoint + "/db" - push.AddServers(pushServers) - go push.Start() - runner.Prometheus, _ = prometheus.NewPrometheusAPI(prometheus.PrometheusURL) if debug { diff --git a/pkg/jobs/canary/canary_jobs.go b/pkg/jobs/canary/canary_jobs.go index 92720d518..37635669e 100644 --- a/pkg/jobs/canary/canary_jobs.go +++ b/pkg/jobs/canary/canary_jobs.go @@ -14,7 +14,6 @@ import ( "github.com/flanksource/canary-checker/pkg/cache" "github.com/flanksource/canary-checker/pkg/db" "github.com/flanksource/canary-checker/pkg/metrics" - "github.com/flanksource/canary-checker/pkg/push" "github.com/flanksource/canary-checker/pkg/runner" "github.com/flanksource/canary-checker/pkg/utils" "github.com/flanksource/commons/logger" @@ -318,9 +317,6 @@ func updateCanaryStatusAndEvent(ctx context.Context, canary v1.Canary, results [ lastTransitionedTime = &metav1.Time{Time: transitionTime} } - // TODO Why is this here ? - push.Queue(pkg.FromV1(canary, result.Check), pkg.CheckStatusFromResult(*result)) - // Update status message if len(messages) == 1 { msg = messages[0] diff --git a/pkg/push/queue.go b/pkg/push/queue.go deleted file mode 100644 index 6c860d162..000000000 --- a/pkg/push/queue.go +++ /dev/null @@ -1,59 +0,0 @@ -package push - -import ( - "bytes" - "encoding/json" - "strings" - "time" - - "github.com/flanksource/canary-checker/pkg" - "github.com/flanksource/canary-checker/pkg/api" - - "github.com/flanksource/commons/logger" - goqueue "github.com/phf/go-queue/queue" -) - -var Queues = make(map[string]*goqueue.Queue) - -func AddServers(servers []string) { - for _, name := range servers { - Queues[name] = goqueue.New() - } -} - -func Queue(check pkg.Check, status pkg.CheckStatus) { - data := api.QueueData{ - Check: check, - Status: status, - } - for _, queue := range Queues { - queue.PushBack(data) - } -} - -func Start() { - for server, queue := range Queues { - go consumeQueue(server, queue) - } -} - -func consumeQueue(server string, queue *goqueue.Queue) { - for { - element := queue.PopBack() - if element == nil { - time.Sleep(100 * time.Millisecond) - continue - } - data := element.(api.QueueData) - jsonData, err := json.Marshal(data) - if err != nil { - logger.Errorf("error unmarshalling request body: %v", err) - continue - } - err = api.PostDataToServer(strings.TrimSpace(server), bytes.NewBuffer(jsonData)) - if err != nil { - logger.Errorf("error sending data to server %v body: %v", server, err) - continue - } - } -} From 926e7b5555762d8993d624b3691ed271e1d1da3f Mon Sep 17 00:00:00 2001 From: Moshe Immerman Date: Wed, 20 Dec 2023 18:29:52 +0200 Subject: [PATCH 2/6] chore: switch to new shared job model --- cmd/root.go | 13 +- cmd/serve.go | 1 - go.mod | 4 +- go.sum | 12 +- pkg/db/canary.go | 46 +----- pkg/db/check_statuses.go | 268 ++++++++++--------------------- pkg/db/init.go | 4 - pkg/jobs/canary/sync_upstream.go | 109 ++++++------- pkg/jobs/jobs.go | 43 ++--- 9 files changed, 163 insertions(+), 337 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index 5abd9e666..28e0f4881 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -47,12 +47,11 @@ var Root = &cobra.Command{ } var ( - httpPort = 8080 - publicEndpoint = "http://localhost:8080" - pushServers, pullServers []string - sharedLibrary []string - exposeEnv bool - logPass, logFail bool + httpPort = 8080 + publicEndpoint = "http://localhost:8080" + sharedLibrary []string + exposeEnv bool + logPass, logFail bool otelcollectorURL string otelServiceName string @@ -81,7 +80,7 @@ func ServerFlags(flags *pflag.FlagSet) { flags.StringVar(&db.ConnectionString, "db", "DB_URL", "Connection string for the postgres database. Use embedded:///path/to/dir to use the embedded database") flags.IntVar(&db.DefaultExpiryDays, "cache-timeout", 90, "Cache timeout in days") flags.StringVarP(&cache.DefaultWindow, "default-window", "", "1h", "Default search window") - flags.IntVar(&db.CheckStatusRetentionDays, "check-status-retention-period", db.DefaultCheckStatusRetentionDays, "Check status retention period in days") + flags.IntVar(&db.CheckStatusRetention, "check-status-retention-period", db.CheckStatusRetention, "Check status retention period in days") flags.IntVar(&db.CheckRetentionDays, "check-retention-period", db.DefaultCheckRetentionDays, "Check retention period in days") flags.IntVar(&db.CanaryRetentionDays, "canary-retention-period", db.DefaultCanaryRetentionDays, "Canary retention period in days") flags.StringVar(&checks.DefaultArtifactConnection, "artifact-connection", "", "Specify the default connection to use for artifacts") diff --git a/cmd/serve.go b/cmd/serve.go index 7b8aa0e10..fe8875ed5 100644 --- a/cmd/serve.go +++ b/cmd/serve.go @@ -76,7 +76,6 @@ func setup() { if err := duty.UpdatePropertiesFromFile(apicontext.DefaultContext, propertiesFile); err != nil { logger.Fatalf("Error setting properties in database: %v", err) } - } func postgrestResponseModifier(r *http.Response) error { diff --git a/go.mod b/go.mod index cc569225a..78a1e5fe4 100644 --- a/go.mod +++ b/go.mod @@ -22,7 +22,7 @@ require ( github.com/fergusstrange/embedded-postgres v1.24.0 github.com/flanksource/artifacts v1.0.0 github.com/flanksource/commons v1.19.2 - github.com/flanksource/duty v1.0.236 + github.com/flanksource/duty v1.0.245-0.20231220161640-a0c01f94c2ba github.com/flanksource/gomplate/v3 v3.20.26 github.com/flanksource/is-healthy v0.0.0-20231003215854-76c51e3a3ff7 github.com/flanksource/kommons v0.31.4 @@ -51,7 +51,6 @@ require ( github.com/opensearch-project/opensearch-go/v2 v2.3.0 github.com/orcaman/concurrent-map v1.0.0 github.com/patrickmn/go-cache v2.1.0+incompatible - github.com/phf/go-queue v0.0.0-20170504031614-9abe38d0371d github.com/pkg/errors v0.9.1 github.com/prometheus-community/pro-bing v0.3.0 github.com/prometheus/alertmanager v0.26.0 @@ -94,6 +93,7 @@ require ( github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358 // indirect github.com/Masterminds/goutils v1.1.1 // indirect github.com/Masterminds/semver/v3 v3.2.1 // indirect + github.com/RaveNoX/go-jsonmerge v1.0.0 // indirect github.com/TomOnTime/utfutil v0.0.0-20230223141146-125e65197b36 // indirect github.com/agext/levenshtein v1.2.3 // indirect github.com/antlr4-go/antlr/v4 v4.13.0 // indirect diff --git a/go.sum b/go.sum index 80d04cc34..5496bb8e1 100644 --- a/go.sum +++ b/go.sum @@ -629,6 +629,9 @@ github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb0 github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= +github.com/RaveNoX/go-jsoncommentstrip v1.0.0/go.mod h1:78ihd09MekBnJnxpICcwzCMzGrKSKYe4AqU6PDYYpjk= +github.com/RaveNoX/go-jsonmerge v1.0.0 h1:2e0nqnadoGUP8rAvcA0hkQelZreVO5X3BHomT2XMrAk= +github.com/RaveNoX/go-jsonmerge v1.0.0/go.mod h1:qYM/NA77LhO4h51JJM7Z+xBU3ovqrNIACZe+SkSNVFo= github.com/TomOnTime/utfutil v0.0.0-20230223141146-125e65197b36 h1:vfVc5pSCq58ljNpXXwUcLnHATYi/x+YUdqFc9uBhLbM= github.com/TomOnTime/utfutil v0.0.0-20230223141146-125e65197b36/go.mod h1:MwE/QxFCN65F0hKGWFHUh2U2o1p2tMPNR1zHkX6vEh8= github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= @@ -736,6 +739,7 @@ github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d h1:xDfNPAt8lFiC1UJrqV3uuy861HCTo708pDMbjHHdCas= github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ00z/TKoufEY6K/a0k6AhaJrQKdFe6OfVXsa4= +github.com/bmatcuk/doublestar v1.1.1/go.mod h1:UD6OnuiIn0yFxxA2le/rnRU1G4RaI4UvFv1sNto9p6w= github.com/boombuler/barcode v1.0.0/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8= github.com/boombuler/barcode v1.0.1/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8= github.com/c2h5oh/datasize v0.0.0-20220606134207-859f65c6625b h1:6+ZFm0flnudZzdSE0JxlhR2hKnGPcNB35BjQf4RYQDY= @@ -821,8 +825,8 @@ github.com/flanksource/artifacts v1.0.0 h1:Fer3firlsI1L0YoOoUOw77w7j4PgtMkNTsQDY github.com/flanksource/artifacts v1.0.0/go.mod h1:KWGcGNGTJe+wb/Pv31thiWsNSdhu7iWqRO/hApLflyA= github.com/flanksource/commons v1.19.2 h1:6JAnKzBBk5iUROrR79dm7Bzbg9beAiFTehkTeZyI2/g= github.com/flanksource/commons v1.19.2/go.mod h1:k+3B7McXUOS+TirYFR9h0pPk6mHNG3dqVUEY9gKI3/U= -github.com/flanksource/duty v1.0.236 h1:7+X0T9JFgM9U1cnd63jVLuxhpWsmQKpd+KQxWeuC8fI= -github.com/flanksource/duty v1.0.236/go.mod h1:6JdeVPo9aKq/nowsP60CTHQxe+oUPu6maMbusIApB8o= +github.com/flanksource/duty v1.0.245-0.20231220161640-a0c01f94c2ba h1:4593zVyJ/Si1tXUiAtkNUoDgorTwVAeVS1CGwf6f4hA= +github.com/flanksource/duty v1.0.245-0.20231220161640-a0c01f94c2ba/go.mod h1:tT+MmnSlSJMeBrFGzWDES/vKOW26g+y3i907/IJrd1s= github.com/flanksource/gomplate/v3 v3.20.4/go.mod h1:27BNWhzzSjDed1z8YShO6W+z6G9oZXuxfNFGd/iGSdc= github.com/flanksource/gomplate/v3 v3.20.26 h1:85lUzlKgZjb1uIkzoa4zN03OcdOnFPG+oWxshZTYqz4= github.com/flanksource/gomplate/v3 v3.20.26/go.mod h1:GKmptFMdr2LbOuqwQZrmo9a/UygyZ0pbXffks8MuYhE= @@ -1195,6 +1199,7 @@ github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1 github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/jszwec/csvutil v1.8.0 h1:G7vS2LGdpZZDH1HmHeNbxOaJ/ZnJlpwGFvOkTkJzzNk= github.com/jszwec/csvutil v1.8.0/go.mod h1:/E4ONrmGkwmWsk9ae9jpXnv9QT8pLHEPcCirMFhxG9I= +github.com/juju/gnuflag v0.0.0-20171113085948-2ce1bb71843d/go.mod h1:2PavIy+JPciBPrBUjwbNvtwB6RQlve+hkpll6QSNmOE= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= github.com/jung-kurt/gofpdf v1.0.0/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes= @@ -1353,8 +1358,6 @@ github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTK github.com/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAvS1LBMMhTE= github.com/peterbourgon/diskv v2.0.1+incompatible h1:UBdAOUP5p4RWqPBg048CAvpKN+vxiaj6gdUUzhl4XmI= github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= -github.com/phf/go-queue v0.0.0-20170504031614-9abe38d0371d h1:U+PMnTlV2tu7RuMK5etusZG3Cf+rpow5hqQByeCzJ2g= -github.com/phf/go-queue v0.0.0-20170504031614-9abe38d0371d/go.mod h1:lXfE4PvvTW5xOjO6Mba8zDPyw8M93B6AQ7frTGnMlA8= github.com/phpdave11/gofpdf v1.4.2/go.mod h1:zpO6xFn9yxo3YLyMvW8HcKWVdbNqgIfOOp2dXMnm1mY= github.com/phpdave11/gofpdi v1.0.12/go.mod h1:vBmVV0Do6hSBHC8uKUQ71JGW+ZGQq74llk/7bXwjDoI= github.com/phpdave11/gofpdi v1.0.13/go.mod h1:vBmVV0Do6hSBHC8uKUQ71JGW+ZGQq74llk/7bXwjDoI= @@ -1455,6 +1458,7 @@ github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyh github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/spkg/bom v0.0.0-20160624110644-59b7046e48ad/go.mod h1:qLr4V1qq6nMqFKkMo8ZTx3f+BZEkzsRUY10Xsm2mwU0= github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8= github.com/stoewer/go-strcase v1.3.0 h1:g0eASXYtp+yvN9fK8sH94oCIk0fau9uV1/ZdJ0AVEzs= github.com/stoewer/go-strcase v1.3.0/go.mod h1:fAH5hQ5pehh+j3nZfvwdk2RgEgQjAoM8wodgtPmh1xo= diff --git a/pkg/db/canary.go b/pkg/db/canary.go index b2f91f925..4960bab43 100644 --- a/pkg/db/canary.go +++ b/pkg/db/canary.go @@ -4,7 +4,6 @@ import ( "encoding/json" "errors" "fmt" - "sync" "time" @@ -16,7 +15,6 @@ import ( "github.com/flanksource/commons/logger" "github.com/flanksource/duty/context" "github.com/flanksource/duty/models" - "github.com/flanksource/duty/query" dutyTypes "github.com/flanksource/duty/types" "github.com/google/uuid" "github.com/jackc/pgx/v5" @@ -428,40 +426,6 @@ func PersistCanary(canary v1.Canary, source string) (*pkg.Canary, error) { return PersistCanaryModel(model) } -var refreshCheckStatusSummaryMutex sync.Mutex - -func RefreshCheckStatusSummary() { - if !refreshCheckStatusSummaryMutex.TryLock() { - logger.Debugf("Skipping RefreshCheckStatusSummary as it is already running") - return - } - - jobHistory := models.NewJobHistory("RefreshCheckStatusSummary", "check_status_summary", "").Start() - _ = PersistJobHistory(jobHistory) - defer func() { - _ = PersistJobHistory(jobHistory.End()) - refreshCheckStatusSummaryMutex.Unlock() - }() - - if err := query.RefreshCheckStatusSummary(defaultCtx); err != nil { - logger.Errorf("error refreshing check_status_summary materialized view: %v", err) - jobHistory.AddError(err.Error()) - } -} - -func RefreshCheckStatusSummaryAged() { - jobHistory := models.NewJobHistory("RefreshCheckStatusSummaryAged", "check_status_summary_aged", "").Start() - _ = PersistJobHistory(jobHistory) - defer func() { - _ = PersistJobHistory(jobHistory.End()) - }() - - if err := query.RefreshCheckStatusSummaryAged(defaultCtx); err != nil { - logger.Errorf("error refreshing check_status_summary_aged materialized view: %v", err) - jobHistory.AddError(err.Error()) - } -} - const ( DefaultCheckRetentionDays = 7 DefaultCanaryRetentionDays = 7 @@ -524,9 +488,9 @@ func CleanupCanaries() { // SuspendCanary sets the suspend annotation on the canary table. func SuspendCanary(ctx context.Context, id string, suspend bool) error { query := ` - UPDATE canaries - SET annotations = - CASE + UPDATE canaries + SET annotations = + CASE WHEN annotations IS NULL THEN '{"suspend": "true"}'::jsonb ELSE jsonb_set(annotations, '{suspend}', '"true"') END @@ -535,8 +499,8 @@ func SuspendCanary(ctx context.Context, id string, suspend bool) error { if !suspend { query = ` - UPDATE canaries - SET annotations = + UPDATE canaries + SET annotations = CASE WHEN annotations IS NOT NULL THEN annotations - 'suspend' END WHERE id = ?; ` diff --git a/pkg/db/check_statuses.go b/pkg/db/check_statuses.go index 12c715a43..186adcfc9 100644 --- a/pkg/db/check_statuses.go +++ b/pkg/db/check_statuses.go @@ -1,208 +1,104 @@ package db import ( - "database/sql" - "errors" - "fmt" + "time" - "github.com/flanksource/commons/logger" - "github.com/flanksource/duty/models" - "gorm.io/gorm/clause" + "github.com/flanksource/duty/job" ) -const ( - DefaultCheckStatusRetentionDays = 60 - RetentionDaysFor1hCheckStatusAggregate = 180 - RetentionDaysFor1dCheckStatusAggregate = 1000 - - checkStatusAggDuration1h = "1hour" - checkStatusAggDuration1d = "1day" +var ( + CheckStatusRetention = 60 ) -var CheckStatusRetentionDays int - -// DeleteAllOldCheckStatuses deletes check statuses older than the configured retention period -// from 3 different tables. -func DeleteAllOldCheckStatuses() { - deleteOldCheckStatuses() - deleteOld1hAggregatedCheckStatuses() - deleteOld1dAggregatedCheckStatuses() +const CheckStatuses = "check_statuses" + +var RefreshCheckStatusSummary = job.Job{ + Name: "RefreshCheckStatusSummary", + Singleton: true, + Timeout: 1 * time.Minute, + JobHistory: true, + Fn: func(ctx job.JobRuntime) error { + ctx.History.ResourceType = CheckStatuses + return job.RefreshCheckStatusSummary(ctx.Context) + }, } -func deleteOldCheckStatuses() { - jobHistory := models.NewJobHistory("DeleteOldCheckStatuses", "", "").Start() - _ = PersistJobHistory(jobHistory) - - if CheckStatusRetentionDays <= 0 { - CheckStatusRetentionDays = DefaultCheckStatusRetentionDays - } - err := Gorm.Exec(` - DELETE FROM check_statuses - WHERE (NOW() - created_at) > INTERVAL '1 day' * ? - `, CheckStatusRetentionDays).Error - - if err != nil { - logger.Errorf("Error deleting old check statuses: %v", err) - jobHistory.AddError(err.Error()) - } else { - jobHistory.IncrSuccess() - } - _ = PersistJobHistory(jobHistory.End()) +var RefreshCheckStatusSummaryAged = job.Job{ + Name: "RefreshCheckStatusSummaryAged", + Timeout: 60 * time.Minute, + Singleton: true, + JobHistory: true, + Fn: func(ctx job.JobRuntime) error { + ctx.History.ResourceType = CheckStatuses + return job.RefreshCheckStatusSummaryAged(ctx.Context) + }, } -// deleteOld1dAggregatedCheckStatuses maintains retention period of old 1day aggregate check statuses. -func deleteOld1dAggregatedCheckStatuses() { - jobHistory := models.NewJobHistory("DeleteOld1dAggregatedCheckStatuses", "", "").Start() - if err := PersistJobHistory(jobHistory); err != nil { - logger.Errorf("error persisting job history: %v", err) - } - defer func() { - if err := PersistJobHistory(jobHistory.End()); err != nil { - logger.Errorf("error persisting end of job: %v", err) - } - }() - - const query = `DELETE FROM check_statuses_1d WHERE (NOW() - created_at) > INTERVAL '1 day' * ?` - tx := Gorm.Exec(query, RetentionDaysFor1dCheckStatusAggregate) - if tx.Error != nil { - logger.Errorf("error deleting old aggregated check statuses: %v", tx.Error) - jobHistory.AddError(tx.Error.Error()) - return - } - - logger.Infof("Successfully deleted %v entries", tx.RowsAffected) - jobHistory.IncrSuccess() +var DeleteOldCheckStatues = job.Job{ + Name: "DeleteOldCheckStatuses", + Singleton: true, + Schedule: "@every 24h", + Fn: func(ctx job.JobRuntime) error { + ctx.History.ResourceType = CheckStatuses + err, count := job.DeleteOldCheckStatuses1h(ctx.Context, CheckStatusRetention*3) + ctx.History.SuccessCount = count + return err + }, } -// deleteOld1hAggregatedCheckStatuses maintains retention period of old 1hour aggregated check statuses. -func deleteOld1hAggregatedCheckStatuses() { - jobHistory := models.NewJobHistory("DeleteOld1hAggregatedCheckStatuses", "", "").Start() - if err := PersistJobHistory(jobHistory); err != nil { - logger.Errorf("error persisting job history: %v", err) - } - defer func() { - if err := PersistJobHistory(jobHistory.End()); err != nil { - logger.Errorf("error persisting end of job: %v", err) - } - }() - - const query = `DELETE FROM check_statuses_1h WHERE (NOW() - created_at) > INTERVAL '1 day' * ?` - tx := Gorm.Exec(query, RetentionDaysFor1hCheckStatusAggregate) - if tx.Error != nil { - logger.Errorf("error deleting old aggregated check statuses: %v", tx.Error) - jobHistory.AddError(tx.Error.Error()) - return - } - - logger.Infof("Successfully deleted %v entries", tx.RowsAffected) - jobHistory.IncrSuccess() +var DeleteOldCheckStatues1d = job.Job{ + Name: "DeleteOldCheckStatuses1d", + Singleton: true, + Schedule: "@every 24h", + Fn: func(ctx job.JobRuntime) error { + ctx.History.ResourceType = CheckStatuses + err, count := job.DeleteOldCheckStatuses1d(ctx.Context, CheckStatusRetention*9) + ctx.History.SuccessCount = count + return err + }, } -// AggregateCheckStatuses aggregates check statuses hourly -// and stores it to the corresponding tables. -func AggregateCheckStatuses1h() { - jobHistory := models.NewJobHistory("AggregateCheckStatuses1h", "", "").Start() - if err := PersistJobHistory(jobHistory); err != nil { - logger.Errorf("error persisting job history: %v", err) - } - defer func() { - if err := PersistJobHistory(jobHistory.End()); err != nil { - logger.Errorf("error persisting end of job: %v", err) - } - }() - - if err := aggregateCheckStatuses(checkStatusAggDuration1h); err != nil { - logger.Errorf("error aggregating check statuses 1h: %v", err) - jobHistory.AddError(err.Error()) - } else { - jobHistory.IncrSuccess() - } +var DeleteOldCheckStatues1h = job.Job{ + Name: "DeleteOldCheckStatuses1h", + Singleton: true, + + Schedule: "@every 24h", + Fn: func(ctx job.JobRuntime) error { + ctx.History.ResourceType = CheckStatuses + err, count := job.DeleteOldCheckStatuses1h(ctx.Context, CheckStatusRetention*3) + ctx.History.SuccessCount = count + return err + }, } -// AggregateCheckStatuses aggregates check statuses daily -// and stores it to the corresponding tables. -func AggregateCheckStatuses1d() { - jobHistory := models.NewJobHistory("AggregateCheckStatuses1d", "", "").Start() - if err := PersistJobHistory(jobHistory); err != nil { - logger.Errorf("error persisting job history: %v", err) - } - defer func() { - if err := PersistJobHistory(jobHistory.End()); err != nil { - logger.Errorf("error persisting end of job: %v", err) - } - }() - - if err := aggregateCheckStatuses(checkStatusAggDuration1d); err != nil { - logger.Errorf("error aggregating check statuses 1d: %v", err) - jobHistory.AddError(err.Error()) - } else { - jobHistory.IncrSuccess() - } +var AggregateCheckStatues1d = job.Job{ + Name: "AggregateCheckStatuses1h", + Schedule: "@every 1h", + Fn: func(ctx job.JobRuntime) error { + ctx.History.ResourceType = CheckStatuses + err, count := job.AggregateCheckStatus1h(ctx.Context) + ctx.History.SuccessCount = count + return err + }, } -func aggregateCheckStatuses(aggregateDurationType string) error { - const query = ` - SELECT - check_statuses.check_id, - date_trunc(?, "time"), - count(*) AS total_checks, - count(*) FILTER (WHERE check_statuses.status = TRUE) AS passed, - count(*) FILTER (WHERE check_statuses.status = FALSE) AS failed, - SUM(duration) AS duration - FROM check_statuses - LEFT JOIN checks ON check_statuses.check_id = checks.id - WHERE checks.created_at > NOW() - INTERVAL '1 hour' * ? - GROUP BY 1, 2 - ORDER BY 1, 2 DESC` - - var rows *sql.Rows - var err error - switch aggregateDurationType { - case checkStatusAggDuration1h: - rows, err = Gorm.Raw(query, "hour", 3).Rows() // Only look for aggregated data in the last 3 hour - if err != nil { - return fmt.Errorf("error aggregating check statuses 1h: %w", err) - } else if rows.Err() != nil { - return fmt.Errorf("error aggregating check statuses 1h: %w", rows.Err()) - } - defer rows.Close() - - for rows.Next() { - var aggr models.CheckStatusAggregate1h - if err := rows.Scan(&aggr.CheckID, &aggr.CreatedAt, &aggr.Total, &aggr.Passed, &aggr.Failed, &aggr.Duration); err != nil { - return fmt.Errorf("error scanning aggregated check statuses: %w", err) - } - - cols := []clause.Column{{Name: "check_id"}, {Name: "created_at"}} - if err := Gorm.Clauses(clause.OnConflict{Columns: cols, UpdateAll: true}).Create(aggr).Error; err != nil { - return fmt.Errorf("error upserting canaries: %w", err) - } - } - - case checkStatusAggDuration1d: - rows, err = Gorm.Raw(query, "day", 3*24).Rows() // Only look for aggregated data in the last 3 days - if err != nil { - return fmt.Errorf("error aggregating check statuses 1h: %w", err) - } else if rows.Err() != nil { - return fmt.Errorf("error aggregating check statuses 1h: %w", rows.Err()) - } - defer rows.Close() - - for rows.Next() { - var aggr models.CheckStatusAggregate1d - if err := rows.Scan(&aggr.CheckID, &aggr.CreatedAt, &aggr.Total, &aggr.Passed, &aggr.Failed, &aggr.Duration); err != nil { - return fmt.Errorf("error scanning aggregated check statuses: %w", err) - } - - cols := []clause.Column{{Name: "check_id"}, {Name: "created_at"}} - if err := Gorm.Clauses(clause.OnConflict{Columns: cols, UpdateAll: true}).Create(aggr).Error; err != nil { - return fmt.Errorf("error upserting canaries: %w", err) - } - } - - default: - return errors.New("unknown duration for aggregation") - } +var AggregateCheckStatues1h = job.Job{ + Name: "AggregateCheckStatuses1d", + Schedule: "@every 24h", + Fn: func(ctx job.JobRuntime) error { + ctx.History.ResourceType = CheckStatuses + err, count := job.AggregateCheckStatus1d(ctx.Context) + ctx.History.SuccessCount = count + return err + }, +} - return nil +var CheckStatusJobs = []job.Job{ + AggregateCheckStatues1d, + AggregateCheckStatues1h, + DeleteOldCheckStatues, + DeleteOldCheckStatues1h, + DeleteOldCheckStatues1d, + RefreshCheckStatusSummary, + RefreshCheckStatusSummaryAged, } diff --git a/pkg/db/init.go b/pkg/db/init.go index 0d0249891..cb96d75fd 100644 --- a/pkg/db/init.go +++ b/pkg/db/init.go @@ -11,7 +11,6 @@ import ( embeddedpostgres "github.com/fergusstrange/embedded-postgres" "github.com/flanksource/commons/logger" "github.com/flanksource/duty" - dutyContext "github.com/flanksource/duty/context" "github.com/flanksource/duty/migrate" "github.com/jackc/pgx/v5/pgxpool" "gorm.io/gorm" @@ -26,7 +25,6 @@ var RunMigrations bool var DBMetrics bool var PostgresServer *embeddedpostgres.EmbeddedPostgres var HTTPEndpoint = "http://localhost:8080/db" -var defaultCtx dutyContext.Context func Start(ctx context.Context) error { if err := Init(); err != nil { @@ -104,8 +102,6 @@ func Init() error { return err } - defaultCtx = dutyContext.Context{}.WithDB(Gorm, Pool) - if DBMetrics { go func() { if err := Gorm.Use(prometheus.New(prometheus.Config{ diff --git a/pkg/jobs/canary/sync_upstream.go b/pkg/jobs/canary/sync_upstream.go index 3464543b2..91c05101d 100644 --- a/pkg/jobs/canary/sync_upstream.go +++ b/pkg/jobs/canary/sync_upstream.go @@ -8,7 +8,7 @@ import ( "github.com/flanksource/canary-checker/api/context" "github.com/flanksource/canary-checker/pkg/db" "github.com/flanksource/commons/logger" - dutyContext "github.com/flanksource/duty/context" + "github.com/flanksource/duty/job" "github.com/flanksource/duty/models" "github.com/flanksource/duty/upstream" "github.com/flanksource/postq/pg" @@ -30,38 +30,40 @@ const ( eventQueueUpdateChannel = "event_queue_updates" ) -// ReconcileChecks coordinates with upstream and pushes any resource -// that are missing on the upstream. -func ReconcileChecks() { - jobHistory := models.NewJobHistory("PushChecksToUpstream", "Canary", "") - - _ = db.PersistJobHistory(jobHistory.Start()) - defer func() { _ = db.PersistJobHistory(jobHistory.End()) }() - - reconciler := upstream.NewUpstreamReconciler(UpstreamConf, 5) - if err := reconciler.SyncAfter(context.DefaultContext, "checks", ReconcileMaxAge); err != nil { - jobHistory.AddError(err.Error()) - logger.Errorf("failed to sync table 'checks': %v", err) - } else { - jobHistory.IncrSuccess() - } +var ReconcileChecks = job.Job{ + Name: "PushChecksToUpstream", + JobHistory: true, + Singleton: true, + Schedule: "@every 30m", + Fn: func(ctx job.JobRuntime) error { + reconciler := upstream.NewUpstreamReconciler(UpstreamConf, 5) + return reconciler.SyncAfter(ctx.Context, "checks", ReconcileMaxAge) + }, } -func SyncCheckStatuses() { - logger.Debugf("running check statuses sync job") - - jobHistory := models.NewJobHistory("SyncCheckStatusesWithUpstream", UpstreamConf.Host, "") - _ = db.PersistJobHistory(jobHistory.Start()) - defer func() { _ = db.PersistJobHistory(jobHistory.End()) }() - - ctx := dutyContext.NewContext(gocontext.TODO()).WithDB(db.Gorm, db.Pool) - if err := upstream.SyncCheckStatuses(ctx, UpstreamConf, ReconcilePageSize); err != nil { - logger.Errorf("failed to run checkstatus sync job: %v", err) - jobHistory.AddError(err.Error()) - return - } +var SyncCheckStatuses = job.Job{ + Name: "SyncCheckStatusesWithUpstream", + JobHistory: true, + Singleton: true, + Schedule: "@every 1m", + Fn: func(ctx job.JobRuntime) error { + err, count := upstream.SyncCheckStatuses(ctx.Context, UpstreamConf, ReconcilePageSize) + ctx.History.SuccessCount = count + return err + }, +} - jobHistory.IncrSuccess() +var lastRuntime time.Time +var PullUpstreamCanaries = job.Job{ + Name: "PullUpstreamCanaries", + JobHistory: true, + Singleton: true, + Schedule: "@every 10m", + Fn: func(ctx job.JobRuntime) error { + count, err := pull(ctx, UpstreamConf) + ctx.History.SuccessCount = count + return err + }, } type CanaryPullResponse struct { @@ -69,59 +71,44 @@ type CanaryPullResponse struct { Canaries []models.Canary `json:"canaries,omitempty"` } -// UpstreamPullJob pulls canaries from the upstream -type UpstreamPullJob struct { - lastRuntime time.Time +func pull(ctx gocontext.Context, config upstream.UpstreamConfig) (int, error) { + logger.Tracef("pulling canaries from upstream since: %v", lastRuntime) - Client *upstream.UpstreamClient -} - -func (t *UpstreamPullJob) Run() { - jobHistory := models.NewJobHistory("PullUpstreamCanaries", "Canary", "") - _ = db.PersistJobHistory(jobHistory.Start()) - defer func() { _ = db.PersistJobHistory(jobHistory.End()) }() - - if err := t.pull(gocontext.TODO(), UpstreamConf); err != nil { - jobHistory.AddError(err.Error()) - logger.Errorf("error pulling from upstream: %v", err) - } else { - jobHistory.IncrSuccess() - } -} - -func (t *UpstreamPullJob) pull(ctx gocontext.Context, config upstream.UpstreamConfig) error { - logger.Tracef("pulling canaries from upstream since: %v", t.lastRuntime) - - req := t.Client.Client.R(ctx).QueryParam("since", t.lastRuntime.Format(time.RFC3339)) + client := upstream.NewUpstreamClient(config) + req := client.Client.R(ctx).QueryParam("since", lastRuntime.Format(time.RFC3339)) resp, err := req.Get(fmt.Sprintf("canary/pull/%s", config.AgentName)) if err != nil { - return fmt.Errorf("error making request: %w", err) + return 0, fmt.Errorf("error making request: %w", err) } defer resp.Body.Close() if !resp.IsOK() { - return fmt.Errorf("upstream responded with status: %s", resp.Status) + return 0, fmt.Errorf("upstream responded with status: %s", resp.Status) } var response CanaryPullResponse if err := resp.Into(&response); err != nil { - return fmt.Errorf("error decoding response: %w", err) + return 0, fmt.Errorf("error decoding response: %w", err) } - t.lastRuntime = response.Before + lastRuntime = response.Before if len(response.Canaries) == 0 { - return nil + return 0, nil } - logger.Tracef("fetched %d canaries from upstream", len(response.Canaries)) - - return db.Gorm.Omit("agent_id").Clauses(clause.OnConflict{ + return len(response.Canaries), db.Gorm.Omit("agent_id").Clauses(clause.OnConflict{ Columns: []clause.Column{{Name: "id"}}, UpdateAll: true, }).Create(&response.Canaries).Error } +var UpstreamJobs = []job.Job{ + SyncCheckStatuses, + PullUpstreamCanaries, + ReconcileChecks, +} + func StartUpstreamEventQueueConsumer(ctx *context.Context) error { consumer, err := upstream.NewPushQueueConsumer(UpstreamConf).EventConsumer() if err != nil { diff --git a/pkg/jobs/jobs.go b/pkg/jobs/jobs.go index 3b9b51686..3590e34bc 100644 --- a/pkg/jobs/jobs.go +++ b/pkg/jobs/jobs.go @@ -12,7 +12,6 @@ import ( "github.com/flanksource/canary-checker/pkg/topology/configs" "github.com/flanksource/commons/logger" dutyjob "github.com/flanksource/duty/job" - "github.com/flanksource/duty/upstream" "github.com/robfig/cron/v3" ) @@ -30,10 +29,6 @@ const ( ComponentCheckSchedule = "@every 2m" ComponentConfigSchedule = "@every 2m" ComponentCostSchedule = "@every 1h" - CheckStatusSummarySchedule = "@every 1m" - CheckStatusesAggregate1hSchedule = "@every 1h" - CheckStatusesAggregate1dSchedule = "@every 24h" - CheckStatusDeleteSchedule = "@every 24h" CheckCleanupSchedule = "@every 12h" CanaryCleanupSchedule = "@every 12h" PrometheusGaugeCleanupSchedule = "@every 1h" @@ -49,29 +44,25 @@ func Start() { FuncScheduler.Start() if canaryJobs.UpstreamConf.Valid() { - pullJob := &canaryJobs.UpstreamPullJob{ - Client: upstream.NewUpstreamClient(canaryJobs.UpstreamConf), - } - pullJob.Run() - if _, err := FuncScheduler.AddJob(PullCanaryFromUpstreamSchedule, pullJob); err != nil { - logger.Fatalf("Failed to schedule job [canaryJobs.Pull]: %v", err) - } - // Push checks to upstream in real-time if err := canaryJobs.StartUpstreamEventQueueConsumer(context.New(nil, nil, db.Gorm, db.Pool, v1.Canary{})); err != nil { logger.Fatalf("Failed to start upstream event queue consumer: %v", err) } - if _, err := ScheduleFunc(ReconcileCanaryToUpstreamSchedule, canaryJobs.ReconcileChecks); err != nil { - logger.Fatalf("Failed to schedule job [canaryJobs.ReconcileChecks]: %v", err) + for _, job := range canaryJobs.UpstreamJobs { + job.Context = context.DefaultContext + if err := job.AddToScheduler(FuncScheduler); err != nil { + logger.Errorf(err.Error()) + } } + } - canaryJobs.SyncCheckStatuses() - if _, err := ScheduleFunc(PushCheckStatusesSchedule, canaryJobs.SyncCheckStatuses); err != nil { - logger.Fatalf("Failed to schedule job [canaryJobs.SyncCheckStatuses]: %v", err) + for _, job := range db.CheckStatusJobs { + job.Context = context.DefaultContext + if err := job.AddToScheduler(FuncScheduler); err != nil { + logger.Errorf(err.Error()) } } - if err := dutyjob.NewJob(context.DefaultContext, "SyncCanaryJobs", SyncCanaryJobsSchedule, canaryJobs.SyncCanaryJobs). RunOnStart().AddToScheduler(FuncScheduler); err != nil { logger.Fatalf("Failed to schedule job [canaryJobs.SyncCanaryJobs]: %v", err) @@ -92,21 +83,11 @@ func Start() { if _, err := ScheduleFunc(ComponentCheckSchedule, checks.ComponentCheckRun); err != nil { logger.Errorf("Failed to schedule component check: %v", err) } + if _, err := ScheduleFunc(ComponentConfigSchedule, configs.ComponentConfigRun); err != nil { logger.Errorf("Failed to schedule component config: %v", err) } - if _, err := ScheduleFunc(CheckStatusSummarySchedule, db.RefreshCheckStatusSummary); err != nil { - logger.Errorf("Failed to schedule check status summary refresh: %v", err) - } - if _, err := ScheduleFunc(CheckStatusesAggregate1hSchedule, db.RefreshCheckStatusSummaryAged); err != nil { - logger.Errorf("Failed to schedule check status summary refresh: %v", err) - } - if _, err := ScheduleFunc(CheckStatusDeleteSchedule, db.DeleteAllOldCheckStatuses); err != nil { - logger.Errorf("Failed to schedule check status deleter: %v", err) - } - if _, err := ScheduleFunc(CheckStatusesAggregate1dSchedule, db.AggregateCheckStatuses1d); err != nil { - logger.Errorf("Failed to schedule check statuses aggregator 1d: %v", err) - } + if _, err := ScheduleFunc(PrometheusGaugeCleanupSchedule, canaryJobs.CleanupMetricsGauges); err != nil { logger.Errorf("Failed to schedule prometheus gauge cleanup job: %v", err) } From aae663f59557149ebf9451fef44089248cad49cc Mon Sep 17 00:00:00 2001 From: Moshe Immerman Date: Wed, 20 Dec 2023 21:34:20 +0200 Subject: [PATCH 3/6] fix: remove time window heuristics --- checks/azure_devops_test.go | 12 +- cmd/serve.go | 1 - go.mod | 3 +- go.sum | 21 +++- pkg/api.go | 31 ++--- pkg/api/api.go | 53 +++----- pkg/cache/cache.go | 6 +- pkg/cache/postgres.go | 12 +- pkg/cache/postgres_query.go | 203 ++++--------------------------- pkg/cache/postgres_query_test.go | 101 --------------- pkg/cache/postgres_util.go | 56 --------- pkg/topology/run_test.go | 8 +- 12 files changed, 94 insertions(+), 413 deletions(-) delete mode 100644 pkg/cache/postgres_query_test.go diff --git a/checks/azure_devops_test.go b/checks/azure_devops_test.go index 5cac97876..bc6a6eac4 100644 --- a/checks/azure_devops_test.go +++ b/checks/azure_devops_test.go @@ -3,8 +3,8 @@ package checks import ( "testing" - "github.com/flanksource/canary-checker/pkg/utils" "github.com/microsoft/azure-devops-go-api/azuredevops/v7/pipelines" + "github.com/samber/lo" ) func TestMatchPipelineVariables(t *testing.T) { @@ -27,8 +27,8 @@ func TestMatchPipelineVariables(t *testing.T) { "key2": "value2", }, got: &map[string]pipelines.Variable{ - "key1": {Value: utils.Ptr("value1")}, - "key2": {Value: utils.Ptr("value2")}, + "key1": {Value: lo.ToPtr("value1")}, + "key2": {Value: lo.ToPtr("value2")}, }, wantResult: true, }, @@ -39,7 +39,7 @@ func TestMatchPipelineVariables(t *testing.T) { "key2": "value2", }, got: &map[string]pipelines.Variable{ - "key1": {Value: utils.Ptr("value1")}, + "key1": {Value: lo.ToPtr("value1")}, }, wantResult: false, }, @@ -50,8 +50,8 @@ func TestMatchPipelineVariables(t *testing.T) { "key2": "value2", }, got: &map[string]pipelines.Variable{ - "key1": {Value: utils.Ptr("value1")}, - "key2": {Value: utils.Ptr("value3")}, + "key1": {Value: lo.ToPtr("value1")}, + "key2": {Value: lo.ToPtr("value3")}, }, wantResult: false, }, diff --git a/cmd/serve.go b/cmd/serve.go index fe8875ed5..81d8a0eb1 100644 --- a/cmd/serve.go +++ b/cmd/serve.go @@ -138,7 +138,6 @@ func serve() { } }) - e.GET("/api", api.CheckSummary) e.GET("/api/summary", api.HealthSummary) // Deprecated: Use Post request for filtering e.POST("/api/summary", api.HealthSummary) e.GET("/about", api.About) diff --git a/go.mod b/go.mod index 78a1e5fe4..e2ca1e240 100644 --- a/go.mod +++ b/go.mod @@ -22,7 +22,7 @@ require ( github.com/fergusstrange/embedded-postgres v1.24.0 github.com/flanksource/artifacts v1.0.0 github.com/flanksource/commons v1.19.2 - github.com/flanksource/duty v1.0.245-0.20231220161640-a0c01f94c2ba + github.com/flanksource/duty v1.0.245 github.com/flanksource/gomplate/v3 v3.20.26 github.com/flanksource/is-healthy v0.0.0-20231003215854-76c51e3a3ff7 github.com/flanksource/kommons v0.31.4 @@ -215,6 +215,7 @@ require ( github.com/prometheus/client_model v0.5.0 // indirect github.com/prometheus/procfs v0.12.0 // indirect github.com/rogpeppe/go-internal v1.11.0 // indirect + github.com/samber/lo v1.39.0 // indirect github.com/sergi/go-diff v1.3.1 // indirect github.com/sethvargo/go-retry v0.2.4 // indirect github.com/sirupsen/logrus v1.9.3 // indirect diff --git a/go.sum b/go.sum index 5496bb8e1..a9bb5a09a 100644 --- a/go.sum +++ b/go.sum @@ -614,6 +614,7 @@ github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0 h1:vcYCAze6p19qBW7MhZybI github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 h1:sXr+ck84g/ZlZUOZiNELInmMgOsuGwdjjVkEIde0OtY= github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azkeys v1.0.0 h1:yfJe15aSwEQ6Oo6J+gdfdulPNoZ3TEhmbhLIoxZcA+U= github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/internal v0.8.0 h1:T028gtTPiYt/RMUfs8nVsAL7FDQrfLlrm/NnRG/zcC4= +github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358 h1:mFRzDkZVAjdal+s7s0MwaRv9igoPqLRdzOLzw/8Xvq8= github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358/go.mod h1:chxPXzSsl7ZWRAuOIE23GDNzjWuZquvFlgA8xmpunjU= github.com/AzureAD/microsoft-authentication-library-for-go v1.1.0 h1:HCc0+LpPfpCKs6LGGLAhwBARt9632unrVcI6i8s/8os= @@ -626,6 +627,7 @@ github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy86 github.com/Masterminds/semver/v3 v3.2.1 h1:RN9w6+7QoMeJVGyfmbcgs28Br8cvmnucEXnY0rYXWg0= github.com/Masterminds/semver/v3 v3.2.1/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ= github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= +github.com/NYTimes/gziphandler v1.1.1/go.mod h1:n/CVRwUEOgIxrgPvAQhUUr9oeUtvrhMomdKFjzJNB0c= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= @@ -663,6 +665,8 @@ github.com/antonmedv/expr v1.15.5/go.mod h1:0E/6TxnOlRNp81GMzX9QfDPAmHo2Phg00y4J github.com/apache/arrow/go/v10 v10.0.1/go.mod h1:YvhnlEePVnBS4+0z3fhPfUy7W1Ikj0Ih0vcRo/gZ1M0= github.com/apache/arrow/go/v11 v11.0.0/go.mod h1:Eg5OsL5H+e299f7u5ssuXsuHQVEGC4xei5aX110hRiI= github.com/apache/thrift v0.16.0/go.mod h1:PHK3hniurgQaNMZYaCLEqXKsYK8upmhPbmdP2FXSqgU= +github.com/apparentlymart/go-dump v0.0.0-20180507223929-23540a00eaa3/go.mod h1:oL81AME2rN47vu18xqj1S1jPIPuN7afo62yKTNn3XMM= +github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo= github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew1u1fNQOlOtuGxQY= github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= @@ -739,6 +743,7 @@ github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d h1:xDfNPAt8lFiC1UJrqV3uuy861HCTo708pDMbjHHdCas= github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ00z/TKoufEY6K/a0k6AhaJrQKdFe6OfVXsa4= +github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ= github.com/bmatcuk/doublestar v1.1.1/go.mod h1:UD6OnuiIn0yFxxA2le/rnRU1G4RaI4UvFv1sNto9p6w= github.com/boombuler/barcode v1.0.0/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8= github.com/boombuler/barcode v1.0.1/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8= @@ -825,8 +830,8 @@ github.com/flanksource/artifacts v1.0.0 h1:Fer3firlsI1L0YoOoUOw77w7j4PgtMkNTsQDY github.com/flanksource/artifacts v1.0.0/go.mod h1:KWGcGNGTJe+wb/Pv31thiWsNSdhu7iWqRO/hApLflyA= github.com/flanksource/commons v1.19.2 h1:6JAnKzBBk5iUROrR79dm7Bzbg9beAiFTehkTeZyI2/g= github.com/flanksource/commons v1.19.2/go.mod h1:k+3B7McXUOS+TirYFR9h0pPk6mHNG3dqVUEY9gKI3/U= -github.com/flanksource/duty v1.0.245-0.20231220161640-a0c01f94c2ba h1:4593zVyJ/Si1tXUiAtkNUoDgorTwVAeVS1CGwf6f4hA= -github.com/flanksource/duty v1.0.245-0.20231220161640-a0c01f94c2ba/go.mod h1:tT+MmnSlSJMeBrFGzWDES/vKOW26g+y3i907/IJrd1s= +github.com/flanksource/duty v1.0.245 h1:tfyrbQ//WFxni6lFQKuYNbPgoPvzKOU/0fBh0pXCp2g= +github.com/flanksource/duty v1.0.245/go.mod h1:nhvoArC48DByxrRvvcCKwRfbAfn9wUbo4YWietT9t7I= github.com/flanksource/gomplate/v3 v3.20.4/go.mod h1:27BNWhzzSjDed1z8YShO6W+z6G9oZXuxfNFGd/iGSdc= github.com/flanksource/gomplate/v3 v3.20.26 h1:85lUzlKgZjb1uIkzoa4zN03OcdOnFPG+oWxshZTYqz4= github.com/flanksource/gomplate/v3 v3.20.26/go.mod h1:GKmptFMdr2LbOuqwQZrmo9a/UygyZ0pbXffks8MuYhE= @@ -942,6 +947,7 @@ github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg78 github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= +github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= github.com/gobuffalo/attrs v0.0.0-20190224210810-a9411de4debd/go.mod h1:4duuawTqi2wkkpB4ePgWMaai6/Kc6WEz83bhFwpHzj0= github.com/gobuffalo/depgen v0.0.0-20190329151759-d478694a28d3/go.mod h1:3STtPUQYuzV0gBVOY3vy6CfMm/ljR4pABfrTeHNLHUY= github.com/gobuffalo/depgen v0.1.0/go.mod h1:+ifsuy7fhi15RWncXQQKjWS9JPkdah5sZvtHc2RXGlg= @@ -1121,6 +1127,8 @@ github.com/gosimple/unidecode v1.0.1 h1:hZzFTMMqSswvf0LBJZCZgThIZrpDHFXux9KeGmn6 github.com/gosimple/unidecode v1.0.1/go.mod h1:CP0Cr1Y1kogOtx0bJblKzsVWrqYaqfNOnHzpgWw4Awc= github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 h1:+ngKgrYPPJrOjhax5N+uePQ0Fh1Z7PheYoUI/0nzkPA= github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= +github.com/grpc-ecosystem/go-grpc-middleware v1.3.0/go.mod h1:z0ButlSOZa5vEBq9m2m2hlwIgKw+rp3sdCBRoJY+30Y= +github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0/go.mod h1:hgWBS7lorOAVIJEQMi4ZsPv9hVvWI6+ch50m39Pf2Ks= github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3/go.mod h1:o//XUCC/F+yRGJoPO/VU0GSB0f8Nhgmxx0VIRUvaC0w= @@ -1130,10 +1138,12 @@ github.com/hairyhenderson/toml v0.4.2-0.20210923231440-40456b8e66cf h1:I1sbT4ZbI github.com/hairyhenderson/toml v0.4.2-0.20210923231440-40456b8e66cf/go.mod h1:jDHmWDKZY6MIIYltYYfW4Rs7hQ50oS4qf/6spSiZAxY= github.com/hairyhenderson/yaml v0.0.0-20220618171115-2d35fca545ce h1:cVkYhlWAxwuS2/Yp6qPtcl0fGpcWxuZNonywHZ6/I+s= github.com/hairyhenderson/yaml v0.0.0-20220618171115-2d35fca545ce/go.mod h1:7TyiGlHI+IO+iJbqRZ82QbFtvgj/AIcFm5qc9DLn7Kc= +github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= github.com/hashicorp/go-getter v1.7.3 h1:bN2+Fw9XPFvOCjB0UOevFIMICZ7G2XSQHzfvLUyOM5E= github.com/hashicorp/go-getter v1.7.3/go.mod h1:W7TalhMmbPmsSMdNjD0ZskARur/9GJ17cfHTRtXV744= +github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= github.com/hashicorp/go-safetemp v1.0.0 h1:2HR189eFNrjHQyENnQMMpCiBAsRxzbTMIgBhEyExpmo= github.com/hashicorp/go-safetemp v1.0.0/go.mod h1:oaerMy3BhqiTbVye6QuFhFtIceqFoDHxNAB65b+Rj1I= github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek= @@ -1183,6 +1193,7 @@ github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHW github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8= github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= +github.com/jonboulle/clockwork v0.2.2/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/joshdk/go-junit v1.0.0 h1:S86cUKIdwBHWwA6xCmFlf3RTLfVXYQfvanM5Uh+K6GE= @@ -1434,6 +1445,9 @@ github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUz github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ruudk/golang-pdf417 v0.0.0-20181029194003-1af4ab5afa58/go.mod h1:6lfFZQK844Gfx8o5WFuvpxWRwnSoipWe/p622j1v06w= github.com/ruudk/golang-pdf417 v0.0.0-20201230142125-a7e3863a1245/go.mod h1:pQAZKsJ8yyVxGRWYNEm9oFB8ieLgKFnamEyDmSA0BRk= +github.com/samber/lo v1.39.0 h1:4gTz1wUhNYLhFSKl6O+8peW0v2F4BCY034GRpU9WnuA= +github.com/samber/lo v1.39.0/go.mod h1:+m/ZKRl6ClXCE2Lgf3MsQlWfh4bn1bz6CXEOxnEXnEA= +github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8= github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I= github.com/sethvargo/go-retry v0.2.4 h1:T+jHEQy/zKJf5s95UkguisicE0zuF9y7+/vgz08Ocec= @@ -1447,6 +1461,7 @@ github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6Mwd github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= +github.com/soheilhy/cmux v0.1.5/go.mod h1:T7TcVDs9LWfQgPlPsdngu6I6QIoyIFZDDC6sNE1GqG0= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= github.com/spf13/afero v1.3.3/go.mod h1:5KUK8ByomD5Ti5Artl0RtHeI5pTF7MIDuXL3yY520V4= @@ -1526,6 +1541,7 @@ github.com/xhit/go-str2duration v1.2.0/go.mod h1:3cPSlfZlUHVlneIVfePFWcJZsuwf+P1 github.com/xhit/go-str2duration/v2 v2.1.0/go.mod h1:ohY8p+0f07DiV6Em5LKB0s2YpLtXVyJfNt1+BlmyAsU= github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 h1:nIPpBwaJSVYIxUFsDv3M8ofmx9yWTog9BfvIu0q41lo= github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8/go.mod h1:HUYIGzjTL3rfEspMxjDjgmT5uz5wzYJKVo23qUhYTos= +github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= github.com/xlab/treeprint v1.2.0 h1:HzHnuAF1plUN2zGlAFHbSQP2qJ0ZAD3XF5XD7OesXRQ= github.com/xlab/treeprint v1.2.0/go.mod h1:gj5Gd3gPdKtR1ikdDK6fnFLdmIS0X30kTTuNd/WEJu0= github.com/xwb1989/sqlparser v0.0.0-20180606152119-120387863bf2 h1:zzrxE1FKn5ryBNl9eKOeqQ58Y/Qpo3Q9QNxKHX5uzzQ= @@ -1545,6 +1561,7 @@ github.com/yuin/gopher-lua v1.1.1 h1:kYKnWBjvbNP4XLT3+bPEwAXJx262OhaHDWDVOPjL46M github.com/yuin/gopher-lua v1.1.1/go.mod h1:GBR0iDaNXjAgGg9zfCvksxSRnQx76gclCIb7kdAd1Pw= github.com/zclconf/go-cty v1.14.1 h1:t9fyA35fwjjUMcmL5hLER+e/rEPqrbCK1/OSE4SI9KA= github.com/zclconf/go-cty v1.14.1/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE= +github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b/go.mod h1:ZRKQfBXbGkpdV6QMzT3rU1kSTAnfu1dO8dPKjYprgj8= github.com/zeebo/assert v1.3.0/go.mod h1:Pq9JiuJQpG8JLJdtkwrJESF0Foym2/D9XMU5ciN/wJ0= github.com/zeebo/xxh3 v1.0.2/go.mod h1:5NWz9Sef7zIDm2JHfFlcQvNekmcEl9ekUZQQKCYaDcA= go.mongodb.org/mongo-driver v1.7.3/go.mod h1:NqaYOwnXWr5Pm7AOpO5QFxKJ503nbMse/R79oO62zWg= diff --git a/pkg/api.go b/pkg/api.go index 83c2e3e3e..dc1d58201 100644 --- a/pkg/api.go +++ b/pkg/api.go @@ -115,7 +115,9 @@ type Timeseries struct { Error string `json:"error,omitempty"` Duration int `json:"duration"` // Count is the number of times the check has been run in the specified time window - Count int `json:"count,omitempty"` + Count int `json:"count,omitempty"` + Passed int `json:"passed,omitempty"` + Failed int `json:"failed,omitempty"` } type Canary struct { @@ -138,15 +140,15 @@ func (c Canary) GetCheckID(checkName string) string { } func (c Canary) ToV1() (*v1.Canary, error) { + annotations := c.Annotations + annotations["source"] = c.Source canary := v1.Canary{ ObjectMeta: metav1.ObjectMeta{ - Name: c.Name, - Namespace: c.Namespace, - Annotations: map[string]string{ - "source": c.Source, - }, - Labels: c.Labels, - UID: k8stypes.UID(c.ID.String()), + Name: c.Name, + Namespace: c.Namespace, + Annotations: annotations, + Labels: c.Labels, + UID: k8stypes.UID(c.ID.String()), }, } var deletionTimestamp metav1.Time @@ -181,12 +183,13 @@ func CanaryFromV1(canary v1.Canary) (Canary, error) { checks = canary.Status.Checks } return Canary{ - Spec: spec, - Labels: types.JSONStringMap(canary.Labels), - Name: canary.Name, - Namespace: canary.Namespace, - Source: canary.Annotations["source"], - Checks: types.JSONStringMap(checks), + Spec: spec, + Labels: types.JSONStringMap(canary.Labels), + Annotations: types.JSONStringMap(canary.Annotations), + Name: canary.Name, + Namespace: canary.Namespace, + Source: canary.Annotations["source"], + Checks: types.JSONStringMap(checks), }, nil } diff --git a/pkg/api/api.go b/pkg/api/api.go index 7004e4731..3662a7e0e 100644 --- a/pkg/api/api.go +++ b/pkg/api/api.go @@ -8,6 +8,7 @@ import ( "github.com/flanksource/canary-checker/pkg/runner" "github.com/flanksource/duty/context" "github.com/flanksource/duty/models" + "github.com/flanksource/duty/query" "github.com/labstack/echo/v4" "github.com/flanksource/canary-checker/pkg" @@ -66,21 +67,21 @@ func CheckDetails(c echo.Context) error { start := time.Now() - summary, err := cache.PostgresCache.Query(*q) - if err != nil { - return errorResonse(c, err, http.StatusInternalServerError) - } - if len(summary) == 0 { - return c.JSON(http.StatusOK, DetailResponse{}) - } - - checkSummary := summary[0] - totalChecks := checkSummary.TotalRuns + end := q.GetEndTime() + since := q.GetStartTime() + timeRange := end.Sub(*since) - rangeDuration := checkSummary.LatestRuntime.Sub(*checkSummary.EarliestRuntime) - q.WindowDuration = getBestPartitioner(totalChecks, rangeDuration) + if timeRange <= time.Hour*2 { + q.WindowDuration = time.Minute + } else if timeRange >= time.Hour*24 { + q.WindowDuration = time.Minute * 15 + } else if timeRange >= time.Hour*24*7 { + q.WindowDuration = time.Minute * 60 + } else { + q.WindowDuration = time.Hour * 4 + } - results, err := cache.PostgresCache.QueryStatus(c.Request().Context(), *q) + results, uptime, latency, err := cache.PostgresCache.QueryStatus(c.Request().Context(), *q) if err != nil { return errorResonse(c, err, http.StatusInternalServerError) } @@ -89,33 +90,13 @@ func CheckDetails(c echo.Context) error { RunnerName: runner.RunnerName, Status: results, Duration: int(time.Since(start).Milliseconds()), - Latency: checkSummary.Latency, - Uptime: checkSummary.Uptime, + Latency: latency, + Uptime: uptime, } return c.JSON(http.StatusOK, apiResponse) } -func CheckSummary(c echo.Context) error { - q, err := cache.ParseQuery(c) - if err != nil { - return errorResonse(c, err, http.StatusBadRequest) - } - - start := time.Now() - results, err := cache.PostgresCache.Query(*q) - if err != nil { - return errorResonse(c, err, http.StatusInternalServerError) - } - - apiResponse := &Response{ - RunnerName: runner.RunnerName, - Checks: results, - Duration: int(time.Since(start).Milliseconds()), - } - return c.JSON(http.StatusOK, apiResponse) -} - func HealthSummary(c echo.Context) error { ctx := c.Request().Context().(context.Context) @@ -125,7 +106,7 @@ func HealthSummary(c echo.Context) error { } start := time.Now() - results, err := cache.PostgresCache.QuerySummary(ctx, queryOpt) + results, err := query.CheckSummary(ctx, query.CheckSummaryOptions(queryOpt)) if err != nil { return errorResonse(c, err, http.StatusInternalServerError) } diff --git a/pkg/cache/cache.go b/pkg/cache/cache.go index 699e7de16..755d63f09 100644 --- a/pkg/cache/cache.go +++ b/pkg/cache/cache.go @@ -9,6 +9,7 @@ import ( "github.com/flanksource/canary-checker/pkg" "github.com/labstack/echo/v4" "github.com/pkg/errors" + "github.com/samber/lo" ) var DefaultCacheCount int @@ -57,9 +58,12 @@ func (q QueryParams) GetStartTime() *time.Time { } func (q QueryParams) GetEndTime() *time.Time { - if q._end != nil || q.End == "" { + if q._end != nil { return q._end } + if q.End == "" { + q._end = lo.ToPtr(time.Now()) + } q._end, _ = timeV(q.End) return q._end } diff --git a/pkg/cache/postgres.go b/pkg/cache/postgres.go index 1610a8b1c..cd16b84b1 100644 --- a/pkg/cache/postgres.go +++ b/pkg/cache/postgres.go @@ -8,8 +8,6 @@ import ( "github.com/flanksource/canary-checker/pkg" "github.com/flanksource/canary-checker/pkg/db" "github.com/flanksource/commons/logger" - "github.com/flanksource/duty/context" - "github.com/flanksource/duty/models" "github.com/flanksource/duty/query" "github.com/google/uuid" "github.com/jackc/pgx/v5/pgxpool" @@ -112,15 +110,7 @@ func (c *postgresCache) AddCheckStatus(check pkg.Check, status pkg.CheckStatus) } } -func (c *postgresCache) Query(q QueryParams) (pkg.Checks, error) { - return q.ExecuteSummary(db.Pool) -} - -func (c *postgresCache) QuerySummary(ctx context.Context, opt SummaryOptions) ([]models.CheckSummary, error) { - return query.CheckSummary(ctx, query.CheckSummaryOptions(opt)) -} - -func (c *postgresCache) QueryStatus(ctx gocontext.Context, q QueryParams) ([]pkg.Timeseries, error) { +func (c *postgresCache) QueryStatus(ctx gocontext.Context, q QueryParams) ([]pkg.Timeseries, pkg.Uptime, pkg.Latency, error) { return q.ExecuteDetails(ctx, db.Pool) } diff --git a/pkg/cache/postgres_query.go b/pkg/cache/postgres_query.go index dbf31acb4..6a7c2fdc8 100644 --- a/pkg/cache/postgres_query.go +++ b/pkg/cache/postgres_query.go @@ -6,10 +6,9 @@ import ( "strings" "time" + "github.com/asecurityteam/rolling" "github.com/flanksource/canary-checker/pkg" "github.com/flanksource/commons/duration" - "github.com/flanksource/commons/logger" - "github.com/google/uuid" "github.com/jackc/pgx/v5" ) @@ -79,7 +78,7 @@ func (q QueryParams) GetWhereClause() (string, map[string]interface{}, error) { return strings.TrimSpace(clause), args, nil } -func (q QueryParams) ExecuteDetails(ctx context.Context, db Querier) ([]pkg.Timeseries, error) { +func (q QueryParams) ExecuteDetails(ctx context.Context, db Querier) ([]pkg.Timeseries, pkg.Uptime, pkg.Latency, error) { start := q.GetStartTime().Format(time.RFC3339) end := q.GetEndTime().Format(time.RFC3339) @@ -88,6 +87,8 @@ With grouped_by_window AS ( SELECT duration, status, + CASE WHEN check_statuses.status = TRUE THEN 1 ELSE 0 END AS passed, + CASE WHEN check_statuses.status = FALSE THEN 1 ELSE 0 END AS failed, to_timestamp(floor((extract(epoch FROM time) + $1) / $2) * $2) AS time FROM check_statuses WHERE @@ -95,11 +96,13 @@ With grouped_by_window AS ( time <= $4 AND check_id = $5 ) -SELECT +SELECT time, bool_and(status), - AVG(duration)::integer as duration -FROM + AVG(duration)::integer as duration, + sum(passed) as passed, + sum(failed) as failed +FROM grouped_by_window GROUP BY time ORDER BY time @@ -107,13 +110,19 @@ ORDER BY time args := []any{q.WindowDuration.Seconds() / 2, q.WindowDuration.Seconds(), start, end, q.Check} if q.WindowDuration == 0 { - query = `SELECT time, status, duration FROM check_statuses WHERE time >= $1 AND time <= $2 AND check_id = $3` + // FIXME + query = `SELECT time, status, duration, + CASE WHEN check_statuses.status = TRUE THEN 1 ELSE 0 END AS passed, + CASE WHEN check_statuses.status = FALSE THEN 1 ELSE 0 END AS failed + FROM check_statuses WHERE time >= $1 AND time <= $2 AND check_id = $3` args = []any{start, end, q.Check} } + uptime := pkg.Uptime{} + latency := rolling.NewPointPolicy(rolling.NewWindow(100)) rows, err := db.Query(ctx, query, args...) if err != nil { - return nil, err + return nil, uptime, pkg.Latency{}, err } defer rows.Close() @@ -121,181 +130,15 @@ ORDER BY time for rows.Next() { var datapoint pkg.Timeseries var ts time.Time - if err := rows.Scan(&ts, &datapoint.Status, &datapoint.Duration); err != nil { - return nil, err + if err := rows.Scan(&ts, &datapoint.Status, &datapoint.Duration, &datapoint.Passed, &datapoint.Failed); err != nil { + return nil, uptime, pkg.Latency{}, err } - + uptime.Failed += datapoint.Failed + uptime.Passed += datapoint.Passed + latency.Append(float64(datapoint.Duration)) datapoint.Time = ts.Format(time.RFC3339) results = append(results, datapoint) } - return results, nil -} - -func exec(db Querier, q QueryParams, sql string, namedArgs map[string]interface{}) (pgx.Rows, error) { - if q.Trace { - sqlDebug := ConvertNamedParamsDebug(sql, namedArgs) - logger.Tracef(sqlDebug) - } - - positionalSQL, args := ConvertNamedParams(sql, namedArgs) - - rows, err := db.Query(context.Background(), positionalSQL, args...) - - if err != nil { - logger.Debugf("Error executing query: %v\n%s\n args=%v", err, positionalSQL, args) - } - return rows, err -} - -func (q QueryParams) ExecuteSummary(db Querier) (pkg.Checks, error) { - clause, namedArgs, err := q.GetWhereClause() - if err != nil { - return nil, err - } - var checkClause string - if q.CanaryID != "" { - checkClause += " AND checks.canary_id = :canary_id " - namedArgs["canary_id"] = q.CanaryID - } - if _, exists := namedArgs["check_key"]; exists { - checkClause += " AND checks.id = :check_key " - } - - statusColumns := "" - if q.IncludeMessages { - statusColumns += ", 'message', message, 'error', error" - } - sql := fmt.Sprintf(` -WITH filtered_check_status AS ( - SELECT * FROM check_statuses - WHERE %s -) -SELECT - checks.id::text, - canary_id::text, - stats.passed, - stats.failed, - stats.p99, stats.p97, stats.p95, - statii, - type, - checks.icon, - checks.name, - checks.description, - canaries.namespace, - canaries.name as canaryName, - canaries.labels || checks.labels as labels, - severity, - owner, - last_runtime, - checks.created_at, - checks.updated_at, - checks.deleted_at, - status, - stats.max_time, - stats.min_time, - stats.total_checks -FROM checks checks -RIGHT JOIN ( - SELECT - check_id, - percentile_disc(0.99) within group (order by filtered_check_status.duration) as p99, - percentile_disc(0.97) within group (order by filtered_check_status.duration) as p97, - percentile_disc(0.05) within group (order by filtered_check_status.duration) as p95, - COUNT(*) FILTER (WHERE filtered_check_status.status = TRUE) as passed, - COUNT(*) FILTER (WHERE filtered_check_status.status = FALSE) as failed, - COUNT(*) total_checks, - MIN(filtered_check_status.time) as min_time, - MAX(filtered_check_status.time) as max_time - FROM - filtered_check_status - GROUP BY check_id -) as stats ON stats.check_id = checks.id - -INNER JOIN canaries on checks.canary_id = canaries.id - -RIGHT JOIN ( - SELECT check_id, json_agg(json_build_object('status',status,'duration',duration,'time',time %s)) as statii - FROM ( - SELECT check_id, - status, - time, - duration, - message, - error, - rank() OVER ( - PARTITION BY check_id - ORDER BY time DESC - ) - FROM filtered_check_status - ) check_statuses - WHERE rank <= :count - GROUP by check_id -) as statuses ON statuses.check_id = checks.id -WHERE (stats.passed > 0 OR stats.failed > 0) %s - `, clause, statusColumns, checkClause) - - if q.StatusCount == 0 { - q.StatusCount = 5 - } - namedArgs["count"] = q.StatusCount - - rows, err := exec(db, q, sql, namedArgs) - if err != nil { - return nil, err - } - defer rows.Close() - - checks := pkg.Checks{} - for rows.Next() { - var check = pkg.Check{} - vals, err := rows.Values() - if err != nil { - return nil, err - } - check.ID, _ = uuid.Parse(vals[0].(string)) - check.CanaryID, _ = uuid.Parse(vals[1].(string)) - check.Uptime.Passed = intV(vals[2]) - check.Uptime.Failed = intV(vals[3]) - check.Latency.Percentile99 = float64V(vals[4]) - check.Latency.Percentile97 = float64V(vals[5]) - check.Latency.Percentile95 = float64V(vals[6]) - check.Type = vals[8].(string) - check.Icon = vals[9].(string) - check.Name = vals[10].(string) - check.Description = vals[11].(string) - check.Namespace = vals[12].(string) - check.CanaryName = vals[13].(string) - check.Labels = mapStringString(vals[14]) - check.Severity = vals[15].(string) - check.Owner = vals[16].(string) - check.LastRuntime, _ = timeV(vals[17]) - check.CreatedAt, _ = timeV(vals[18]) - check.UpdatedAt, _ = timeV(vals[19]) - if vals[20] != nil { - check.DeletedAt, _ = timeV(vals[20]) - } - check.Status = vals[21].(string) - check.LatestRuntime, _ = timeV(vals[22]) - check.EarliestRuntime, _ = timeV(vals[23]) - check.TotalRuns = intV(vals[24]) - - if vals[7] != nil { - for _, status := range vals[7].([]interface{}) { - s := status.(map[string]interface{}) - check.Statuses = append(check.Statuses, pkg.CheckStatus{ - Status: s["status"].(bool), - Time: s["time"].(string), - Duration: intV(s["duration"]), - Message: stringV(s["message"]), - Error: stringV(s["error"]), - }) - } - } - if q.Trace { - logger.Infof("%+v", check) - } - checks = append(checks, &check) - } - return checks, err + return results, uptime, pkg.Latency{Percentile95: latency.Reduce(rolling.Percentile(95))}, nil } diff --git a/pkg/cache/postgres_query_test.go b/pkg/cache/postgres_query_test.go deleted file mode 100644 index 9577f34d5..000000000 --- a/pkg/cache/postgres_query_test.go +++ /dev/null @@ -1,101 +0,0 @@ -package cache - -import ( - "fmt" - "testing" - - "github.com/flanksource/canary-checker/pkg/db" - "github.com/flanksource/duty" - . "github.com/onsi/gomega" - . "github.com/onsi/gomega/gstruct" -) - -var cases = []struct { - fixture QueryParams - returnErr bool - args map[string]interface{} - clause string -}{ - { - fixture: QueryParams{ - Start: "1h", - Trace: true, - StatusCount: 5, - }, - args: map[string]interface{}{ - "start": float64(60), - }, - returnErr: false, - clause: "time > (NOW() at TIME ZONE 'utc' - Interval '1 minute' * :start)", - }, - // { - // fixture: QueryParams{ - // End: "1h", - // }, - // args: map[string]interface{}{ - // "end": float64(60), - // }, - // returnErr: false, - // clause: "time < (NOW() - Interval '1 minute' * :end)", - // }, - // { - // fixture: QueryParams{ - // Start: "2h", - // End: "1h", - // }, - // args: map[string]interface{}{ - // "start": float64(120), - // "end": float64(60), - // }, - // returnErr: false, - // clause: "time BETWEEN (NOW() - Interval '1 minute' * :start) AND (NOW() - Interval '1 minute' * :end)", - // }, -} - -func TestQueries(t *testing.T) { - t.Skip("Skipping TestQueries due to DB object creation failing. TODO: Fix me") - if err := db.Init(); err != nil { - t.Fatalf("Failed to init db: %v", err) - } - var err error - if db.Gorm, db.Pool, err = duty.SetupDB("", nil); err != nil { - t.Fatalf("Failed to setup database: %v", err) - } - psql := NewPostgresCache(db.Pool) - _cache := psql - t.Run(fmt.Sprintf("%T", psql), func(t *testing.T) { - for _, tc := range cases { - t.Run(tc.fixture.String(), func(t *testing.T) { - results, err := _cache.Query(tc.fixture) - if err != nil { - t.Errorf("Expected no error, got: %v", err) - } - g := NewWithT(t) - g.Expect(len(results)).To(BeNumerically(">", 1)) - check := results[0] - t.Log(*check) - g.Expect(*check).To((MatchFields(IgnoreExtras, Fields{ - "Name": Not(BeEmpty()), - "Namespace": Not(BeEmpty()), - "Type": Not(BeEmpty()), - "Key": Not(BeEmpty()), - "RunnerName": Not(BeEmpty()), - "Statuses": HaveLen(tc.fixture.StatusCount), - }))) - }) - } - }) -} - -func TestDurations(t *testing.T) { - for _, tc := range cases { - t.Run(tc.fixture.String(), func(t *testing.T) { - clause, args, err := tc.fixture.GetWhereClause() - returnedErr := err != nil - g := NewWithT(t) - g.Expect(returnedErr).To(Equal(tc.returnErr)) - g.Expect(args).To(Equal(tc.args)) - g.Expect(clause).To(Equal(tc.clause)) - }) - } -} diff --git a/pkg/cache/postgres_util.go b/pkg/cache/postgres_util.go index e3191eb0a..1582bda0b 100644 --- a/pkg/cache/postgres_util.go +++ b/pkg/cache/postgres_util.go @@ -28,43 +28,6 @@ func ConvertNamedParams(sql string, namedArgs map[string]interface{}) (string, [ return sql, args } -func mapStringString(v interface{}) map[string]string { - if v == nil { - return nil - } - r := make(map[string]string) - for k, v := range v.(map[string]interface{}) { - r[k] = fmt.Sprintf("%v", v) - } - return r -} - -func intV(v interface{}) int { - if v == nil { - return 0 - } - switch v := v.(type) { - case int: - return v - case int32: - return int(v) - case int64: - return int(v) - case float64: - return int(v) - case float32: - return int(v) - } - return 0 -} - -func stringV(v interface{}) string { - if v == nil { - return "" - } - return v.(string) -} - func timeV(v interface{}) (*time.Time, error) { if v == nil { return nil, nil @@ -89,22 +52,3 @@ func timeV(v interface{}) (*time.Time, error) { } return nil, fmt.Errorf("unknown time type %T", v) } - -func float64V(v interface{}) float64 { - if v == nil { - return 0 - } - switch v := v.(type) { - case int: - return float64(v) - case int32: - return float64(v) - case int64: - return float64(v) - case float64: - return v - case float32: - return float64(v) - } - return 0 -} diff --git a/pkg/topology/run_test.go b/pkg/topology/run_test.go index 22244ec6f..ec93b8349 100644 --- a/pkg/topology/run_test.go +++ b/pkg/topology/run_test.go @@ -5,11 +5,11 @@ import ( v1 "github.com/flanksource/canary-checker/api/v1" "github.com/flanksource/canary-checker/pkg/db" - "github.com/flanksource/canary-checker/pkg/utils" "github.com/flanksource/duty/models" "github.com/flanksource/duty/types" ginkgo "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" + "github.com/samber/lo" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/yaml" @@ -47,13 +47,13 @@ var _ = ginkgo.Describe("Test topology run", ginkgo.Ordered, func() { } ci := models.ConfigItem{ - Name: utils.Ptr("config-item"), + Name: lo.ToPtr("config-item"), Tags: &types.JSONStringMap{ "tag-1": "a", "tag-2": "b", }, - Config: utils.Ptr(`{"spec": {"container": {"name": "hello", "version": "v3"}}}`), - Type: utils.Ptr("Config::Dummy"), + Config: lo.ToPtr(`{"spec": {"container": {"name": "hello", "version": "v3"}}}`), + Type: lo.ToPtr("Config::Dummy"), ConfigClass: "Dummy", } From ed6077948be6923ac96d38fdc6ec19f059b55453 Mon Sep 17 00:00:00 2001 From: Moshe Immerman Date: Wed, 20 Dec 2023 21:53:10 +0200 Subject: [PATCH 4/6] feat: add helmRef envvar source --- config/deploy/crd.yaml | 741 +++++++++++++++++- config/schemas/canary.schema.json | 18 + config/schemas/component.schema.json | 18 + .../schemas/health_alertmanager.schema.json | 18 + config/schemas/health_awsconfig.schema.json | 18 + .../schemas/health_awsconfigrule.schema.json | 18 + config/schemas/health_azuredevops.schema.json | 18 + config/schemas/health_cloudwatch.schema.json | 18 + .../schemas/health_containerdPull.schema.json | 18 + .../health_databasebackupcheck.schema.json | 18 + config/schemas/health_dockerPull.schema.json | 18 + config/schemas/health_dockerPush.schema.json | 18 + config/schemas/health_dynatrace.schema.json | 18 + config/schemas/health_ec2.schema.json | 18 + .../schemas/health_elasticsearch.schema.json | 18 + config/schemas/health_exec.schema.json | 18 + config/schemas/health_folder.schema.json | 18 + config/schemas/health_github.schema.json | 18 + config/schemas/health_helm.schema.json | 18 + config/schemas/health_http.schema.json | 18 + config/schemas/health_jmeter.schema.json | 18 + config/schemas/health_ldap.schema.json | 18 + config/schemas/health_mongodb.schema.json | 18 + config/schemas/health_mssql.schema.json | 18 + config/schemas/health_mysql.schema.json | 18 + config/schemas/health_opensearch.schema.json | 18 + config/schemas/health_postgres.schema.json | 18 + config/schemas/health_prometheus.schema.json | 18 + config/schemas/health_redis.schema.json | 18 + config/schemas/health_restic.schema.json | 18 + config/schemas/health_s3.schema.json | 18 + config/schemas/health_webhook.schema.json | 18 + config/schemas/topology.schema.json | 18 + hack/generate-schemas/.gitignore | 2 + hack/generate-schemas/go.mod | 3 +- hack/generate-schemas/go.sum | 11 +- pkg/db/check_statuses.go | 2 + 37 files changed, 1331 insertions(+), 4 deletions(-) create mode 100644 hack/generate-schemas/.gitignore diff --git a/config/deploy/crd.yaml b/config/deploy/crd.yaml index 5b6696163..8442b746a 100644 --- a/config/deploy/crd.yaml +++ b/config/deploy/crd.yaml @@ -1,4 +1,3 @@ ---- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: @@ -154,6 +153,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -307,6 +316,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -345,6 +364,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -443,6 +472,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -474,6 +513,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -544,6 +593,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -653,6 +712,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -684,6 +753,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -814,6 +893,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -895,6 +984,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -997,6 +1096,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -1028,6 +1137,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -1189,6 +1308,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -1220,6 +1349,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -1392,6 +1531,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -1579,6 +1728,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -1610,6 +1769,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -1704,6 +1873,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -1735,6 +1914,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -1822,6 +2011,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -1944,6 +2143,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -2041,6 +2250,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -2074,6 +2293,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -2185,6 +2414,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -2248,6 +2487,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -2353,6 +2602,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -2389,6 +2648,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -2422,6 +2691,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -2458,6 +2737,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -2499,6 +2788,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -2530,6 +2829,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -2570,6 +2879,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -2601,6 +2920,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -2642,6 +2971,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -2693,6 +3032,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -2805,6 +3154,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -2846,6 +3205,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -2877,6 +3246,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -2949,6 +3328,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -3050,6 +3439,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -3084,6 +3483,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -3126,6 +3535,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -3160,6 +3579,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -3244,6 +3673,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -3352,6 +3791,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -3383,6 +3832,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -3498,6 +3957,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -3532,6 +4001,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -3629,6 +4108,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -3713,6 +4202,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -3829,6 +4328,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -4188,6 +4697,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -4229,6 +4748,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -4313,6 +4842,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -4350,6 +4889,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -4444,6 +4993,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -4508,6 +5067,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -4602,6 +5171,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -4666,6 +5245,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -4866,6 +5455,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -4930,6 +5529,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -5124,6 +5733,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -5188,6 +5807,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -5285,6 +5914,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -5347,6 +5986,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -5436,6 +6085,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -5473,6 +6132,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -5515,6 +6184,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -5604,6 +6283,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -5639,6 +6328,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -5685,6 +6384,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -5770,6 +6479,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -5801,6 +6520,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -5974,6 +6703,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: diff --git a/config/schemas/canary.schema.json b/config/schemas/canary.schema.json index d7be3244f..547bdce3d 100644 --- a/config/schemas/canary.schema.json +++ b/config/schemas/canary.schema.json @@ -1434,6 +1434,9 @@ "serviceAccount": { "type": "string" }, + "helmRef": { + "$ref": "#/$defs/HelmRefKeySelector" + }, "configMapKeyRef": { "$ref": "#/$defs/ConfigMapKeySelector" }, @@ -1897,6 +1900,21 @@ "name" ] }, + "HelmRefKeySelector": { + "properties": { + "name": { + "type": "string" + }, + "key": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "key" + ] + }, "ICMPCheck": { "properties": { "description": { diff --git a/config/schemas/component.schema.json b/config/schemas/component.schema.json index 8d2667485..9bd36a40c 100644 --- a/config/schemas/component.schema.json +++ b/config/schemas/component.schema.json @@ -1610,6 +1610,9 @@ "serviceAccount": { "type": "string" }, + "helmRef": { + "$ref": "#/$defs/HelmRefKeySelector" + }, "configMapKeyRef": { "$ref": "#/$defs/ConfigMapKeySelector" }, @@ -2106,6 +2109,21 @@ "name" ] }, + "HelmRefKeySelector": { + "properties": { + "name": { + "type": "string" + }, + "key": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "key" + ] + }, "ICMPCheck": { "properties": { "description": { diff --git a/config/schemas/health_alertmanager.schema.json b/config/schemas/health_alertmanager.schema.json index 40952d025..ce847d28c 100644 --- a/config/schemas/health_alertmanager.schema.json +++ b/config/schemas/health_alertmanager.schema.json @@ -141,6 +141,9 @@ "serviceAccount": { "type": "string" }, + "helmRef": { + "$ref": "#/$defs/HelmRefKeySelector" + }, "configMapKeyRef": { "$ref": "#/$defs/ConfigMapKeySelector" }, @@ -151,6 +154,21 @@ "additionalProperties": false, "type": "object" }, + "HelmRefKeySelector": { + "properties": { + "name": { + "type": "string" + }, + "key": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "key" + ] + }, "Labels": { "patternProperties": { ".*": { diff --git a/config/schemas/health_awsconfig.schema.json b/config/schemas/health_awsconfig.schema.json index 4b86792d9..0c4343991 100644 --- a/config/schemas/health_awsconfig.schema.json +++ b/config/schemas/health_awsconfig.schema.json @@ -114,6 +114,9 @@ "serviceAccount": { "type": "string" }, + "helmRef": { + "$ref": "#/$defs/HelmRefKeySelector" + }, "configMapKeyRef": { "$ref": "#/$defs/ConfigMapKeySelector" }, @@ -124,6 +127,21 @@ "additionalProperties": false, "type": "object" }, + "HelmRefKeySelector": { + "properties": { + "name": { + "type": "string" + }, + "key": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "key" + ] + }, "Labels": { "patternProperties": { ".*": { diff --git a/config/schemas/health_awsconfigrule.schema.json b/config/schemas/health_awsconfigrule.schema.json index dfa9128b8..f4d9eda4a 100644 --- a/config/schemas/health_awsconfigrule.schema.json +++ b/config/schemas/health_awsconfigrule.schema.json @@ -125,6 +125,9 @@ "serviceAccount": { "type": "string" }, + "helmRef": { + "$ref": "#/$defs/HelmRefKeySelector" + }, "configMapKeyRef": { "$ref": "#/$defs/ConfigMapKeySelector" }, @@ -135,6 +138,21 @@ "additionalProperties": false, "type": "object" }, + "HelmRefKeySelector": { + "properties": { + "name": { + "type": "string" + }, + "key": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "key" + ] + }, "Labels": { "patternProperties": { ".*": { diff --git a/config/schemas/health_azuredevops.schema.json b/config/schemas/health_azuredevops.schema.json index fd51f2b35..b14cc35a3 100644 --- a/config/schemas/health_azuredevops.schema.json +++ b/config/schemas/health_azuredevops.schema.json @@ -119,6 +119,9 @@ "serviceAccount": { "type": "string" }, + "helmRef": { + "$ref": "#/$defs/HelmRefKeySelector" + }, "configMapKeyRef": { "$ref": "#/$defs/ConfigMapKeySelector" }, @@ -129,6 +132,21 @@ "additionalProperties": false, "type": "object" }, + "HelmRefKeySelector": { + "properties": { + "name": { + "type": "string" + }, + "key": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "key" + ] + }, "Labels": { "patternProperties": { ".*": { diff --git a/config/schemas/health_cloudwatch.schema.json b/config/schemas/health_cloudwatch.schema.json index ff2d343bc..23dfdd017 100644 --- a/config/schemas/health_cloudwatch.schema.json +++ b/config/schemas/health_cloudwatch.schema.json @@ -122,6 +122,9 @@ "serviceAccount": { "type": "string" }, + "helmRef": { + "$ref": "#/$defs/HelmRefKeySelector" + }, "configMapKeyRef": { "$ref": "#/$defs/ConfigMapKeySelector" }, @@ -132,6 +135,21 @@ "additionalProperties": false, "type": "object" }, + "HelmRefKeySelector": { + "properties": { + "name": { + "type": "string" + }, + "key": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "key" + ] + }, "Labels": { "patternProperties": { ".*": { diff --git a/config/schemas/health_containerdPull.schema.json b/config/schemas/health_containerdPull.schema.json index 889e96a20..e991478f7 100644 --- a/config/schemas/health_containerdPull.schema.json +++ b/config/schemas/health_containerdPull.schema.json @@ -96,6 +96,9 @@ "serviceAccount": { "type": "string" }, + "helmRef": { + "$ref": "#/$defs/HelmRefKeySelector" + }, "configMapKeyRef": { "$ref": "#/$defs/ConfigMapKeySelector" }, @@ -106,6 +109,21 @@ "additionalProperties": false, "type": "object" }, + "HelmRefKeySelector": { + "properties": { + "name": { + "type": "string" + }, + "key": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "key" + ] + }, "Labels": { "patternProperties": { ".*": { diff --git a/config/schemas/health_databasebackupcheck.schema.json b/config/schemas/health_databasebackupcheck.schema.json index 0311430c4..03819cf8b 100644 --- a/config/schemas/health_databasebackupcheck.schema.json +++ b/config/schemas/health_databasebackupcheck.schema.json @@ -86,6 +86,9 @@ "serviceAccount": { "type": "string" }, + "helmRef": { + "$ref": "#/$defs/HelmRefKeySelector" + }, "configMapKeyRef": { "$ref": "#/$defs/ConfigMapKeySelector" }, @@ -130,6 +133,21 @@ "instance" ] }, + "HelmRefKeySelector": { + "properties": { + "name": { + "type": "string" + }, + "key": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "key" + ] + }, "Labels": { "patternProperties": { ".*": { diff --git a/config/schemas/health_dockerPull.schema.json b/config/schemas/health_dockerPull.schema.json index 572acc011..ee29326a4 100644 --- a/config/schemas/health_dockerPull.schema.json +++ b/config/schemas/health_dockerPull.schema.json @@ -96,6 +96,9 @@ "serviceAccount": { "type": "string" }, + "helmRef": { + "$ref": "#/$defs/HelmRefKeySelector" + }, "configMapKeyRef": { "$ref": "#/$defs/ConfigMapKeySelector" }, @@ -106,6 +109,21 @@ "additionalProperties": false, "type": "object" }, + "HelmRefKeySelector": { + "properties": { + "name": { + "type": "string" + }, + "key": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "key" + ] + }, "Labels": { "patternProperties": { ".*": { diff --git a/config/schemas/health_dockerPush.schema.json b/config/schemas/health_dockerPush.schema.json index 8f235438f..fc09df178 100644 --- a/config/schemas/health_dockerPush.schema.json +++ b/config/schemas/health_dockerPush.schema.json @@ -90,6 +90,9 @@ "serviceAccount": { "type": "string" }, + "helmRef": { + "$ref": "#/$defs/HelmRefKeySelector" + }, "configMapKeyRef": { "$ref": "#/$defs/ConfigMapKeySelector" }, @@ -100,6 +103,21 @@ "additionalProperties": false, "type": "object" }, + "HelmRefKeySelector": { + "properties": { + "name": { + "type": "string" + }, + "key": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "key" + ] + }, "Labels": { "patternProperties": { ".*": { diff --git a/config/schemas/health_dynatrace.schema.json b/config/schemas/health_dynatrace.schema.json index bec945724..713f8b716 100644 --- a/config/schemas/health_dynatrace.schema.json +++ b/config/schemas/health_dynatrace.schema.json @@ -92,6 +92,9 @@ "serviceAccount": { "type": "string" }, + "helmRef": { + "$ref": "#/$defs/HelmRefKeySelector" + }, "configMapKeyRef": { "$ref": "#/$defs/ConfigMapKeySelector" }, @@ -102,6 +105,21 @@ "additionalProperties": false, "type": "object" }, + "HelmRefKeySelector": { + "properties": { + "name": { + "type": "string" + }, + "key": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "key" + ] + }, "Labels": { "patternProperties": { ".*": { diff --git a/config/schemas/health_ec2.schema.json b/config/schemas/health_ec2.schema.json index 132ca7110..dc53528a4 100644 --- a/config/schemas/health_ec2.schema.json +++ b/config/schemas/health_ec2.schema.json @@ -122,6 +122,9 @@ "serviceAccount": { "type": "string" }, + "helmRef": { + "$ref": "#/$defs/HelmRefKeySelector" + }, "configMapKeyRef": { "$ref": "#/$defs/ConfigMapKeySelector" }, @@ -132,6 +135,21 @@ "additionalProperties": false, "type": "object" }, + "HelmRefKeySelector": { + "properties": { + "name": { + "type": "string" + }, + "key": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "key" + ] + }, "Labels": { "patternProperties": { ".*": { diff --git a/config/schemas/health_elasticsearch.schema.json b/config/schemas/health_elasticsearch.schema.json index fab736412..57c91041b 100644 --- a/config/schemas/health_elasticsearch.schema.json +++ b/config/schemas/health_elasticsearch.schema.json @@ -101,6 +101,9 @@ "serviceAccount": { "type": "string" }, + "helmRef": { + "$ref": "#/$defs/HelmRefKeySelector" + }, "configMapKeyRef": { "$ref": "#/$defs/ConfigMapKeySelector" }, @@ -111,6 +114,21 @@ "additionalProperties": false, "type": "object" }, + "HelmRefKeySelector": { + "properties": { + "name": { + "type": "string" + }, + "key": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "key" + ] + }, "Labels": { "patternProperties": { ".*": { diff --git a/config/schemas/health_exec.schema.json b/config/schemas/health_exec.schema.json index 044abf822..c795af4dd 100644 --- a/config/schemas/health_exec.schema.json +++ b/config/schemas/health_exec.schema.json @@ -101,6 +101,9 @@ "serviceAccount": { "type": "string" }, + "helmRef": { + "$ref": "#/$defs/HelmRefKeySelector" + }, "configMapKeyRef": { "$ref": "#/$defs/ConfigMapKeySelector" }, @@ -229,6 +232,21 @@ "additionalProperties": false, "type": "object" }, + "HelmRefKeySelector": { + "properties": { + "name": { + "type": "string" + }, + "key": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "key" + ] + }, "Labels": { "patternProperties": { ".*": { diff --git a/config/schemas/health_folder.schema.json b/config/schemas/health_folder.schema.json index f4978bf47..5919622da 100644 --- a/config/schemas/health_folder.schema.json +++ b/config/schemas/health_folder.schema.json @@ -71,6 +71,9 @@ "serviceAccount": { "type": "string" }, + "helmRef": { + "$ref": "#/$defs/HelmRefKeySelector" + }, "configMapKeyRef": { "$ref": "#/$defs/ConfigMapKeySelector" }, @@ -205,6 +208,21 @@ "additionalProperties": false, "type": "object" }, + "HelmRefKeySelector": { + "properties": { + "name": { + "type": "string" + }, + "key": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "key" + ] + }, "Labels": { "patternProperties": { ".*": { diff --git a/config/schemas/health_github.schema.json b/config/schemas/health_github.schema.json index 0990fc011..81bf738bd 100644 --- a/config/schemas/health_github.schema.json +++ b/config/schemas/health_github.schema.json @@ -38,6 +38,9 @@ "serviceAccount": { "type": "string" }, + "helmRef": { + "$ref": "#/$defs/HelmRefKeySelector" + }, "configMapKeyRef": { "$ref": "#/$defs/ConfigMapKeySelector" }, @@ -100,6 +103,21 @@ "query" ] }, + "HelmRefKeySelector": { + "properties": { + "name": { + "type": "string" + }, + "key": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "key" + ] + }, "Labels": { "patternProperties": { ".*": { diff --git a/config/schemas/health_helm.schema.json b/config/schemas/health_helm.schema.json index 44f04c6f6..efea8f7e2 100644 --- a/config/schemas/health_helm.schema.json +++ b/config/schemas/health_helm.schema.json @@ -50,6 +50,9 @@ "serviceAccount": { "type": "string" }, + "helmRef": { + "$ref": "#/$defs/HelmRefKeySelector" + }, "configMapKeyRef": { "$ref": "#/$defs/ConfigMapKeySelector" }, @@ -105,6 +108,21 @@ "name" ] }, + "HelmRefKeySelector": { + "properties": { + "name": { + "type": "string" + }, + "key": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "key" + ] + }, "Labels": { "patternProperties": { ".*": { diff --git a/config/schemas/health_http.schema.json b/config/schemas/health_http.schema.json index be5a3d7ce..28505e5cd 100644 --- a/config/schemas/health_http.schema.json +++ b/config/schemas/health_http.schema.json @@ -38,6 +38,9 @@ "serviceAccount": { "type": "string" }, + "helmRef": { + "$ref": "#/$defs/HelmRefKeySelector" + }, "configMapKeyRef": { "$ref": "#/$defs/ConfigMapKeySelector" }, @@ -153,6 +156,21 @@ "name" ] }, + "HelmRefKeySelector": { + "properties": { + "name": { + "type": "string" + }, + "key": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "key" + ] + }, "JSONCheck": { "properties": { "path": { diff --git a/config/schemas/health_jmeter.schema.json b/config/schemas/health_jmeter.schema.json index 26dbacff4..7a326c0c5 100644 --- a/config/schemas/health_jmeter.schema.json +++ b/config/schemas/health_jmeter.schema.json @@ -38,6 +38,9 @@ "serviceAccount": { "type": "string" }, + "helmRef": { + "$ref": "#/$defs/HelmRefKeySelector" + }, "configMapKeyRef": { "$ref": "#/$defs/ConfigMapKeySelector" }, @@ -48,6 +51,21 @@ "additionalProperties": false, "type": "object" }, + "HelmRefKeySelector": { + "properties": { + "name": { + "type": "string" + }, + "key": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "key" + ] + }, "JmeterCheck": { "properties": { "description": { diff --git a/config/schemas/health_ldap.schema.json b/config/schemas/health_ldap.schema.json index d441acc72..7cdbab552 100644 --- a/config/schemas/health_ldap.schema.json +++ b/config/schemas/health_ldap.schema.json @@ -38,6 +38,9 @@ "serviceAccount": { "type": "string" }, + "helmRef": { + "$ref": "#/$defs/HelmRefKeySelector" + }, "configMapKeyRef": { "$ref": "#/$defs/ConfigMapKeySelector" }, @@ -48,6 +51,21 @@ "additionalProperties": false, "type": "object" }, + "HelmRefKeySelector": { + "properties": { + "name": { + "type": "string" + }, + "key": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "key" + ] + }, "LDAPCheck": { "properties": { "description": { diff --git a/config/schemas/health_mongodb.schema.json b/config/schemas/health_mongodb.schema.json index 8d4c5c1fc..57b4fae02 100644 --- a/config/schemas/health_mongodb.schema.json +++ b/config/schemas/health_mongodb.schema.json @@ -38,6 +38,9 @@ "serviceAccount": { "type": "string" }, + "helmRef": { + "$ref": "#/$defs/HelmRefKeySelector" + }, "configMapKeyRef": { "$ref": "#/$defs/ConfigMapKeySelector" }, @@ -48,6 +51,21 @@ "additionalProperties": false, "type": "object" }, + "HelmRefKeySelector": { + "properties": { + "name": { + "type": "string" + }, + "key": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "key" + ] + }, "Labels": { "patternProperties": { ".*": { diff --git a/config/schemas/health_mssql.schema.json b/config/schemas/health_mssql.schema.json index 7867f580e..2dea6fa65 100644 --- a/config/schemas/health_mssql.schema.json +++ b/config/schemas/health_mssql.schema.json @@ -38,6 +38,9 @@ "serviceAccount": { "type": "string" }, + "helmRef": { + "$ref": "#/$defs/HelmRefKeySelector" + }, "configMapKeyRef": { "$ref": "#/$defs/ConfigMapKeySelector" }, @@ -48,6 +51,21 @@ "additionalProperties": false, "type": "object" }, + "HelmRefKeySelector": { + "properties": { + "name": { + "type": "string" + }, + "key": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "key" + ] + }, "Labels": { "patternProperties": { ".*": { diff --git a/config/schemas/health_mysql.schema.json b/config/schemas/health_mysql.schema.json index b14635df7..d5b830b8d 100644 --- a/config/schemas/health_mysql.schema.json +++ b/config/schemas/health_mysql.schema.json @@ -38,6 +38,9 @@ "serviceAccount": { "type": "string" }, + "helmRef": { + "$ref": "#/$defs/HelmRefKeySelector" + }, "configMapKeyRef": { "$ref": "#/$defs/ConfigMapKeySelector" }, @@ -48,6 +51,21 @@ "additionalProperties": false, "type": "object" }, + "HelmRefKeySelector": { + "properties": { + "name": { + "type": "string" + }, + "key": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "key" + ] + }, "Labels": { "patternProperties": { ".*": { diff --git a/config/schemas/health_opensearch.schema.json b/config/schemas/health_opensearch.schema.json index 656affaa3..c92b01495 100644 --- a/config/schemas/health_opensearch.schema.json +++ b/config/schemas/health_opensearch.schema.json @@ -38,6 +38,9 @@ "serviceAccount": { "type": "string" }, + "helmRef": { + "$ref": "#/$defs/HelmRefKeySelector" + }, "configMapKeyRef": { "$ref": "#/$defs/ConfigMapKeySelector" }, @@ -48,6 +51,21 @@ "additionalProperties": false, "type": "object" }, + "HelmRefKeySelector": { + "properties": { + "name": { + "type": "string" + }, + "key": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "key" + ] + }, "Labels": { "patternProperties": { ".*": { diff --git a/config/schemas/health_postgres.schema.json b/config/schemas/health_postgres.schema.json index 42e21f6e7..d12944118 100644 --- a/config/schemas/health_postgres.schema.json +++ b/config/schemas/health_postgres.schema.json @@ -38,6 +38,9 @@ "serviceAccount": { "type": "string" }, + "helmRef": { + "$ref": "#/$defs/HelmRefKeySelector" + }, "configMapKeyRef": { "$ref": "#/$defs/ConfigMapKeySelector" }, @@ -48,6 +51,21 @@ "additionalProperties": false, "type": "object" }, + "HelmRefKeySelector": { + "properties": { + "name": { + "type": "string" + }, + "key": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "key" + ] + }, "Labels": { "patternProperties": { ".*": { diff --git a/config/schemas/health_prometheus.schema.json b/config/schemas/health_prometheus.schema.json index 3ae607f12..e488539de 100644 --- a/config/schemas/health_prometheus.schema.json +++ b/config/schemas/health_prometheus.schema.json @@ -38,6 +38,9 @@ "serviceAccount": { "type": "string" }, + "helmRef": { + "$ref": "#/$defs/HelmRefKeySelector" + }, "configMapKeyRef": { "$ref": "#/$defs/ConfigMapKeySelector" }, @@ -48,6 +51,21 @@ "additionalProperties": false, "type": "object" }, + "HelmRefKeySelector": { + "properties": { + "name": { + "type": "string" + }, + "key": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "key" + ] + }, "Labels": { "patternProperties": { ".*": { diff --git a/config/schemas/health_redis.schema.json b/config/schemas/health_redis.schema.json index 719a4697e..8310fef33 100644 --- a/config/schemas/health_redis.schema.json +++ b/config/schemas/health_redis.schema.json @@ -38,6 +38,9 @@ "serviceAccount": { "type": "string" }, + "helmRef": { + "$ref": "#/$defs/HelmRefKeySelector" + }, "configMapKeyRef": { "$ref": "#/$defs/ConfigMapKeySelector" }, @@ -48,6 +51,21 @@ "additionalProperties": false, "type": "object" }, + "HelmRefKeySelector": { + "properties": { + "name": { + "type": "string" + }, + "key": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "key" + ] + }, "Labels": { "patternProperties": { ".*": { diff --git a/config/schemas/health_restic.schema.json b/config/schemas/health_restic.schema.json index aa0ccaaaf..12990d737 100644 --- a/config/schemas/health_restic.schema.json +++ b/config/schemas/health_restic.schema.json @@ -38,6 +38,9 @@ "serviceAccount": { "type": "string" }, + "helmRef": { + "$ref": "#/$defs/HelmRefKeySelector" + }, "configMapKeyRef": { "$ref": "#/$defs/ConfigMapKeySelector" }, @@ -48,6 +51,21 @@ "additionalProperties": false, "type": "object" }, + "HelmRefKeySelector": { + "properties": { + "name": { + "type": "string" + }, + "key": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "key" + ] + }, "Labels": { "patternProperties": { ".*": { diff --git a/config/schemas/health_s3.schema.json b/config/schemas/health_s3.schema.json index e912569dc..96232322c 100644 --- a/config/schemas/health_s3.schema.json +++ b/config/schemas/health_s3.schema.json @@ -38,6 +38,9 @@ "serviceAccount": { "type": "string" }, + "helmRef": { + "$ref": "#/$defs/HelmRefKeySelector" + }, "configMapKeyRef": { "$ref": "#/$defs/ConfigMapKeySelector" }, @@ -48,6 +51,21 @@ "additionalProperties": false, "type": "object" }, + "HelmRefKeySelector": { + "properties": { + "name": { + "type": "string" + }, + "key": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "key" + ] + }, "Labels": { "patternProperties": { ".*": { diff --git a/config/schemas/health_webhook.schema.json b/config/schemas/health_webhook.schema.json index f47f3376d..5f4f73d2d 100644 --- a/config/schemas/health_webhook.schema.json +++ b/config/schemas/health_webhook.schema.json @@ -38,6 +38,9 @@ "serviceAccount": { "type": "string" }, + "helmRef": { + "$ref": "#/$defs/HelmRefKeySelector" + }, "configMapKeyRef": { "$ref": "#/$defs/ConfigMapKeySelector" }, @@ -48,6 +51,21 @@ "additionalProperties": false, "type": "object" }, + "HelmRefKeySelector": { + "properties": { + "name": { + "type": "string" + }, + "key": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "key" + ] + }, "Labels": { "patternProperties": { ".*": { diff --git a/config/schemas/topology.schema.json b/config/schemas/topology.schema.json index e2ebcf441..255ab572c 100644 --- a/config/schemas/topology.schema.json +++ b/config/schemas/topology.schema.json @@ -1580,6 +1580,9 @@ "serviceAccount": { "type": "string" }, + "helmRef": { + "$ref": "#/$defs/HelmRefKeySelector" + }, "configMapKeyRef": { "$ref": "#/$defs/ConfigMapKeySelector" }, @@ -2076,6 +2079,21 @@ "name" ] }, + "HelmRefKeySelector": { + "properties": { + "name": { + "type": "string" + }, + "key": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "key" + ] + }, "ICMPCheck": { "properties": { "description": { diff --git a/hack/generate-schemas/.gitignore b/hack/generate-schemas/.gitignore new file mode 100644 index 000000000..6db33941e --- /dev/null +++ b/hack/generate-schemas/.gitignore @@ -0,0 +1,2 @@ +go.mod +go.sum diff --git a/hack/generate-schemas/go.mod b/hack/generate-schemas/go.mod index f68f57863..34381f066 100644 --- a/hack/generate-schemas/go.mod +++ b/hack/generate-schemas/go.mod @@ -31,6 +31,7 @@ require ( github.com/AlekSi/pointer v1.2.0 // indirect github.com/Masterminds/goutils v1.1.1 // indirect github.com/Masterminds/semver/v3 v3.2.1 // indirect + github.com/RaveNoX/go-jsonmerge v1.0.0 // indirect github.com/TomOnTime/utfutil v0.0.0-20230223141146-125e65197b36 // indirect github.com/agext/levenshtein v1.2.3 // indirect github.com/antlr4-go/antlr/v4 v4.13.0 // indirect @@ -42,7 +43,7 @@ require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/dustin/go-humanize v1.0.1 // indirect github.com/evanphx/json-patch v5.7.0+incompatible // indirect - github.com/flanksource/duty v1.0.236 // indirect + github.com/flanksource/duty v1.0.245 // indirect github.com/flanksource/is-healthy v0.0.0-20231003215854-76c51e3a3ff7 // indirect github.com/flanksource/kommons v0.31.4 // indirect github.com/ghodss/yaml v1.0.0 // indirect diff --git a/hack/generate-schemas/go.sum b/hack/generate-schemas/go.sum index a6d480bf3..01af2f12d 100644 --- a/hack/generate-schemas/go.sum +++ b/hack/generate-schemas/go.sum @@ -621,6 +621,9 @@ github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb0 github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= +github.com/RaveNoX/go-jsoncommentstrip v1.0.0/go.mod h1:78ihd09MekBnJnxpICcwzCMzGrKSKYe4AqU6PDYYpjk= +github.com/RaveNoX/go-jsonmerge v1.0.0 h1:2e0nqnadoGUP8rAvcA0hkQelZreVO5X3BHomT2XMrAk= +github.com/RaveNoX/go-jsonmerge v1.0.0/go.mod h1:qYM/NA77LhO4h51JJM7Z+xBU3ovqrNIACZe+SkSNVFo= github.com/TomOnTime/utfutil v0.0.0-20230223141146-125e65197b36 h1:vfVc5pSCq58ljNpXXwUcLnHATYi/x+YUdqFc9uBhLbM= github.com/TomOnTime/utfutil v0.0.0-20230223141146-125e65197b36/go.mod h1:MwE/QxFCN65F0hKGWFHUh2U2o1p2tMPNR1zHkX6vEh8= github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= @@ -649,6 +652,7 @@ github.com/aws/aws-sdk-go v1.48.15 h1:Gad2C4pLzuZDd5CA0Rvkfko6qUDDTOYru145gkO7w/ github.com/aws/aws-sdk-go v1.48.15/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d h1:xDfNPAt8lFiC1UJrqV3uuy861HCTo708pDMbjHHdCas= github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ00z/TKoufEY6K/a0k6AhaJrQKdFe6OfVXsa4= +github.com/bmatcuk/doublestar v1.1.1/go.mod h1:UD6OnuiIn0yFxxA2le/rnRU1G4RaI4UvFv1sNto9p6w= github.com/boombuler/barcode v1.0.0/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8= github.com/boombuler/barcode v1.0.1/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8= github.com/c2h5oh/datasize v0.0.0-20220606134207-859f65c6625b h1:6+ZFm0flnudZzdSE0JxlhR2hKnGPcNB35BjQf4RYQDY= @@ -711,8 +715,8 @@ github.com/evanphx/json-patch v5.7.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLi github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/flanksource/commons v1.19.2 h1:6JAnKzBBk5iUROrR79dm7Bzbg9beAiFTehkTeZyI2/g= github.com/flanksource/commons v1.19.2/go.mod h1:k+3B7McXUOS+TirYFR9h0pPk6mHNG3dqVUEY9gKI3/U= -github.com/flanksource/duty v1.0.236 h1:7+X0T9JFgM9U1cnd63jVLuxhpWsmQKpd+KQxWeuC8fI= -github.com/flanksource/duty v1.0.236/go.mod h1:6JdeVPo9aKq/nowsP60CTHQxe+oUPu6maMbusIApB8o= +github.com/flanksource/duty v1.0.245 h1:tfyrbQ//WFxni6lFQKuYNbPgoPvzKOU/0fBh0pXCp2g= +github.com/flanksource/duty v1.0.245/go.mod h1:nhvoArC48DByxrRvvcCKwRfbAfn9wUbo4YWietT9t7I= github.com/flanksource/gomplate/v3 v3.20.4/go.mod h1:27BNWhzzSjDed1z8YShO6W+z6G9oZXuxfNFGd/iGSdc= github.com/flanksource/gomplate/v3 v3.20.26 h1:85lUzlKgZjb1uIkzoa4zN03OcdOnFPG+oWxshZTYqz4= github.com/flanksource/gomplate/v3 v3.20.26/go.mod h1:GKmptFMdr2LbOuqwQZrmo9a/UygyZ0pbXffks8MuYhE= @@ -976,6 +980,7 @@ github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnr github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= +github.com/juju/gnuflag v0.0.0-20171113085948-2ce1bb71843d/go.mod h1:2PavIy+JPciBPrBUjwbNvtwB6RQlve+hkpll6QSNmOE= github.com/jung-kurt/gofpdf v1.0.0/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes= github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes= github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8= @@ -1105,6 +1110,7 @@ github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUz github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ruudk/golang-pdf417 v0.0.0-20181029194003-1af4ab5afa58/go.mod h1:6lfFZQK844Gfx8o5WFuvpxWRwnSoipWe/p622j1v06w= github.com/ruudk/golang-pdf417 v0.0.0-20201230142125-a7e3863a1245/go.mod h1:pQAZKsJ8yyVxGRWYNEm9oFB8ieLgKFnamEyDmSA0BRk= +github.com/samber/lo v1.39.0 h1:4gTz1wUhNYLhFSKl6O+8peW0v2F4BCY034GRpU9WnuA= github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8= github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I= github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= @@ -1118,6 +1124,7 @@ github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0= github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/spkg/bom v0.0.0-20160624110644-59b7046e48ad/go.mod h1:qLr4V1qq6nMqFKkMo8ZTx3f+BZEkzsRUY10Xsm2mwU0= github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8= github.com/stoewer/go-strcase v1.3.0 h1:g0eASXYtp+yvN9fK8sH94oCIk0fau9uV1/ZdJ0AVEzs= github.com/stoewer/go-strcase v1.3.0/go.mod h1:fAH5hQ5pehh+j3nZfvwdk2RgEgQjAoM8wodgtPmh1xo= diff --git a/pkg/db/check_statuses.go b/pkg/db/check_statuses.go index 186adcfc9..1d6c54a5d 100644 --- a/pkg/db/check_statuses.go +++ b/pkg/db/check_statuses.go @@ -16,6 +16,7 @@ var RefreshCheckStatusSummary = job.Job{ Name: "RefreshCheckStatusSummary", Singleton: true, Timeout: 1 * time.Minute, + Schedule: "@every 1m", JobHistory: true, Fn: func(ctx job.JobRuntime) error { ctx.History.ResourceType = CheckStatuses @@ -26,6 +27,7 @@ var RefreshCheckStatusSummary = job.Job{ var RefreshCheckStatusSummaryAged = job.Job{ Name: "RefreshCheckStatusSummaryAged", Timeout: 60 * time.Minute, + Schedule: "@every 1h", Singleton: true, JobHistory: true, Fn: func(ctx job.JobRuntime) error { From 3185c6be6cbb5792f22c174e3da491ba265199c2 Mon Sep 17 00:00:00 2001 From: Moshe Immerman Date: Wed, 20 Dec 2023 22:01:22 +0200 Subject: [PATCH 5/6] chore: regen manifests --- config/deploy/crd.yaml | 1 + config/deploy/manifests.yaml | 740 +++++++++++++++++++++++++++++++++++ 2 files changed, 741 insertions(+) diff --git a/config/deploy/crd.yaml b/config/deploy/crd.yaml index 8442b746a..fabd98b62 100644 --- a/config/deploy/crd.yaml +++ b/config/deploy/crd.yaml @@ -1,3 +1,4 @@ +--- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: diff --git a/config/deploy/manifests.yaml b/config/deploy/manifests.yaml index fca550e14..79b7a61e8 100644 --- a/config/deploy/manifests.yaml +++ b/config/deploy/manifests.yaml @@ -153,6 +153,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -306,6 +316,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -344,6 +364,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -442,6 +472,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -473,6 +513,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -543,6 +593,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -652,6 +712,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -683,6 +753,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -813,6 +893,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -894,6 +984,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -996,6 +1096,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -1027,6 +1137,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -1188,6 +1308,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -1219,6 +1349,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -1391,6 +1531,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -1578,6 +1728,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -1609,6 +1769,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -1703,6 +1873,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -1734,6 +1914,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -1821,6 +2011,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -1943,6 +2143,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -2040,6 +2250,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -2073,6 +2293,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -2184,6 +2414,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -2247,6 +2487,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -2352,6 +2602,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -2388,6 +2648,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -2421,6 +2691,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -2457,6 +2737,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -2498,6 +2788,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -2529,6 +2829,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -2569,6 +2879,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -2600,6 +2920,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -2641,6 +2971,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -2692,6 +3032,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -2804,6 +3154,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -2845,6 +3205,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -2876,6 +3246,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -2948,6 +3328,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -3049,6 +3439,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -3083,6 +3483,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -3125,6 +3535,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -3159,6 +3579,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -3243,6 +3673,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -3351,6 +3791,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -3382,6 +3832,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -3497,6 +3957,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -3531,6 +4001,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -3628,6 +4108,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -3712,6 +4202,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -3828,6 +4328,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -4187,6 +4697,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -4228,6 +4748,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -4312,6 +4842,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -4349,6 +4889,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -4443,6 +4993,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -4507,6 +5067,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -4601,6 +5171,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -4665,6 +5245,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -4865,6 +5455,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -4929,6 +5529,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -5123,6 +5733,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -5187,6 +5807,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -5284,6 +5914,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -5346,6 +5986,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -5435,6 +6085,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -5472,6 +6132,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -5514,6 +6184,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -5603,6 +6283,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -5638,6 +6328,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -5684,6 +6384,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -5769,6 +6479,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -5800,6 +6520,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: @@ -5973,6 +6703,16 @@ spec: required: - key type: object + helmRef: + properties: + key: + description: Key is a JSONPath expression used to fetch the key from the merged JSON. + type: string + name: + type: string + required: + - key + type: object secretKeyRef: properties: key: From 379e581196c549a98c866ead3b43abdb8effe13b Mon Sep 17 00:00:00 2001 From: Moshe Immerman Date: Wed, 20 Dec 2023 22:23:22 +0200 Subject: [PATCH 6/6] chore: fix operator tests --- test/e2e-operator.sh | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/test/e2e-operator.sh b/test/e2e-operator.sh index 8ec15f3e3..5db73a9b5 100755 --- a/test/e2e-operator.sh +++ b/test/e2e-operator.sh @@ -57,21 +57,18 @@ echo "Server is ready now" i=0 while [ $i -lt 5 ] do - go run main.go push http://0.0.0.0:8080 --name abc --description a --type junit --duration 10 --message "10 of 10 passed" + go run main.go push http://0.0.0.0:8080 --name abc$i --description a --type junit --duration 10 --message "10 of 10 passed" i=$((i+1)) done CANARY_COUNT=$(kubectl get canaries.canaries.flanksource.com -A --no-headers | wc -l) CANARY_COUNT=$(echo "$CANARY_COUNT" | xargs) -STATUS_COUNT_POSTGRES=$(curl -s http://0.0.0.0:8080/api\?count\=4 | jq ."checks[0].checkStatuses | length") -STATUS_COUNT_MEMORY=$(curl -s http://0.0.0.0:8080/api | jq ."checks[0].checkStatuses | length") - +STATUS_COUNT_POSTGRES=$(curl -s http://0.0.0.0:8080/api/summary | jq ".checks_summary | length") echo "Canary count: ${CANARY_COUNT}" echo "Postgres count: ${STATUS_COUNT_POSTGRES}" -echo "Memory count: ${STATUS_COUNT_MEMORY}" if [ "${CANARY_COUNT}" -gt 0 ]; then @@ -79,12 +76,6 @@ if [ "${CANARY_COUNT}" -gt 0 ]; then exit 1 fi -if [ "${STATUS_COUNT_MEMORY}" -gt 1 ]; then - echo "Status in memory should not be greater than 1" - sudo kill -9 $PROC_ID || : - exit 1 -fi - if [ "${STATUS_COUNT_POSTGRES}" -ge 4 ]; then sudo kill -9 $PROC_ID || : echo "::endgroup::"