diff --git a/api/v1/zz_generated.deepcopy.go b/api/v1/zz_generated.deepcopy.go index c716b68c1..9d1ce1033 100644 --- a/api/v1/zz_generated.deepcopy.go +++ b/api/v1/zz_generated.deepcopy.go @@ -885,7 +885,7 @@ func (in *Component) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ComponentCheck) DeepCopyInto(out *ComponentCheck) { *out = *in - out.Selector = in.Selector + in.Selector.DeepCopyInto(&out.Selector) if in.Inline != nil { in, out := &in.Inline, &out.Inline *out = new(CanarySpec) @@ -1002,7 +1002,9 @@ func (in *ComponentSpec) DeepCopyInto(out *ComponentSpec) { if in.Selectors != nil { in, out := &in.Selectors, &out.Selectors *out = make(types.ResourceSelectors, len(*in)) - copy(*out, *in) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } } if in.ComponentChecks != nil { in, out := &in.ComponentChecks, &out.ComponentChecks @@ -1102,7 +1104,9 @@ func (in *ComponentSpecObject) DeepCopyInto(out *ComponentSpecObject) { if in.Selectors != nil { in, out := &in.Selectors, &out.Selectors *out = make(types.ResourceSelectors, len(*in)) - copy(*out, *in) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } } if in.ComponentChecks != nil { in, out := &in.ComponentChecks, &out.ComponentChecks @@ -1841,7 +1845,9 @@ func (in *ForEach) DeepCopyInto(out *ForEach) { if in.Selectors != nil { in, out := &in.Selectors, &out.Selectors *out = make(types.ResourceSelectors, len(*in)) - copy(*out, *in) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } } if in.Relationships != nil { in, out := &in.Relationships, &out.Relationships diff --git a/config/deploy/crd.yaml b/config/deploy/crd.yaml index f800665d2..ae20ffda6 100644 --- a/config/deploy/crd.yaml +++ b/config/deploy/crd.yaml @@ -7222,12 +7222,30 @@ spec: description: Lookup and associcate other components with this component items: properties: + agent: + description: Agent can be the agent id or the name of the agent. Additionally, the special "self" value can be used to select resources without an agent. + type: string + cache: + description: Cache directives 'no-cache' (should not fetch from cache but can be cached) 'no-store' (should not cache) 'max-age=X' (cache for X duration) + type: string fieldSelector: type: string + id: + type: string labelSelector: type: string name: type: string + namespace: + type: string + statuses: + items: + type: string + type: array + types: + items: + type: string + type: array type: object type: array summary: @@ -7314,12 +7332,30 @@ spec: x-kubernetes-preserve-unknown-fields: true selector: properties: + agent: + description: Agent can be the agent id or the name of the agent. Additionally, the special "self" value can be used to select resources without an agent. + type: string + cache: + description: Cache directives 'no-cache' (should not fetch from cache but can be cached) 'no-store' (should not cache) 'max-age=X' (cache for X duration) + type: string fieldSelector: type: string + id: + type: string labelSelector: type: string name: type: string + namespace: + type: string + statuses: + items: + type: string + type: array + types: + items: + type: string + type: array type: object type: object type: array @@ -7545,12 +7581,30 @@ spec: description: Lookup and associcate other components with this component items: properties: + agent: + description: Agent can be the agent id or the name of the agent. Additionally, the special "self" value can be used to select resources without an agent. + type: string + cache: + description: Cache directives 'no-cache' (should not fetch from cache but can be cached) 'no-store' (should not cache) 'max-age=X' (cache for X duration) + type: string fieldSelector: type: string + id: + type: string labelSelector: type: string name: type: string + namespace: + type: string + statuses: + items: + type: string + type: array + types: + items: + type: string + type: array type: object type: array summary: diff --git a/config/deploy/manifests.yaml b/config/deploy/manifests.yaml index 19930db03..ba33927e4 100644 --- a/config/deploy/manifests.yaml +++ b/config/deploy/manifests.yaml @@ -7490,12 +7490,30 @@ spec: description: Lookup and associcate other components with this component items: properties: + agent: + description: Agent can be the agent id or the name of the agent. Additionally, the special "self" value can be used to select resources without an agent. + type: string + cache: + description: Cache directives 'no-cache' (should not fetch from cache but can be cached) 'no-store' (should not cache) 'max-age=X' (cache for X duration) + type: string fieldSelector: type: string + id: + type: string labelSelector: type: string name: type: string + namespace: + type: string + statuses: + items: + type: string + type: array + types: + items: + type: string + type: array type: object type: array summary: @@ -7582,12 +7600,30 @@ spec: x-kubernetes-preserve-unknown-fields: true selector: properties: + agent: + description: Agent can be the agent id or the name of the agent. Additionally, the special "self" value can be used to select resources without an agent. + type: string + cache: + description: Cache directives 'no-cache' (should not fetch from cache but can be cached) 'no-store' (should not cache) 'max-age=X' (cache for X duration) + type: string fieldSelector: type: string + id: + type: string labelSelector: type: string name: type: string + namespace: + type: string + statuses: + items: + type: string + type: array + types: + items: + type: string + type: array type: object type: object type: array @@ -7813,12 +7849,30 @@ spec: description: Lookup and associcate other components with this component items: properties: + agent: + description: Agent can be the agent id or the name of the agent. Additionally, the special "self" value can be used to select resources without an agent. + type: string + cache: + description: Cache directives 'no-cache' (should not fetch from cache but can be cached) 'no-store' (should not cache) 'max-age=X' (cache for X duration) + type: string fieldSelector: type: string + id: + type: string labelSelector: type: string name: type: string + namespace: + type: string + statuses: + items: + type: string + type: array + types: + items: + type: string + type: array type: object type: array summary: diff --git a/go.mod b/go.mod index 5626944ec..1b77ec3c8 100644 --- a/go.mod +++ b/go.mod @@ -22,7 +22,7 @@ require ( github.com/fergusstrange/embedded-postgres v1.25.0 github.com/flanksource/artifacts v1.0.4 github.com/flanksource/commons v1.22.0 - github.com/flanksource/duty v1.0.319 + github.com/flanksource/duty v1.0.330 github.com/flanksource/gomplate/v3 v3.21.0 github.com/flanksource/is-healthy v0.0.0-20231003215854-76c51e3a3ff7 github.com/flanksource/kommons v0.31.4 @@ -68,7 +68,7 @@ require ( go.opentelemetry.io/contrib/instrumentation/github.com/labstack/echo/otelecho v0.47.0 go.opentelemetry.io/otel v1.22.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.22.0 - go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.21.0 + go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.22.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.22.0 go.opentelemetry.io/otel/sdk v1.22.0 go.opentelemetry.io/otel/trace v1.22.0 @@ -298,3 +298,5 @@ require ( sigs.k8s.io/kustomize/kyaml v0.16.0 // indirect sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect ) + +// replace github.com/flanksource/duty => ../duty diff --git a/go.sum b/go.sum index 5d2cab0a2..e68f4fa4a 100644 --- a/go.sum +++ b/go.sum @@ -846,8 +846,8 @@ github.com/flanksource/artifacts v1.0.4 h1:KjQTwsvQ73uHqTK7o4Jwt/RW8fyxJOTJ6JLgz github.com/flanksource/artifacts v1.0.4/go.mod h1:wkbdseaTkDo4Q6k6T86vXd4Uy47M6NPCmexgHvCTDl0= github.com/flanksource/commons v1.22.0 h1:LI839ZOVJ6qrNuGKqb6Z4JyIxFHXGhfDxJbXUj5VimQ= github.com/flanksource/commons v1.22.0/go.mod h1:GD5+yGvmYFPIW3WMNN+y1JkeDMJY74e05pQAsRbrvwY= -github.com/flanksource/duty v1.0.319 h1:ZgUXQIlQoODdgTSucqAHD77HU+hrxErAXBcIIPABxno= -github.com/flanksource/duty v1.0.319/go.mod h1:AAggGtbh47so9VVgjhbmceNAPSlLik9VZoC06pACNpU= +github.com/flanksource/duty v1.0.330 h1:8qqDuCGJ4H5MgXhSLb+MrS4MRllY568sIUmMq+UdrmI= +github.com/flanksource/duty v1.0.330/go.mod h1:j4VZ/QzD79eSuOsfNCOZ0kWaeFiSP6GSFNV9vxRH4Rs= github.com/flanksource/gomplate/v3 v3.20.4/go.mod h1:27BNWhzzSjDed1z8YShO6W+z6G9oZXuxfNFGd/iGSdc= github.com/flanksource/gomplate/v3 v3.21.0 h1:HbgJ7GCv2fGjjKhGBBtMmo+uA9T6pI9FVm+M/eEurOA= github.com/flanksource/gomplate/v3 v3.21.0/go.mod h1:m2WVc04GMVBOcZhtDaz/LTtrVWKejeJhFM1Jy/h9VZQ= @@ -1607,8 +1607,8 @@ go.opentelemetry.io/otel v1.22.0 h1:xS7Ku+7yTFvDfDraDIJVpw7XPyuHlB9MCiqqX5mcJ6Y= go.opentelemetry.io/otel v1.22.0/go.mod h1:eoV4iAi3Ea8LkAEI9+GFT44O6T/D0GWAVFyZVCC6pMI= go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.22.0 h1:9M3+rhx7kZCIQQhQRYaZCdNu1V73tm4TvXs2ntl98C4= go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.22.0/go.mod h1:noq80iT8rrHP1SfybmPiRGc9dc5M8RPmGvtwo7Oo7tc= -go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.21.0 h1:tIqheXEFWAZ7O8A7m+J0aPTmpJN3YQ7qetUAdkkkKpk= -go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.21.0/go.mod h1:nUeKExfxAQVbiVFn32YXpXZZHZ61Cc3s3Rn1pDBGAb0= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.22.0 h1:H2JFgRcGiyHg7H7bwcwaQJYrNFqCqrbTQ8K4p1OvDu8= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.22.0/go.mod h1:WfCWp1bGoYK8MeULtI15MmQVczfR+bFkk0DF3h06QmQ= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.22.0 h1:FyjCyI9jVEfqhUh2MoSkmolPjfh5fp2hnV0b0irxH4Q= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.22.0/go.mod h1:hYwym2nDEeZfG/motx0p7L7J1N1vyzIThemQsb4g2qY= go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.21.0 h1:VhlEQAPp9R1ktYfrPk5SOryw1e9LDDTZCbIPFrho0ec= diff --git a/hack/generate-schemas/go.mod b/hack/generate-schemas/go.mod index 5f0b637e6..68f5d303b 100644 --- a/hack/generate-schemas/go.mod +++ b/hack/generate-schemas/go.mod @@ -41,6 +41,7 @@ require ( github.com/beorn7/perks v1.0.1 // indirect github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect github.com/c2h5oh/datasize v0.0.0-20231215233829-aa82cc1e6500 // indirect + github.com/cenkalti/backoff/v4 v4.2.1 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/eko/gocache/lib/v4 v4.1.5 // indirect @@ -48,7 +49,7 @@ require ( github.com/evanphx/json-patch v5.7.0+incompatible // indirect github.com/exaring/otelpgx v0.5.2 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect - github.com/flanksource/duty v1.0.319 // indirect + github.com/flanksource/duty v1.0.330 // indirect github.com/flanksource/is-healthy v0.0.0-20231003215854-76c51e3a3ff7 // indirect github.com/flanksource/kommons v0.31.4 // indirect github.com/flanksource/postq v1.0.0 // indirect @@ -76,6 +77,7 @@ require ( github.com/googleapis/gax-go/v2 v2.12.0 // indirect github.com/gosimple/slug v1.13.1 // indirect github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 // indirect + github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.0 // indirect github.com/hairyhenderson/toml v0.4.2-0.20210923231440-40456b8e66cf // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect github.com/hashicorp/go-getter v1.7.3 // indirect @@ -137,8 +139,13 @@ require ( go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.1 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.22.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.22.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.22.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.22.0 // indirect go.opentelemetry.io/otel/metric v1.22.0 // indirect + go.opentelemetry.io/otel/sdk v1.22.0 // indirect go.opentelemetry.io/otel/trace v1.22.0 // indirect + go.opentelemetry.io/proto/otlp v1.0.0 // indirect go.starlark.net v0.0.0-20231121155337-90ade8b19d09 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.26.0 // indirect diff --git a/hack/generate-schemas/go.sum b/hack/generate-schemas/go.sum index 72e0a3079..96a848f25 100644 --- a/hack/generate-schemas/go.sum +++ b/hack/generate-schemas/go.sum @@ -659,6 +659,8 @@ github.com/boombuler/barcode v1.0.0/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl github.com/boombuler/barcode v1.0.1/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8= github.com/c2h5oh/datasize v0.0.0-20231215233829-aa82cc1e6500 h1:6lhrsTEnloDPXyeZBvSYvQf8u86jbKehZPVDDlkgDl4= github.com/c2h5oh/datasize v0.0.0-20231215233829-aa82cc1e6500/go.mod h1:S/7n9copUssQ56c7aAgHqftWO4LTf4xY6CGWt8Bc+3M= +github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM= +github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/census-instrumentation/opencensus-proto v0.3.0/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/census-instrumentation/opencensus-proto v0.4.1/go.mod h1:4T9NM4+4Vw91VeyqjLS6ao50K5bOcLKN6Q42XnYaRYw= @@ -726,8 +728,8 @@ github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2 github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/flanksource/commons v1.22.0 h1:LI839ZOVJ6qrNuGKqb6Z4JyIxFHXGhfDxJbXUj5VimQ= github.com/flanksource/commons v1.22.0/go.mod h1:GD5+yGvmYFPIW3WMNN+y1JkeDMJY74e05pQAsRbrvwY= -github.com/flanksource/duty v1.0.319 h1:ZgUXQIlQoODdgTSucqAHD77HU+hrxErAXBcIIPABxno= -github.com/flanksource/duty v1.0.319/go.mod h1:AAggGtbh47so9VVgjhbmceNAPSlLik9VZoC06pACNpU= +github.com/flanksource/duty v1.0.330 h1:8qqDuCGJ4H5MgXhSLb+MrS4MRllY568sIUmMq+UdrmI= +github.com/flanksource/duty v1.0.330/go.mod h1:j4VZ/QzD79eSuOsfNCOZ0kWaeFiSP6GSFNV9vxRH4Rs= github.com/flanksource/gomplate/v3 v3.20.4/go.mod h1:27BNWhzzSjDed1z8YShO6W+z6G9oZXuxfNFGd/iGSdc= github.com/flanksource/gomplate/v3 v3.21.0 h1:HbgJ7GCv2fGjjKhGBBtMmo+uA9T6pI9FVm+M/eEurOA= github.com/flanksource/gomplate/v3 v3.21.0/go.mod h1:m2WVc04GMVBOcZhtDaz/LTtrVWKejeJhFM1Jy/h9VZQ= @@ -795,6 +797,7 @@ github.com/golang-sql/sqlexp v0.1.0 h1:ZCD6MBpcuOVfGVqsEmY5/4FtYiKz6tSyUv9LPEDei github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4= +github.com/golang/glog v1.1.2 h1:DVjP2PbBOzHyzA+dn3WhHIq4NdVu3Q+pvivFICf/7fo= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -929,6 +932,8 @@ github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79/go.mod h1:Fecb 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= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.0 h1:RtRsiaGvWxcwd8y3BiRZxsylPT8hLWZ5SPcfI+3IDNk= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.0/go.mod h1:TzP6duP4Py2pHLVPPQp42aoYI92+PCrVotyR5e8Vqlk= github.com/hairyhenderson/toml v0.4.2-0.20210923231440-40456b8e66cf h1:I1sbT4ZbIt9i+hB1zfKw2mE8C12TuGxPiW7YmtLbPa4= 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= @@ -1211,14 +1216,23 @@ go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 h1:aFJWCqJ go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1/go.mod h1:sEGXWArGqc3tVa+ekntsN65DmVbVeW+7lTKTjZF3/Fo= go.opentelemetry.io/otel v1.22.0 h1:xS7Ku+7yTFvDfDraDIJVpw7XPyuHlB9MCiqqX5mcJ6Y= go.opentelemetry.io/otel v1.22.0/go.mod h1:eoV4iAi3Ea8LkAEI9+GFT44O6T/D0GWAVFyZVCC6pMI= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.22.0 h1:9M3+rhx7kZCIQQhQRYaZCdNu1V73tm4TvXs2ntl98C4= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.22.0/go.mod h1:noq80iT8rrHP1SfybmPiRGc9dc5M8RPmGvtwo7Oo7tc= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.22.0 h1:H2JFgRcGiyHg7H7bwcwaQJYrNFqCqrbTQ8K4p1OvDu8= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.22.0/go.mod h1:WfCWp1bGoYK8MeULtI15MmQVczfR+bFkk0DF3h06QmQ= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.22.0 h1:FyjCyI9jVEfqhUh2MoSkmolPjfh5fp2hnV0b0irxH4Q= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.22.0/go.mod h1:hYwym2nDEeZfG/motx0p7L7J1N1vyzIThemQsb4g2qY= go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.21.0 h1:VhlEQAPp9R1ktYfrPk5SOryw1e9LDDTZCbIPFrho0ec= go.opentelemetry.io/otel/metric v1.22.0 h1:lypMQnGyJYeuYPhOM/bgjbFM6WE44W1/T45er4d8Hhg= go.opentelemetry.io/otel/metric v1.22.0/go.mod h1:evJGjVpZv0mQ5QBRJoBF64yMuOf4xCWdXjK8pzFvliY= go.opentelemetry.io/otel/sdk v1.22.0 h1:6coWHw9xw7EfClIC/+O31R8IY3/+EiRFHevmHafB2Gw= +go.opentelemetry.io/otel/sdk v1.22.0/go.mod h1:iu7luyVGYovrRpe2fmj3CVKouQNdTOkxtLzPvPz1DOc= go.opentelemetry.io/otel/trace v1.22.0 h1:Hg6pPujv0XG9QaVbGOBVHunyuLcCC3jN7WEhPx83XD0= go.opentelemetry.io/otel/trace v1.22.0/go.mod h1:RbbHXVqKES9QhzZq/fE5UnOSILqRt40a21sPw2He1xo= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.opentelemetry.io/proto/otlp v0.15.0/go.mod h1:H7XAot3MsfNsj7EXtrA2q5xSNQ10UqI405h3+duxN4U= +go.opentelemetry.io/proto/otlp v1.0.0 h1:T0TX0tmXU8a3CbNXzEKGeU5mIVOdf0oykP+u2lIVU/I= +go.opentelemetry.io/proto/otlp v1.0.0/go.mod h1:Sy6pihPLfYHkr3NkUbEhGHFhINUSI/v80hjKIs5JXpM= go.starlark.net v0.0.0-20231121155337-90ade8b19d09 h1:hzy3LFnSN8kuQK8h9tHl4ndF6UruMj47OqwqsS+/Ai4= go.starlark.net v0.0.0-20231121155337-90ade8b19d09/go.mod h1:LcLNIzVOMp4oV+uusnpk+VU+SzXaJakUuBjoCSWH5dM= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= diff --git a/pkg/db/check_statuses.go b/pkg/db/check_statuses.go index a6037efb6..571bbdafc 100644 --- a/pkg/db/check_statuses.go +++ b/pkg/db/check_statuses.go @@ -8,7 +8,7 @@ import ( const CheckStatuses = "check_statuses" -var RefreshCheckStatusSummary = job.Job{ +var RefreshCheckStatusSummary = &job.Job{ Name: "RefreshCheckStatusSummary", Singleton: true, Timeout: 1 * time.Minute, @@ -26,7 +26,7 @@ var RefreshCheckStatusSummary = job.Job{ }, } -var RefreshCheckStatusSummaryAged = job.Job{ +var RefreshCheckStatusSummaryAged = &job.Job{ Name: "RefreshCheckStatusSummaryAged", Timeout: 60 * time.Minute, Schedule: "@every 1h", @@ -44,7 +44,7 @@ var RefreshCheckStatusSummaryAged = job.Job{ }, } -var DeleteOldCheckStatues = job.Job{ +var DeleteOldCheckStatues = &job.Job{ Name: "DeleteOldCheckStatuses", Singleton: true, JobHistory: true, @@ -57,7 +57,7 @@ var DeleteOldCheckStatues = job.Job{ }, } -var DeleteOldCheckStatues1d = job.Job{ +var DeleteOldCheckStatues1d = &job.Job{ Name: "DeleteOldCheckStatuses1d", Singleton: true, JobHistory: true, @@ -71,7 +71,7 @@ var DeleteOldCheckStatues1d = job.Job{ }, } -var DeleteOldCheckStatues1h = job.Job{ +var DeleteOldCheckStatues1h = &job.Job{ Name: "DeleteOldCheckStatuses1h", Singleton: true, JobHistory: true, @@ -85,7 +85,7 @@ var DeleteOldCheckStatues1h = job.Job{ }, } -var AggregateCheckStatues1d = job.Job{ +var AggregateCheckStatues1d = &job.Job{ Name: "AggregateCheckStatuses1h", Singleton: true, JobHistory: true, @@ -99,7 +99,7 @@ var AggregateCheckStatues1d = job.Job{ }, } -var AggregateCheckStatues1h = job.Job{ +var AggregateCheckStatues1h = &job.Job{ Name: "AggregateCheckStatuses1d", Singleton: true, JobHistory: true, @@ -113,7 +113,7 @@ var AggregateCheckStatues1h = job.Job{ }, } -var CheckStatusJobs = []job.Job{ +var CheckStatusJobs = []*job.Job{ AggregateCheckStatues1d, AggregateCheckStatues1h, DeleteOldCheckStatues, diff --git a/pkg/jobs/canary/sync_upstream.go b/pkg/jobs/canary/sync_upstream.go index 6c2e70245..e2c4e6b22 100644 --- a/pkg/jobs/canary/sync_upstream.go +++ b/pkg/jobs/canary/sync_upstream.go @@ -30,13 +30,13 @@ const ( ResourceTypeUpstream = "upstream" ) -var UpstreamJobs = []job.Job{ +var UpstreamJobs = []*job.Job{ SyncCheckStatuses, PullUpstreamCanaries, ReconcileChecks, } -var ReconcileChecks = job.Job{ +var ReconcileChecks = &job.Job{ Name: "PushChecksToUpstream", JobHistory: true, Singleton: true, @@ -62,7 +62,7 @@ var ReconcileChecks = job.Job{ }, } -var SyncCheckStatuses = job.Job{ +var SyncCheckStatuses = &job.Job{ Name: "SyncCheckStatusesWithUpstream", JobHistory: true, Singleton: true, @@ -79,7 +79,7 @@ var SyncCheckStatuses = job.Job{ } var lastRuntime time.Time -var PullUpstreamCanaries = job.Job{ +var PullUpstreamCanaries = &job.Job{ Name: "PullUpstreamCanaries", JobHistory: true, Singleton: true, diff --git a/pkg/jobs/topology/topology_jobs.go b/pkg/jobs/topology/topology_jobs.go index ce3c21928..66d87389e 100644 --- a/pkg/jobs/topology/topology_jobs.go +++ b/pkg/jobs/topology/topology_jobs.go @@ -49,7 +49,7 @@ func newTopologyJob(ctx context.Context, topology pkg.Topology) { topologyJobs.Store(topology.ID.String(), j) if err := j.AddToScheduler(TopologyScheduler); err != nil { - logger.Errorf("[%s] failed to schedule %v", *j, err) + logger.Errorf("[%s] failed to schedule %v", j.Name, err) } } diff --git a/pkg/system_api.go b/pkg/system_api.go index 48fe0ac09..ae7a1cdf5 100644 --- a/pkg/system_api.go +++ b/pkg/system_api.go @@ -8,6 +8,7 @@ import ( "github.com/flanksource/commons/console" "github.com/flanksource/commons/logger" "github.com/flanksource/commons/utils" + "github.com/flanksource/duty/context" "github.com/flanksource/duty/models" dutyTypes "github.com/flanksource/duty/types" "github.com/google/uuid" @@ -180,8 +181,8 @@ func (component *Component) FindExisting(db *gorm.DB) (*models.Component, error) return &existing, tx.Error } -func (component *Component) GetConfigs(db *gorm.DB) (relationships []models.ConfigComponentRelationship, err error) { - err = db.Where("component_id = ? AND deleted_at IS NULL", component.ID).Find(&relationships).Error +func (component *Component) GetConfigs(ctx context.Context) (relationships []models.ConfigComponentRelationship, err error) { + err = ctx.DB().Where("component_id = ? AND deleted_at IS NULL", component.ID).Find(&relationships).Error return relationships, err } diff --git a/pkg/topology/component_check.go b/pkg/topology/component_check.go index 88c847c40..68b96330f 100644 --- a/pkg/topology/component_check.go +++ b/pkg/topology/component_check.go @@ -14,7 +14,7 @@ import ( "github.com/flanksource/duty/context" "github.com/flanksource/duty/job" "github.com/flanksource/duty/models" - "github.com/flanksource/duty/types" + "github.com/flanksource/duty/query" "github.com/pkg/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -77,7 +77,7 @@ func GetChecksForComponent(ctx context.Context, component *pkg.Component) ([]mod for idx, componentCheck := range component.ComponentChecks { hash := componentCheck.Hash() if componentCheck.Selector.LabelSelector != "" { - checks, err := duty.FindChecks(ctx, types.ResourceSelectors{componentCheck.Selector}, duty.PickColumns("id", "canary_id")) + checks, err := query.FindChecks(ctx, componentCheck.Selector) if err != nil { return nil, err } diff --git a/pkg/topology/component_check_test.go b/pkg/topology/component_check_test.go index 6ef6c7d10..3228fd2c0 100644 --- a/pkg/topology/component_check_test.go +++ b/pkg/topology/component_check_test.go @@ -16,7 +16,6 @@ var _ = ginkgo.Describe("Topology checks", ginkgo.Ordered, func() { Name: "Component", ComponentChecks: []v1.ComponentCheck{{ Selector: types.ResourceSelector{ - Name: "ComponentCheckSelector", LabelSelector: "check-target=api", }, }}, diff --git a/pkg/topology/component_config.go b/pkg/topology/component_config.go index fe656d001..d739ea36c 100644 --- a/pkg/topology/component_config.go +++ b/pkg/topology/component_config.go @@ -5,6 +5,7 @@ import ( "github.com/flanksource/commons/collections" "github.com/flanksource/duty" + "github.com/flanksource/duty/context" "github.com/flanksource/duty/job" "github.com/flanksource/duty/models" "github.com/flanksource/duty/query" @@ -35,7 +36,7 @@ var ComponentConfigRun = &job.Job{ } for _, component := range components { - if err := SyncComponentConfigRelationship(db, component); err != nil { + if err := SyncComponentConfigRelationship(run.Context, component); err != nil { run.History.AddError(fmt.Sprintf("error persisting config relationships: %v", err)) continue } @@ -58,12 +59,12 @@ var ComponentConfigRun = &job.Job{ }, } -func PersistConfigComponentRelationships(db *gorm.DB, rels []models.ConfigComponentRelationship) error { +func PersistConfigComponentRelationships(ctx context.Context, rels []models.ConfigComponentRelationship) error { if len(rels) == 0 { return nil } - return db.Clauses(clause.OnConflict{ + return ctx.DB().Clauses(clause.OnConflict{ Columns: []clause.Column{{Name: "config_id"}, {Name: "component_id"}}, DoUpdates: clause.Assignments(map[string]any{"deleted_at": nil, "updated_at": duty.Now()}), }).Create(&rels).Error @@ -82,12 +83,12 @@ func PersistConfigComponentRelationship(db *gorm.DB, configID, componentID uuid. }).Create(&relationship).Error } -func SyncComponentConfigRelationship(db *gorm.DB, component pkg.Component) error { +func SyncComponentConfigRelationship(ctx context.Context, component pkg.Component) error { if len(component.Configs) == 0 { return nil } - existingRelationships, err := component.GetConfigs(db) + existingRelationships, err := component.GetConfigs(ctx) if err != nil { return errors.Wrapf(err, "error fetching config relationships for component[%s]", component.ID) } @@ -97,10 +98,11 @@ func SyncComponentConfigRelationship(db *gorm.DB, component pkg.Component) error var relationshipsToPersist []models.ConfigComponentRelationship for _, config := range component.Configs { - dbConfigIDs, err := query.FindConfigIDs(db, *config) + dbConfigIDs, err := query.FindConfigIDs(ctx, *config) if err != nil { return errors.Wrap(err, "error fetching config from database") } + for _, dbConfigID := range dbConfigIDs { newConfigsIDs = append(newConfigsIDs, dbConfigID.String()) @@ -115,14 +117,14 @@ func SyncComponentConfigRelationship(db *gorm.DB, component pkg.Component) error } } - if err := PersistConfigComponentRelationships(db, relationshipsToPersist); err != nil { + if err := PersistConfigComponentRelationships(ctx, relationshipsToPersist); err != nil { return errors.Wrapf(err, "error persisting config component relationships for component[%s]", component.ID) } // Take set difference of these child component Ids and delete them configIDsToDelete := utils.SetDifference(existingConfigIDs, newConfigsIDs) if len(configIDsToDelete) > 0 { - if err := db.Table("config_component_relationships"). + if err := ctx.DB().Table("config_component_relationships"). Where("component_id = ? AND config_id IN ?", component.ID, configIDsToDelete). Update("deleted_at", duty.Now()). Error; err != nil { diff --git a/pkg/topology/component_config_test.go b/pkg/topology/component_config_test.go index fe1d441e6..3afc7b76f 100644 --- a/pkg/topology/component_config_test.go +++ b/pkg/topology/component_config_test.go @@ -2,7 +2,7 @@ package topology import ( "github.com/flanksource/canary-checker/pkg" - "github.com/flanksource/duty" + "github.com/flanksource/duty/query" "github.com/flanksource/duty/types" ginkgo "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -36,10 +36,11 @@ var _ = ginkgo.Describe("Topology configs", ginkgo.Ordered, func() { ComponentConfigRun.Run() expectJobToPass(ComponentConfigRun) - cr, err := component.GetConfigs(DefaultContext.DB()) + cr, err := component.GetConfigs(DefaultContext) Expect(err).To(BeNil()) + Expect(len(cr)).Should(BeNumerically(">", 1)) - ci, err := duty.FindCachedConfig(DefaultContext, cr[0].ConfigID.String()) + ci, err := query.GetCachedConfig(DefaultContext, cr[0].ConfigID.String()) Expect(err).To(BeNil()) tags := *ci.Tags diff --git a/pkg/topology/component_relationship.go b/pkg/topology/component_relationship.go index 16974f5f7..db12e3c6e 100644 --- a/pkg/topology/component_relationship.go +++ b/pkg/topology/component_relationship.go @@ -7,6 +7,7 @@ import ( "github.com/flanksource/duty/context" "github.com/flanksource/duty/job" "github.com/flanksource/duty/models" + "github.com/flanksource/duty/query" "github.com/google/uuid" "github.com/pkg/errors" "github.com/samber/lo" @@ -29,7 +30,7 @@ var ComponentRelationshipSync = &job.Job{ for _, component := range components { hash := component.Selectors.Hash() - comps, err := duty.FindComponents(ctx.Context, component.Selectors, duty.PickColumns("id", "path")) + comps, err := query.FindComponents(ctx.Context, component.Selectors...) if err != nil { ctx.History.AddError(fmt.Sprintf("error getting components with selectors: %s. err: %v", component.Selectors, err)) continue diff --git a/pkg/topology/component_relationship_test.go b/pkg/topology/component_relationship_test.go index c49f43695..962f7cd28 100644 --- a/pkg/topology/component_relationship_test.go +++ b/pkg/topology/component_relationship_test.go @@ -40,7 +40,7 @@ var _ = ginkgo.Describe("Topology relationships", ginkgo.Ordered, func() { Selectors: []types.ResourceSelector{ { LabelSelector: "service=payments", - FieldSelector: "type=api", + Types: []string{"api"}, }, }, }, @@ -48,7 +48,8 @@ var _ = ginkgo.Describe("Topology relationships", ginkgo.Ordered, func() { Name: "Component2", Selectors: []types.ResourceSelector{ { - FieldSelector: "type=api,agent_id=all", + Types: []string{"api"}, + Agent: "all", }, }, }, @@ -56,7 +57,7 @@ var _ = ginkgo.Describe("Topology relationships", ginkgo.Ordered, func() { Name: "Component3", Selectors: []types.ResourceSelector{ { - FieldSelector: "type=api", + Types: []string{"api"}, }, }, }, @@ -72,7 +73,7 @@ var _ = ginkgo.Describe("Topology relationships", ginkgo.Ordered, func() { Name: "Component5", Selectors: []types.ResourceSelector{ { - FieldSelector: "agent_id=" + agent.ID.String(), + Agent: agent.ID.String(), }, }, }, @@ -81,7 +82,7 @@ var _ = ginkgo.Describe("Topology relationships", ginkgo.Ordered, func() { Selectors: []types.ResourceSelector{ { LabelSelector: "service=payments", - FieldSelector: "type=api", + Types: []string{"api"}, }, { LabelSelector: "service=logistics", @@ -200,33 +201,37 @@ var _ = ginkgo.Describe("Topology relationships", ginkgo.Ordered, func() { err := DefaultContext.DB().Delete(&childrenComponents[2]).Error Expect(err).To(BeNil()) + cleanupQueryCache() + ComponentRelationshipSync.Run() expectJobToPass(ComponentRelationshipSync) relationships, err := parentComponents.Find("Component").GetChildren(DefaultContext.DB()) Expect(err).To(BeNil()) - // Only child 1 should be present - Expect(len(relationships)).To(Equal(1)) + Expect(len(relationships)).To(Equal(1), "Only child 1 should be present") err = DefaultContext.DB().Create(&childrenComponents[2]).Error Expect(err).To(BeNil()) + cleanupQueryCache() + ComponentRelationshipSync.Run() expectJobToPass(ComponentRelationshipSync) relationships, err = parentComponents.Find("Component").GetChildren(DefaultContext.DB()) Expect(err).To(BeNil()) - // Child-1 and Child-3 should be present but not Child-2 - Expect(len(relationships)).To(Equal(2)) - + Expect(len(relationships)).To(Equal(2), "Child-1 and Child-3 should be present but not Child-2") }) ginkgo.It("should handle component label updates", func() { childrenComponents[2].Labels = map[string]string{"service": "logistics"} err := DefaultContext.DB().Save(&childrenComponents[2]).Error Expect(err).To(BeNil()) + + cleanupQueryCache() + ComponentRelationshipSync.Run() expectJobToPass(ComponentRelationshipSync) diff --git a/pkg/topology/run.go b/pkg/topology/run.go index d99267e23..158140503 100644 --- a/pkg/topology/run.go +++ b/pkg/topology/run.go @@ -241,9 +241,10 @@ func lookupConfig(ctx *ComponentContext, property *v1.Property) (*types.Property if err := ctx.TemplateConfig(config); err != nil { return nil, err } + pkgConfig := config pkgConfig.Name = configName - _config, err := query.FindConfig(ctx.DB(), *pkgConfig) + _config, err := query.FindConfig(ctx.Context, *pkgConfig) if err != nil || _config == nil { return prop, err } diff --git a/pkg/topology/run_test.go b/pkg/topology/run_test.go index 206901b83..ef769cec9 100644 --- a/pkg/topology/run_test.go +++ b/pkg/topology/run_test.go @@ -30,6 +30,7 @@ var _ = ginkgo.Describe("Topology run", ginkgo.Ordered, func() { err = DefaultContext.DB().Create(&ci).Error Expect(err).To(BeNil()) + cleanupQueryCache() rootComponent, history, err := Run(DefaultContext.WithTrace(), *t) Expect(err).To(BeNil()) diff --git a/pkg/topology/suite_test.go b/pkg/topology/suite_test.go index 00a543806..c92b9e5cb 100644 --- a/pkg/topology/suite_test.go +++ b/pkg/topology/suite_test.go @@ -6,6 +6,7 @@ import ( dutyContext "github.com/flanksource/duty/context" "github.com/flanksource/duty/job" "github.com/flanksource/duty/models" + "github.com/flanksource/duty/query" "github.com/flanksource/duty/tests/setup" "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -15,6 +16,12 @@ var ( DefaultContext dutyContext.Context ) +func cleanupQueryCache() { + Expect(query.FlushComponentCache(DefaultContext)).To(BeNil()) + Expect(query.FlushConfigCache(DefaultContext)).To(BeNil()) + query.FlushGettersCache() +} + func expectJobToPass(j *job.Job) { history, err := j.FindHistory() Expect(err).To(BeNil())