feat: Probes/Added backend implementation for probes as resource (#4116)
* Added probes graphql schema in backend Signed-off-by: Saranya-jena <saranya.jena@harness.io> * Added mongo schema for probes and updated experiment schema Signed-off-by: Saranya-jena <saranya.jena@harness.io> * Added handler functions for probes Signed-off-by: Saranya-jena <saranya.jena@harness.io> * Updated operator version in subscriber Signed-off-by: Saranya-jena <saranya.jena@harness.io> * removed redundant types in GQL n mongo schema Signed-off-by: Saranya-jena <saranya.jena@harness.io> * Added checks for updateProbe Signed-off-by: Saranya-jena <saranya.jena@harness.io> * Added nil checks for update probe Signed-off-by: Saranya-jena <saranya.jena@harness.io> * fixed imports Signed-off-by: Saranya-jena <saranya.jena@harness.io> * resolved conflicts and errors Signed-off-by: Saranya-jena <saranya.jena@harness.io> --------- Signed-off-by: Saranya-jena <saranya.jena@harness.io>
This commit is contained in:
parent
4b778f5a0e
commit
5d4e61074b
File diff suppressed because it is too large
Load Diff
|
|
@ -14,7 +14,7 @@ require (
|
|||
github.com/gorilla/websocket v1.5.0
|
||||
github.com/jinzhu/copier v0.3.5
|
||||
github.com/kelseyhightower/envconfig v1.4.0
|
||||
github.com/litmuschaos/chaos-operator v0.0.0-20230109130222-de7c74a937a9
|
||||
github.com/litmuschaos/chaos-operator v0.0.0-20230718113617-6819a4be12e4
|
||||
github.com/litmuschaos/chaos-scheduler v0.0.0-20220714173615-d7513d616a71
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/sirupsen/logrus v1.8.1
|
||||
|
|
@ -27,8 +27,8 @@ require (
|
|||
google.golang.org/grpc v1.44.0
|
||||
google.golang.org/protobuf v1.28.1
|
||||
gopkg.in/yaml.v2 v2.4.0
|
||||
k8s.io/api v0.23.3
|
||||
k8s.io/apimachinery v0.23.3
|
||||
k8s.io/api v0.26.0
|
||||
k8s.io/apimachinery v0.26.0
|
||||
k8s.io/client-go v12.0.0+incompatible
|
||||
|
||||
)
|
||||
|
|
@ -42,13 +42,14 @@ require (
|
|||
github.com/agnivade/levenshtein v1.0.3 // indirect
|
||||
github.com/bytedance/sonic v1.8.0 // indirect
|
||||
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/emicklei/go-restful v2.15.0+incompatible // indirect
|
||||
github.com/emirpasic/gods v1.12.0 // indirect
|
||||
github.com/gin-contrib/sse v0.1.0 // indirect
|
||||
github.com/go-git/gcfg v1.5.0 // indirect
|
||||
github.com/go-git/go-billy/v5 v5.3.1 // indirect
|
||||
github.com/go-logr/logr v1.2.2 // indirect
|
||||
github.com/go-logr/logr v1.2.3 // indirect
|
||||
github.com/go-openapi/jsonpointer v0.19.5 // indirect
|
||||
github.com/go-openapi/jsonreference v0.19.6 // indirect
|
||||
github.com/go-openapi/swag v0.19.15 // indirect
|
||||
|
|
@ -58,7 +59,7 @@ require (
|
|||
github.com/goccy/go-json v0.10.0 // indirect
|
||||
github.com/gogo/protobuf v1.3.2 // indirect
|
||||
github.com/golang/protobuf v1.5.2 // indirect
|
||||
github.com/golang/snappy v0.0.1 // indirect
|
||||
github.com/golang/snappy v0.0.3 // indirect
|
||||
github.com/google/go-cmp v0.5.7 // indirect
|
||||
github.com/google/gofuzz v1.2.0 // indirect
|
||||
github.com/googleapis/gnostic v0.5.5 // indirect
|
||||
|
|
@ -81,35 +82,39 @@ require (
|
|||
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
||||
github.com/sergi/go-diff v1.1.0 // indirect
|
||||
github.com/spf13/pflag v1.0.5 // indirect
|
||||
github.com/tidwall/match v1.1.1 // indirect
|
||||
github.com/tidwall/pretty v1.2.0 // indirect
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
||||
github.com/ugorji/go/codec v1.2.9 // indirect
|
||||
github.com/urfave/cli/v2 v2.1.1 // indirect
|
||||
github.com/xanzy/ssh-agent v0.3.0 // indirect
|
||||
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
|
||||
github.com/xdg-go/scram v1.1.1 // indirect
|
||||
github.com/xdg-go/stringprep v1.0.3 // indirect
|
||||
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect
|
||||
golang.org/x/arch v0.0.0-20210923205945-b76863e36670 // indirect
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
|
||||
golang.org/x/net v0.7.0 // indirect
|
||||
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 // indirect
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 // indirect
|
||||
golang.org/x/sys v0.5.0 // indirect
|
||||
golang.org/x/term v0.5.0 // indirect
|
||||
golang.org/x/text v0.7.0 // indirect
|
||||
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 // indirect
|
||||
golang.org/x/tools v0.1.12 // indirect
|
||||
google.golang.org/appengine v1.6.7 // indirect
|
||||
google.golang.org/genproto v0.0.0-20220218161850-94dd64e39d7c // indirect
|
||||
gopkg.in/inf.v0 v0.9.1 // indirect
|
||||
gopkg.in/warnings.v0 v0.1.2 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
k8s.io/klog/v2 v2.40.1 // indirect
|
||||
k8s.io/klog/v2 v2.80.1 // indirect
|
||||
k8s.io/kube-openapi v0.0.0-20220124234850-424119656bbf // indirect
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 // indirect
|
||||
k8s.io/utils v0.0.0-20221107191617-1a15be271d1d // indirect
|
||||
sigs.k8s.io/controller-runtime v0.11.1 // indirect
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.2.1 // indirect
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
|
||||
sigs.k8s.io/yaml v1.3.0 // indirect
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -236,9 +236,12 @@ github.com/coreos/pkg v0.0.0-20180108230652-97fdf19511ea/go.mod h1:E3G3o1h8I7cfc
|
|||
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
|
||||
github.com/coreos/prometheus-operator v0.34.0/go.mod h1:Li6rMllG/hYIyXfMuvUwhyC+hqwJVHdsDdP21hypT1M=
|
||||
github.com/coreos/rkt v1.30.0/go.mod h1:O634mlH6U7qk87poQifK6M2rsFNt+FyUTWNMnP1hF1U=
|
||||
github.com/cpuguy83/go-md2man v1.0.10 h1:BSKMNlYxDvnunlTymqtgONjNnaRV1sTpcovwwjF22jk=
|
||||
github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.1 h1:r/myEWzV9lfsM1tFLgDyu0atFtJ1fXn261LKYj/3DxU=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
||||
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
|
||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||
github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||
|
|
@ -374,8 +377,8 @@ github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7
|
|||
github.com/go-logr/logr v0.2.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU=
|
||||
github.com/go-logr/logr v0.4.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU=
|
||||
github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||
github.com/go-logr/logr v1.2.2 h1:ahHml/yUpnlb96Rp8HCvtYVPY8ZYpxq3g7UYchIYwbs=
|
||||
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||
github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0=
|
||||
github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||
github.com/go-logr/zapr v0.1.0/go.mod h1:tabnROwaDl0UNxkVeFRbY8bwB37GwRv0P8lg6aAiEnk=
|
||||
github.com/go-logr/zapr v0.1.1/go.mod h1:tabnROwaDl0UNxkVeFRbY8bwB37GwRv0P8lg6aAiEnk=
|
||||
github.com/go-logr/zapr v0.4.0/go.mod h1:tabnROwaDl0UNxkVeFRbY8bwB37GwRv0P8lg6aAiEnk=
|
||||
|
|
@ -534,8 +537,9 @@ github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw
|
|||
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||
github.com/golang/snappy v0.0.0-20170215233205-553a64147049/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4=
|
||||
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/golang/snappy v0.0.3 h1:fHPg5GQYlCeLIPB9BZqMVR5nR9A+IM5zcgeTdjMYmLA=
|
||||
github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/golangci/check v0.0.0-20180506172741-cfe4005ccda2/go.mod h1:k9Qvh+8juN+UKMCS/3jFtGICgW8O96FVaZsaxdzDkR4=
|
||||
github.com/golangci/dupl v0.0.0-20180902072040-3e9179ac440a/go.mod h1:ryS0uhF+x9jgbj/N71xsEqODy9BN81/GonCZiOzirOk=
|
||||
github.com/golangci/errcheck v0.0.0-20181223084120-ef45e06d44b6/go.mod h1:DbHgvLiFKX1Sh2T1w8Q/h4NAI8MHIpzCdnBUDTXU3I0=
|
||||
|
|
@ -776,8 +780,8 @@ github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de/go.mod h1:zAbeS9
|
|||
github.com/lithammer/dedent v1.1.0/go.mod h1:jrXYCQtgg0nJiN+StA2KgR7w6CiQNv9Fd/Z9BP0jIOc=
|
||||
github.com/litmuschaos/chaos-operator v0.0.0-20210610071657-a58dbd939e73/go.mod h1:QMjfAVIfwcpj/P1jikyz5+C5vWICiUXsFZMR7Ihnzro=
|
||||
github.com/litmuschaos/chaos-operator v0.0.0-20220714075136-66fee1fb7ef7/go.mod h1:m8jQuijmZ9PxCbrvWy0QXL0ji558hUCuD9Q5JAKB12Q=
|
||||
github.com/litmuschaos/chaos-operator v0.0.0-20230109130222-de7c74a937a9 h1:5VkAw2Zqf6xXEElnmFTVuNiP+YVZqH2Qr2t/yv6eI5g=
|
||||
github.com/litmuschaos/chaos-operator v0.0.0-20230109130222-de7c74a937a9/go.mod h1:jRA6jKGed6ytLDJ7897yr2Kr2ygg+cuRXJqwvNmE4Bw=
|
||||
github.com/litmuschaos/chaos-operator v0.0.0-20230718113617-6819a4be12e4 h1:GVU1jK8Gb9OaYuU3iDyU/FE3uZYmBwAEB95VY41SYJ8=
|
||||
github.com/litmuschaos/chaos-operator v0.0.0-20230718113617-6819a4be12e4/go.mod h1:i6wMEZRQoHjUy4bhq6ePuA2FChX1b7WBR2lH09iM0tU=
|
||||
github.com/litmuschaos/chaos-scheduler v0.0.0-20220714173615-d7513d616a71 h1:V9/txTSub+FzFE+h48mlQgJ427vaYqKqvzGmzt6XSfw=
|
||||
github.com/litmuschaos/chaos-scheduler v0.0.0-20220714173615-d7513d616a71/go.mod h1:Edc10opZte1DHcKt0mxyqt64XKPVFAtQ8cghBltZTjs=
|
||||
github.com/litmuschaos/elves v0.0.0-20201107015738-552d74669e3c/go.mod h1:DsbHGNUq/78NZozWVVI9Q6eBei4I+JjlkkD5aibJ3MQ=
|
||||
|
|
@ -1028,8 +1032,11 @@ github.com/rs/cors v1.6.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU=
|
|||
github.com/rubenv/sql-migrate v0.0.0-20191025130928-9355dd04f4b3/go.mod h1:WS0rl9eEliYI8DPnr3TOwz4439pay+qNgzJoVya/DmY=
|
||||
github.com/rubiojr/go-vhd v0.0.0-20200706105327-02e210299021/go.mod h1:DM5xW0nvfNNm2uytzsvhI3OnX8uzaRAg8UX/CnDqbto=
|
||||
github.com/russross/blackfriday v0.0.0-20170610170232-067529f716f4/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
|
||||
github.com/russross/blackfriday v1.5.2 h1:HyvC0ARfnZBqnXwABFeSZHpKvJHJJfPz81GNueLj0oo=
|
||||
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
|
||||
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
|
||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
|
||||
github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
|
||||
github.com/ryanuber/go-glob v0.0.0-20170128012129-256dc444b735/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc=
|
||||
|
|
@ -1135,7 +1142,9 @@ github.com/ugorji/go/codec v1.2.9/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZg
|
|||
github.com/ultraware/funlen v0.0.1/go.mod h1:Dp4UiAus7Wdb9KUZsYWZEWiRzGuM2kXM1lPbfaF6xhA=
|
||||
github.com/ultraware/funlen v0.0.2/go.mod h1:Dp4UiAus7Wdb9KUZsYWZEWiRzGuM2kXM1lPbfaF6xhA=
|
||||
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
|
||||
github.com/urfave/cli v1.22.2 h1:gsqYFH8bb9ekPA12kRo0hfjngWQjkJPlN9R0N78BoUo=
|
||||
github.com/urfave/cli v1.22.2/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
|
||||
github.com/urfave/cli/v2 v2.1.1 h1:Qt8FeAtxE/vfdrLmR3rxR6JRE0RoVmbXu8+6kZtYU4k=
|
||||
github.com/urfave/cli/v2 v2.1.1/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ=
|
||||
github.com/urfave/negroni v1.0.0/go.mod h1:Meg73S6kFm/4PpbYdq35yYWoCZ9mS/YSx+lKnmiohz4=
|
||||
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
||||
|
|
@ -1293,6 +1302,7 @@ golang.org/x/mod v0.3.1-0.20200828183125-ce943fd02449/go.mod h1:s0Qsj1ACt9ePp/hM
|
|||
golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/net v0.0.0-20170114055629-f2499483f923/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20170915142106-8351a756f30f/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
|
|
@ -1392,6 +1402,8 @@ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJ
|
|||
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 h1:uVc8UZUe6tr40fFVnUP5Oj+veunVezqYl9z7DYw9xzw=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20170830134202-bb24a47a89ea/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20171026204733-164713f0dfce/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180117170059-2c42eef0765b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
|
|
@ -1599,6 +1611,8 @@ golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4f
|
|||
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
|
||||
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/tools v0.1.11/go.mod h1:SgwaegtQh8clINPpECJMqnxLv9I09HLqnW3RMqW0CA4=
|
||||
golang.org/x/tools v0.1.12 h1:VveCTK38A2rkS8ZqFY25HIDFscX5X9OoEhJd3quQmXU=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
|
|
@ -1831,8 +1845,8 @@ k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE=
|
|||
k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y=
|
||||
k8s.io/klog/v2 v2.8.0/go.mod h1:hy9LJ/NvuK+iVyP4Ehqva4HxZG/oXyIS3n3Jmire4Ec=
|
||||
k8s.io/klog/v2 v2.9.0/go.mod h1:hy9LJ/NvuK+iVyP4Ehqva4HxZG/oXyIS3n3Jmire4Ec=
|
||||
k8s.io/klog/v2 v2.40.1 h1:P4RRucWk/lFOlDdkAr3mc7iWFkgKrZY9qZMAgek06S4=
|
||||
k8s.io/klog/v2 v2.40.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
|
||||
k8s.io/klog/v2 v2.80.1 h1:atnLQ121W371wYYFawwYx1aEY2eUfs4l3J72wtgAwV4=
|
||||
k8s.io/klog/v2 v2.80.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
|
||||
k8s.io/kube-aggregator v0.21.2/go.mod h1:7NgmUXJziySAJ7GxMRBBwcJay7MLUoxms31fw/ICpYk=
|
||||
k8s.io/kube-controller-manager v0.21.2/go.mod h1:gu0rV2UWy1k05E3kZxJFQE1F7RR1PZlq83+9J+lWlno=
|
||||
k8s.io/kube-openapi v0.0.0-20190320154901-5e45bb682580/go.mod h1:BXM9ceUBTj2QnfH2MK1odQs778ajze1RxcmP6S8RVVc=
|
||||
|
|
@ -1867,8 +1881,8 @@ k8s.io/utils v0.0.0-20200414100711-2df71ebbae66/go.mod h1:jPW/WVKK9YHAvNhRxK0md/
|
|||
k8s.io/utils v0.0.0-20201110183641-67b214c5f920/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
k8s.io/utils v0.0.0-20210802155522-efc7438f0176/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
k8s.io/utils v0.0.0-20210819203725-bdf08cb9a70a/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 h1:HNSDgDCrr/6Ly3WEGKZftiE7IY19Vz2GdbOCyI4qqhc=
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
k8s.io/utils v0.0.0-20221107191617-1a15be271d1d h1:0Smp/HP1OH4Rvhe+4B8nWGERtlqAGSftbSbbmm45oFs=
|
||||
k8s.io/utils v0.0.0-20221107191617-1a15be271d1d/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
|
||||
mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc=
|
||||
mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b/go.mod h1:2odslEg/xrtNQqCYg2/jCoyKnw3vv5biOc3JnIcYfL4=
|
||||
mvdan.cc/unparam v0.0.0-20190209190245-fbb59629db34/go.mod h1:H6SUd1XjIs+qQCyskXg5OFSrilMRUkD8ePJpHKDPaeY=
|
||||
|
|
@ -1894,8 +1908,8 @@ sigs.k8s.io/structured-merge-diff/v3 v3.0.0-20200116222232-67a7b8c61874/go.mod h
|
|||
sigs.k8s.io/structured-merge-diff/v4 v4.0.2/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK1F7G282QMXDPYydCw=
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.1.0/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK1F7G282QMXDPYydCw=
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.1.2/go.mod h1:j/nl6xW8vLS49O8YvXW1ocPhZawJtm+Yrr7PPRQ0Vg4=
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.2.1 h1:bKCqE9GvQ5tiVHn5rfn1r+yao3aLQEaLzkkmAkf+A6Y=
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.2.1/go.mod h1:j/nl6xW8vLS49O8YvXW1ocPhZawJtm+Yrr7PPRQ0Vg4=
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 h1:PRbqxJClWWYMNV1dhaG4NsibJbArud9kFxnAMREiWFE=
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.2.3/go.mod h1:qjx8mGObPmV2aSZepjQjbmb2ihdVs8cGKBraizNC69E=
|
||||
sigs.k8s.io/testing_frameworks v0.1.2/go.mod h1:ToQrwSC3s8Xf/lADdZp3Mktcql9CG0UAmdJG9th5i0w=
|
||||
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
|
||||
sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc=
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -12,6 +12,11 @@ type Audit interface {
|
|||
IsAudit()
|
||||
}
|
||||
|
||||
// Defines the common probe properties shared across different ProbeTypes
|
||||
type CommonProbeProperties interface {
|
||||
IsCommonProbeProperties()
|
||||
}
|
||||
|
||||
type ResourceDetails interface {
|
||||
IsResourceDetails()
|
||||
}
|
||||
|
|
@ -34,6 +39,60 @@ type Annotation struct {
|
|||
ChartDescription string `json:"chartDescription"`
|
||||
}
|
||||
|
||||
// Defines the CMD probe properties
|
||||
type CMDProbe struct {
|
||||
// Timeout of the Probe
|
||||
ProbeTimeout string `json:"probeTimeout"`
|
||||
// Interval of the Probe
|
||||
Interval string `json:"interval"`
|
||||
// Retry interval of the Probe
|
||||
Retry *int `json:"retry"`
|
||||
// Attempt contains the total attempt count for the probe
|
||||
Attempt *int `json:"attempt"`
|
||||
// Polling interval of the Probe
|
||||
ProbePollingInterval *string `json:"probePollingInterval"`
|
||||
// Initial delay interval of the Probe in seconds
|
||||
InitialDelay *string `json:"initialDelay"`
|
||||
// EvaluationTimeout is the timeout window in which the SLO metrics
|
||||
EvaluationTimeout *string `json:"evaluationTimeout"`
|
||||
// Is stop on failure enabled in the Probe
|
||||
StopOnFailure *bool `json:"stopOnFailure"`
|
||||
// Command of the Probe
|
||||
Command string `json:"command"`
|
||||
// Comparator of the Probe
|
||||
Comparator *Comparator `json:"comparator"`
|
||||
// Source of the Probe
|
||||
Source *string `json:"source"`
|
||||
}
|
||||
|
||||
func (CMDProbe) IsCommonProbeProperties() {}
|
||||
|
||||
// Defines the input for CMD probe properties
|
||||
type CMDProbeRequest struct {
|
||||
// Timeout of the Probe
|
||||
ProbeTimeout string `json:"probeTimeout"`
|
||||
// Interval of the Probe
|
||||
Interval string `json:"interval"`
|
||||
// Retry interval of the Probe
|
||||
Retry *int `json:"retry"`
|
||||
// Attempt contains the total attempt count for the probe
|
||||
Attempt *int `json:"attempt"`
|
||||
// Polling interval of the Probe
|
||||
ProbePollingInterval *string `json:"probePollingInterval"`
|
||||
// Initial delay interval of the Probe in seconds
|
||||
InitialDelay *string `json:"initialDelay"`
|
||||
// EvaluationTimeout is the timeout window in which the SLO metrics
|
||||
EvaluationTimeout *string `json:"evaluationTimeout"`
|
||||
// Is stop on failure enabled in the Probe
|
||||
StopOnFailure *bool `json:"stopOnFailure"`
|
||||
// Command of the Probe
|
||||
Command string `json:"command"`
|
||||
// Comparator of the Probe
|
||||
Comparator *ComparatorInput `json:"comparator"`
|
||||
// Source of the Probe
|
||||
Source *string `json:"source"`
|
||||
}
|
||||
|
||||
// Defines the details for a chaos experiment
|
||||
type ChaosExperimentRequest struct {
|
||||
// ID of the experiment
|
||||
|
|
@ -218,6 +277,26 @@ type CloningInput struct {
|
|||
IsDefault bool `json:"isDefault"`
|
||||
}
|
||||
|
||||
// Defines the properties of the comparator
|
||||
type Comparator struct {
|
||||
// Type of the Comparator
|
||||
Type string `json:"type"`
|
||||
// Value of the Comparator
|
||||
Value string `json:"value"`
|
||||
// Operator of the Comparator
|
||||
Criteria string `json:"criteria"`
|
||||
}
|
||||
|
||||
// Defines the input properties of the comparator
|
||||
type ComparatorInput struct {
|
||||
// Type of the Comparator
|
||||
Type string `json:"type"`
|
||||
// Value of the Comparator
|
||||
Value string `json:"value"`
|
||||
// Operator of the Comparator
|
||||
Criteria string `json:"criteria"`
|
||||
}
|
||||
|
||||
type ConfirmInfraRegistrationResponse struct {
|
||||
IsInfraConfirmed bool `json:"isInfraConfirmed"`
|
||||
NewAccessKey *string `json:"newAccessKey"`
|
||||
|
|
@ -317,6 +396,26 @@ type EnvironmentSortInput struct {
|
|||
Ascending *bool `json:"ascending"`
|
||||
}
|
||||
|
||||
// Defines the Executed by which experiment details for Probes
|
||||
type ExecutedByExperiment struct {
|
||||
// Experiment ID
|
||||
ExperimentID string `json:"experimentID"`
|
||||
// Experiment Name
|
||||
ExperimentName string `json:"experimentName"`
|
||||
// Timestamp at which the experiment was last updated
|
||||
UpdatedAt int `json:"updatedAt"`
|
||||
// User who has updated the experiment
|
||||
UpdatedBy *UserDetails `json:"updatedBy"`
|
||||
}
|
||||
|
||||
// Defines the Execution History of experiment referenced by the Probe
|
||||
type ExecutionHistory struct {
|
||||
// Fault Status
|
||||
Status *Status `json:"status"`
|
||||
// Fault executed by which experiment
|
||||
ExecutedByExperiment *ExecutedByExperiment `json:"executedByExperiment"`
|
||||
}
|
||||
|
||||
// Defines the details for a experiment
|
||||
type Experiment struct {
|
||||
ProjectID string `json:"projectID"`
|
||||
|
|
@ -525,6 +624,22 @@ type FaultList struct {
|
|||
Plan []string `json:"plan"`
|
||||
}
|
||||
|
||||
// Details of GET request
|
||||
type Get struct {
|
||||
// Criteria of the request
|
||||
Criteria string `json:"criteria"`
|
||||
// Response Code of the request
|
||||
ResponseCode string `json:"responseCode"`
|
||||
}
|
||||
|
||||
// Details for input of GET request
|
||||
type GETRequest struct {
|
||||
// Criteria of the request
|
||||
Criteria string `json:"criteria"`
|
||||
// Response Code of the request
|
||||
ResponseCode string `json:"responseCode"`
|
||||
}
|
||||
|
||||
type GetChaosHubStatsResponse struct {
|
||||
// Total number of chaoshubs
|
||||
TotalChaosHubs int `json:"totalChaosHubs"`
|
||||
|
|
@ -573,6 +688,36 @@ type GetInfraStatsResponse struct {
|
|||
TotalNonConfirmedInfrastructures int `json:"totalNonConfirmedInfrastructures"`
|
||||
}
|
||||
|
||||
// Defines the response of the Probe reference API
|
||||
type GetProbeReferenceResponse struct {
|
||||
// Harness identifiers
|
||||
ProjectID string `json:"projectID"`
|
||||
// Name of the Probe
|
||||
Name string `json:"name"`
|
||||
// Total Runs
|
||||
TotalRuns int `json:"totalRuns"`
|
||||
// Recent Executions of the probe
|
||||
RecentExecutions []*RecentExecutions `json:"recentExecutions"`
|
||||
}
|
||||
|
||||
// Defines the input requests for GetProbeYAML query
|
||||
type GetProbeYAMLRequest struct {
|
||||
// Probe name of the probe
|
||||
ProbeName string `json:"probeName"`
|
||||
// Mode of the Probe (SoT, EoT, Edge, Continuous or OnChaos)
|
||||
Mode Mode `json:"mode"`
|
||||
}
|
||||
|
||||
// Defines the response for Get Probe In Experiment Run Query
|
||||
type GetProbesInExperimentRunResponse struct {
|
||||
// Probe Object
|
||||
Probe *Probe `json:"probe"`
|
||||
// Mode of the probe
|
||||
Mode Mode `json:"mode"`
|
||||
// Status of the Probe
|
||||
Status *Status `json:"status"`
|
||||
}
|
||||
|
||||
// Details of setting a Git repository
|
||||
type GitConfig struct {
|
||||
// ID of the project where GitOps is configured
|
||||
|
|
@ -615,6 +760,60 @@ type GitConfigResponse struct {
|
|||
SSHPrivateKey *string `json:"sshPrivateKey"`
|
||||
}
|
||||
|
||||
// Defines the HTTP probe properties
|
||||
type HTTPProbe struct {
|
||||
// Timeout of the Probe
|
||||
ProbeTimeout string `json:"probeTimeout"`
|
||||
// Interval of the Probe
|
||||
Interval string `json:"interval"`
|
||||
// Retry interval of the Probe
|
||||
Retry *int `json:"retry"`
|
||||
// Attempt contains the total attempt count for the probe
|
||||
Attempt *int `json:"attempt"`
|
||||
// Polling interval of the Probe
|
||||
ProbePollingInterval *string `json:"probePollingInterval"`
|
||||
// Initial delay interval of the Probe in seconds
|
||||
InitialDelay *string `json:"initialDelay"`
|
||||
// EvaluationTimeout is the timeout window in which the SLO metrics
|
||||
EvaluationTimeout *string `json:"evaluationTimeout"`
|
||||
// Is stop on failure enabled in the Probe
|
||||
StopOnFailure *bool `json:"stopOnFailure"`
|
||||
// URL of the Probe
|
||||
URL string `json:"url"`
|
||||
// HTTP method of the Probe
|
||||
Method *Method `json:"method"`
|
||||
// If Insecure HTTP verification should be skipped
|
||||
InsecureSkipVerify *bool `json:"insecureSkipVerify"`
|
||||
}
|
||||
|
||||
func (HTTPProbe) IsCommonProbeProperties() {}
|
||||
|
||||
// Defines the input for HTTP probe properties
|
||||
type HTTPProbeRequest struct {
|
||||
// Timeout of the Probe
|
||||
ProbeTimeout string `json:"probeTimeout"`
|
||||
// Interval of the Probe
|
||||
Interval string `json:"interval"`
|
||||
// Retry interval of the Probe
|
||||
Retry *int `json:"retry"`
|
||||
// Attempt contains the total attempt count for the probe
|
||||
Attempt *int `json:"attempt"`
|
||||
// Polling interval of the Probe
|
||||
ProbePollingInterval *string `json:"probePollingInterval"`
|
||||
// Initial delay interval of the Probe in seconds
|
||||
InitialDelay *string `json:"initialDelay"`
|
||||
// EvaluationTimeout is the timeout window in which the SLO metrics
|
||||
EvaluationTimeout *string `json:"evaluationTimeout"`
|
||||
// Is stop on failure enabled in the Probe
|
||||
StopOnFailure *bool `json:"stopOnFailure"`
|
||||
// URL of the Probe
|
||||
URL string `json:"url"`
|
||||
// HTTP method of the Probe
|
||||
Method *MethodRequest `json:"method"`
|
||||
// If Insecure HTTP verification should be skipped
|
||||
InsecureSkipVerify *bool `json:"insecureSkipVerify"`
|
||||
}
|
||||
|
||||
// Defines details for image registry
|
||||
type ImageRegistry struct {
|
||||
// Bool value indicating if the image registry is default or not; by default workflow uses LitmusChaos registry
|
||||
|
|
@ -780,6 +979,76 @@ type InfraVersionDetails struct {
|
|||
CompatibleVersions []string `json:"compatibleVersions"`
|
||||
}
|
||||
|
||||
// Defines the K8S probe properties
|
||||
type K8SProbe struct {
|
||||
// Timeout of the Probe
|
||||
ProbeTimeout string `json:"probeTimeout"`
|
||||
// Interval of the Probe
|
||||
Interval string `json:"interval"`
|
||||
// Retry interval of the Probe
|
||||
Retry *int `json:"retry"`
|
||||
// Attempt contains the total attempt count for the probe
|
||||
Attempt *int `json:"attempt"`
|
||||
// Polling interval of the Probe
|
||||
ProbePollingInterval *string `json:"probePollingInterval"`
|
||||
// Initial delay interval of the Probe in seconds
|
||||
InitialDelay *string `json:"initialDelay"`
|
||||
// EvaluationTimeout is the timeout window in which the SLO metrics
|
||||
EvaluationTimeout *string `json:"evaluationTimeout"`
|
||||
// Is stop on failure enabled in the Probe
|
||||
StopOnFailure *bool `json:"stopOnFailure"`
|
||||
// Group of the Probe
|
||||
Group *string `json:"group"`
|
||||
// Version of the Probe
|
||||
Version string `json:"version"`
|
||||
// Resource of the Probe
|
||||
Resource string `json:"resource"`
|
||||
// Namespace of the Probe
|
||||
Namespace *string `json:"namespace"`
|
||||
// Field Selector of the Probe
|
||||
FieldSelector *string `json:"fieldSelector"`
|
||||
// Label Selector of the Probe
|
||||
LabelSelector *string `json:"labelSelector"`
|
||||
// Operation of the Probe
|
||||
Operation string `json:"operation"`
|
||||
}
|
||||
|
||||
func (K8SProbe) IsCommonProbeProperties() {}
|
||||
|
||||
// Defines the input for K8S probe properties
|
||||
type K8SProbeRequest struct {
|
||||
// Timeout of the Probe
|
||||
ProbeTimeout string `json:"probeTimeout"`
|
||||
// Interval of the Probe
|
||||
Interval string `json:"interval"`
|
||||
// Retry interval of the Probe
|
||||
Retry *int `json:"retry"`
|
||||
// Attempt contains the total attempt count for the probe
|
||||
Attempt *int `json:"attempt"`
|
||||
// Polling interval of the Probe
|
||||
ProbePollingInterval *string `json:"probePollingInterval"`
|
||||
// Initial delay interval of the Probe in seconds
|
||||
InitialDelay *string `json:"initialDelay"`
|
||||
// EvaluationTimeout is the timeout window in which the SLO metrics
|
||||
EvaluationTimeout *string `json:"evaluationTimeout"`
|
||||
// Is stop on failure enabled in the Probe
|
||||
StopOnFailure *bool `json:"stopOnFailure"`
|
||||
// Group of the Probe
|
||||
Group *string `json:"group"`
|
||||
// Version of the Probe
|
||||
Version string `json:"version"`
|
||||
// Resource of the Probe
|
||||
Resource string `json:"resource"`
|
||||
// Namespace of the Probe
|
||||
Namespace *string `json:"namespace"`
|
||||
// Field Selector of the Probe
|
||||
FieldSelector *string `json:"fieldSelector"`
|
||||
// Label Selector of the Probe
|
||||
LabelSelector *string `json:"labelSelector"`
|
||||
// Operation of the Probe
|
||||
Operation string `json:"operation"`
|
||||
}
|
||||
|
||||
type KubeGVRRequest struct {
|
||||
Group string `json:"group"`
|
||||
Version string `json:"version"`
|
||||
|
|
@ -927,6 +1196,22 @@ type Metadata struct {
|
|||
Annotations *Annotation `json:"annotations"`
|
||||
}
|
||||
|
||||
// Defines the methods of the probe properties
|
||||
type Method struct {
|
||||
// A GET request
|
||||
Get *Get `json:"get"`
|
||||
// A POST request
|
||||
Post *Post `json:"post"`
|
||||
}
|
||||
|
||||
// Defines the input for methods of the probe properties
|
||||
type MethodRequest struct {
|
||||
// A GET request
|
||||
Get *GETRequest `json:"get"`
|
||||
// A POST request
|
||||
Post *POSTRequest `json:"post"`
|
||||
}
|
||||
|
||||
type NewInfraEventRequest struct {
|
||||
EventName string `json:"eventName"`
|
||||
Description string `json:"description"`
|
||||
|
|
@ -941,6 +1226,92 @@ type ObjectData struct {
|
|||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
// Details of POST request
|
||||
type Post struct {
|
||||
// Content Type of the request
|
||||
ContentType *string `json:"contentType"`
|
||||
// Body of the request
|
||||
Body *string `json:"body"`
|
||||
// Body Path of the HTTP body required for the http post request
|
||||
BodyPath *string `json:"bodyPath"`
|
||||
// Criteria of the request
|
||||
Criteria string `json:"criteria"`
|
||||
// Response Code of the request
|
||||
ResponseCode string `json:"responseCode"`
|
||||
}
|
||||
|
||||
// Details for input of the POST request
|
||||
type POSTRequest struct {
|
||||
// Content Type of the request
|
||||
ContentType *string `json:"contentType"`
|
||||
// Body of the request
|
||||
Body *string `json:"body"`
|
||||
// Body Path of the request for Body
|
||||
BodyPath *string `json:"bodyPath"`
|
||||
// Criteria of the request
|
||||
Criteria string `json:"criteria"`
|
||||
// Response Code of the request
|
||||
ResponseCode string `json:"responseCode"`
|
||||
}
|
||||
|
||||
// Defines the PROM probe properties
|
||||
type PROMProbe struct {
|
||||
// Timeout of the Probe
|
||||
ProbeTimeout string `json:"probeTimeout"`
|
||||
// Interval of the Probe
|
||||
Interval string `json:"interval"`
|
||||
// Retry interval of the Probe
|
||||
Retry *int `json:"retry"`
|
||||
// Attempt contains the total attempt count for the probe
|
||||
Attempt *int `json:"attempt"`
|
||||
// Polling interval of the Probe
|
||||
ProbePollingInterval *string `json:"probePollingInterval"`
|
||||
// Initial delay interval of the Probe in seconds
|
||||
InitialDelay *string `json:"initialDelay"`
|
||||
// EvaluationTimeout is the timeout window in which the SLO metrics
|
||||
EvaluationTimeout *string `json:"evaluationTimeout"`
|
||||
// Is stop on failure enabled in the Probe
|
||||
StopOnFailure *bool `json:"stopOnFailure"`
|
||||
// Endpoint of the Probe
|
||||
Endpoint string `json:"endpoint"`
|
||||
// Query of the Probe
|
||||
Query *string `json:"query"`
|
||||
// Query path of the Probe
|
||||
QueryPath *string `json:"queryPath"`
|
||||
// Comparator of the Probe
|
||||
Comparator *Comparator `json:"comparator"`
|
||||
}
|
||||
|
||||
func (PROMProbe) IsCommonProbeProperties() {}
|
||||
|
||||
// Defines the input for PROM probe properties
|
||||
type PROMProbeRequest struct {
|
||||
// Timeout of the Probe
|
||||
ProbeTimeout string `json:"probeTimeout"`
|
||||
// Interval of the Probe
|
||||
Interval string `json:"interval"`
|
||||
// Retry interval of the Probe
|
||||
Retry *int `json:"retry"`
|
||||
// Attempt contains the total attempt count for the probe
|
||||
Attempt *int `json:"attempt"`
|
||||
// Polling interval of the Probe
|
||||
ProbePollingInterval *string `json:"probePollingInterval"`
|
||||
// Initial delay interval of the Probe in seconds
|
||||
InitialDelay *string `json:"initialDelay"`
|
||||
// EvaluationTimeout is the timeout window in which the SLO metrics
|
||||
EvaluationTimeout *string `json:"evaluationTimeout"`
|
||||
// Is stop on failure enabled in the Probe
|
||||
StopOnFailure *bool `json:"stopOnFailure"`
|
||||
// Endpoint of the Probe
|
||||
Endpoint string `json:"endpoint"`
|
||||
// Query of the Probe
|
||||
Query *string `json:"query"`
|
||||
// Query path of the Probe
|
||||
QueryPath *string `json:"queryPath"`
|
||||
// Comparator of the Probe
|
||||
Comparator *ComparatorInput `json:"comparator"`
|
||||
}
|
||||
|
||||
type PackageInformation struct {
|
||||
PackageName string `json:"packageName"`
|
||||
Experiments []*Experiments `json:"experiments"`
|
||||
|
|
@ -1011,10 +1382,97 @@ type PredefinedExperimentList struct {
|
|||
ExperimentManifest string `json:"experimentManifest"`
|
||||
}
|
||||
|
||||
// Defines the details of the Probe entity
|
||||
type Probe struct {
|
||||
// Harness identifiers
|
||||
ProjectID string `json:"projectID"`
|
||||
// Name of the Probe
|
||||
Name string `json:"name"`
|
||||
// Description of the Probe
|
||||
Description *string `json:"description"`
|
||||
// Tags of the Probe
|
||||
Tags []string `json:"tags"`
|
||||
// Type of the Probe [From list of ProbeType enum]
|
||||
Type ProbeType `json:"type"`
|
||||
// HTTP Properties of the specific type of the Probe
|
||||
HTTPProperties *HTTPProbe `json:"httpProperties"`
|
||||
// CMD Properties of the specific type of the Probe
|
||||
CmdProperties *CMDProbe `json:"cmdProperties"`
|
||||
// K8S Properties of the specific type of the Probe
|
||||
K8sProperties *K8SProbe `json:"k8sProperties"`
|
||||
// PROM Properties of the specific type of the Probe
|
||||
PromProperties *PROMProbe `json:"promProperties"`
|
||||
// All execution histories of the probe
|
||||
RecentExecutions []*ProbeRecentExecutions `json:"recentExecutions"`
|
||||
// Referenced by how many faults
|
||||
ReferencedBy *int `json:"referencedBy"`
|
||||
// Timestamp at which the Probe was last updated
|
||||
UpdatedAt string `json:"updatedAt"`
|
||||
// Timestamp at which the Probe was created
|
||||
CreatedAt string `json:"createdAt"`
|
||||
// User who has updated the Probe
|
||||
UpdatedBy *UserDetails `json:"updatedBy"`
|
||||
// User who has created the Probe
|
||||
CreatedBy *UserDetails `json:"createdBy"`
|
||||
}
|
||||
|
||||
func (Probe) IsResourceDetails() {}
|
||||
func (Probe) IsAudit() {}
|
||||
|
||||
// Defines the input for Probe filter
|
||||
type ProbeFilterInput struct {
|
||||
// Name of the Probe
|
||||
Name *string `json:"name"`
|
||||
// Date range for filtering purpose
|
||||
DateRange *DateRange `json:"dateRange"`
|
||||
// Type of the Probe [From list of ProbeType enum]
|
||||
Type []*ProbeType `json:"type"`
|
||||
}
|
||||
|
||||
// Defines the Recent Executions of global probe in ListProbe API with different fault and execution history each time
|
||||
type ProbeRecentExecutions struct {
|
||||
// Fault name
|
||||
FaultName string `json:"faultName"`
|
||||
// Fault Status
|
||||
Status *Status `json:"status"`
|
||||
// Fault executed by which experiment
|
||||
ExecutedByExperiment *ExecutedByExperiment `json:"executedByExperiment"`
|
||||
}
|
||||
|
||||
// Defines the details required for creating a Chaos Probe
|
||||
type ProbeRequest struct {
|
||||
// Name of the Probe
|
||||
Name string `json:"name"`
|
||||
// Description of the Probe
|
||||
Description *string `json:"description"`
|
||||
// Tags of the Probe
|
||||
Tags []string `json:"tags"`
|
||||
// Type of the Probe [From list of ProbeType enum]
|
||||
Type ProbeType `json:"type"`
|
||||
// HTTP Properties of the specific type of the Probe
|
||||
HTTPProperties *HTTPProbeRequest `json:"httpProperties"`
|
||||
// CMD Properties of the specific type of the Probe
|
||||
CmdProperties *CMDProbeRequest `json:"cmdProperties"`
|
||||
// K8S Properties of the specific type of the Probe
|
||||
K8sProperties *K8SProbeRequest `json:"k8sProperties"`
|
||||
// PROM Properties of the specific type of the Probe
|
||||
PromProperties *PROMProbeRequest `json:"promProperties"`
|
||||
}
|
||||
|
||||
type Provider struct {
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
// Defines the Recent Executions of experiment referenced by the Probe
|
||||
type RecentExecutions struct {
|
||||
// Fault name
|
||||
FaultName string `json:"faultName"`
|
||||
// Probe mode
|
||||
Mode Mode `json:"mode"`
|
||||
// Execution History
|
||||
ExecutionHistory []*ExecutionHistory `json:"executionHistory"`
|
||||
}
|
||||
|
||||
type RecentExperimentRun struct {
|
||||
// ID of the experiment run which is to be queried
|
||||
ExperimentRunID string `json:"experimentRunID"`
|
||||
|
|
@ -1139,6 +1597,14 @@ type Spec struct {
|
|||
ChaosType *string `json:"chaosType"`
|
||||
}
|
||||
|
||||
// Status defines whether a probe is pass or fail
|
||||
type Status struct {
|
||||
// Verdict defines the verdict of the probe, range: Passed, Failed, N/A
|
||||
Verdict ProbeVerdict `json:"verdict"`
|
||||
// Description defines the description of probe status
|
||||
Description *string `json:"description"`
|
||||
}
|
||||
|
||||
// Defines the request for stopping a experiment
|
||||
type StopExperimentRunsRequest struct {
|
||||
ProjectID string `json:"projectID"`
|
||||
|
|
@ -1618,6 +2084,50 @@ func (e InfraScope) MarshalGQL(w io.Writer) {
|
|||
fmt.Fprint(w, strconv.Quote(e.String()))
|
||||
}
|
||||
|
||||
// Defines the different types of Image Pull Policy
|
||||
type ImagePullPolicy string
|
||||
|
||||
const (
|
||||
ImagePullPolicyIfNotPresent ImagePullPolicy = "IfNotPresent"
|
||||
ImagePullPolicyAlways ImagePullPolicy = "Always"
|
||||
ImagePullPolicyNever ImagePullPolicy = "Never"
|
||||
)
|
||||
|
||||
var AllImagePullPolicy = []ImagePullPolicy{
|
||||
ImagePullPolicyIfNotPresent,
|
||||
ImagePullPolicyAlways,
|
||||
ImagePullPolicyNever,
|
||||
}
|
||||
|
||||
func (e ImagePullPolicy) IsValid() bool {
|
||||
switch e {
|
||||
case ImagePullPolicyIfNotPresent, ImagePullPolicyAlways, ImagePullPolicyNever:
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (e ImagePullPolicy) String() string {
|
||||
return string(e)
|
||||
}
|
||||
|
||||
func (e *ImagePullPolicy) UnmarshalGQL(v interface{}) error {
|
||||
str, ok := v.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("enums must be strings")
|
||||
}
|
||||
|
||||
*e = ImagePullPolicy(str)
|
||||
if !e.IsValid() {
|
||||
return fmt.Errorf("%s is not a valid ImagePullPolicy", str)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e ImagePullPolicy) MarshalGQL(w io.Writer) {
|
||||
fmt.Fprint(w, strconv.Quote(e.String()))
|
||||
}
|
||||
|
||||
type InfrastructureType string
|
||||
|
||||
const (
|
||||
|
|
@ -1743,6 +2253,196 @@ func (e MemberRole) MarshalGQL(w io.Writer) {
|
|||
fmt.Fprint(w, strconv.Quote(e.String()))
|
||||
}
|
||||
|
||||
// Defines the different modes of Probes
|
||||
type Mode string
|
||||
|
||||
const (
|
||||
ModeSot Mode = "SOT"
|
||||
ModeEot Mode = "EOT"
|
||||
ModeEdge Mode = "Edge"
|
||||
ModeContinuous Mode = "Continuous"
|
||||
ModeOnChaos Mode = "OnChaos"
|
||||
)
|
||||
|
||||
var AllMode = []Mode{
|
||||
ModeSot,
|
||||
ModeEot,
|
||||
ModeEdge,
|
||||
ModeContinuous,
|
||||
ModeOnChaos,
|
||||
}
|
||||
|
||||
func (e Mode) IsValid() bool {
|
||||
switch e {
|
||||
case ModeSot, ModeEot, ModeEdge, ModeContinuous, ModeOnChaos:
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (e Mode) String() string {
|
||||
return string(e)
|
||||
}
|
||||
|
||||
func (e *Mode) UnmarshalGQL(v interface{}) error {
|
||||
str, ok := v.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("enums must be strings")
|
||||
}
|
||||
|
||||
*e = Mode(str)
|
||||
if !e.IsValid() {
|
||||
return fmt.Errorf("%s is not a valid Mode", str)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e Mode) MarshalGQL(w io.Writer) {
|
||||
fmt.Fprint(w, strconv.Quote(e.String()))
|
||||
}
|
||||
|
||||
// Defines the different statuses of Probes
|
||||
type ProbeStatus string
|
||||
|
||||
const (
|
||||
ProbeStatusRunning ProbeStatus = "Running"
|
||||
ProbeStatusCompleted ProbeStatus = "Completed"
|
||||
ProbeStatusStopped ProbeStatus = "Stopped"
|
||||
ProbeStatusError ProbeStatus = "Error"
|
||||
ProbeStatusQueued ProbeStatus = "Queued"
|
||||
ProbeStatusNa ProbeStatus = "NA"
|
||||
)
|
||||
|
||||
var AllProbeStatus = []ProbeStatus{
|
||||
ProbeStatusRunning,
|
||||
ProbeStatusCompleted,
|
||||
ProbeStatusStopped,
|
||||
ProbeStatusError,
|
||||
ProbeStatusQueued,
|
||||
ProbeStatusNa,
|
||||
}
|
||||
|
||||
func (e ProbeStatus) IsValid() bool {
|
||||
switch e {
|
||||
case ProbeStatusRunning, ProbeStatusCompleted, ProbeStatusStopped, ProbeStatusError, ProbeStatusQueued, ProbeStatusNa:
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (e ProbeStatus) String() string {
|
||||
return string(e)
|
||||
}
|
||||
|
||||
func (e *ProbeStatus) UnmarshalGQL(v interface{}) error {
|
||||
str, ok := v.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("enums must be strings")
|
||||
}
|
||||
|
||||
*e = ProbeStatus(str)
|
||||
if !e.IsValid() {
|
||||
return fmt.Errorf("%s is not a valid ProbeStatus", str)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e ProbeStatus) MarshalGQL(w io.Writer) {
|
||||
fmt.Fprint(w, strconv.Quote(e.String()))
|
||||
}
|
||||
|
||||
// Defines the different types of Probes
|
||||
type ProbeType string
|
||||
|
||||
const (
|
||||
ProbeTypeHTTPProbe ProbeType = "httpProbe"
|
||||
ProbeTypeCmdProbe ProbeType = "cmdProbe"
|
||||
ProbeTypePromProbe ProbeType = "promProbe"
|
||||
ProbeTypeK8sProbe ProbeType = "k8sProbe"
|
||||
)
|
||||
|
||||
var AllProbeType = []ProbeType{
|
||||
ProbeTypeHTTPProbe,
|
||||
ProbeTypeCmdProbe,
|
||||
ProbeTypePromProbe,
|
||||
ProbeTypeK8sProbe,
|
||||
}
|
||||
|
||||
func (e ProbeType) IsValid() bool {
|
||||
switch e {
|
||||
case ProbeTypeHTTPProbe, ProbeTypeCmdProbe, ProbeTypePromProbe, ProbeTypeK8sProbe:
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (e ProbeType) String() string {
|
||||
return string(e)
|
||||
}
|
||||
|
||||
func (e *ProbeType) UnmarshalGQL(v interface{}) error {
|
||||
str, ok := v.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("enums must be strings")
|
||||
}
|
||||
|
||||
*e = ProbeType(str)
|
||||
if !e.IsValid() {
|
||||
return fmt.Errorf("%s is not a valid ProbeType", str)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e ProbeType) MarshalGQL(w io.Writer) {
|
||||
fmt.Fprint(w, strconv.Quote(e.String()))
|
||||
}
|
||||
|
||||
// Defines the older different statuses of Probes
|
||||
type ProbeVerdict string
|
||||
|
||||
const (
|
||||
ProbeVerdictPassed ProbeVerdict = "Passed"
|
||||
ProbeVerdictFailed ProbeVerdict = "Failed"
|
||||
ProbeVerdictNa ProbeVerdict = "NA"
|
||||
ProbeVerdictAwaited ProbeVerdict = "Awaited"
|
||||
)
|
||||
|
||||
var AllProbeVerdict = []ProbeVerdict{
|
||||
ProbeVerdictPassed,
|
||||
ProbeVerdictFailed,
|
||||
ProbeVerdictNa,
|
||||
ProbeVerdictAwaited,
|
||||
}
|
||||
|
||||
func (e ProbeVerdict) IsValid() bool {
|
||||
switch e {
|
||||
case ProbeVerdictPassed, ProbeVerdictFailed, ProbeVerdictNa, ProbeVerdictAwaited:
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (e ProbeVerdict) String() string {
|
||||
return string(e)
|
||||
}
|
||||
|
||||
func (e *ProbeVerdict) UnmarshalGQL(v interface{}) error {
|
||||
str, ok := v.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("enums must be strings")
|
||||
}
|
||||
|
||||
*e = ProbeVerdict(str)
|
||||
if !e.IsValid() {
|
||||
return fmt.Errorf("%s is not a valid ProbeVerdict", str)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e ProbeVerdict) MarshalGQL(w io.Writer) {
|
||||
fmt.Fprint(w, strconv.Quote(e.String()))
|
||||
}
|
||||
|
||||
type ScheduleType string
|
||||
|
||||
const (
|
||||
|
|
|
|||
|
|
@ -0,0 +1,261 @@
|
|||
package graph
|
||||
|
||||
// This file will be automatically regenerated based on the schema, any resolver implementations
|
||||
// will be copied through when generating and any unknown code will be moved to the end.
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"github.com/litmuschaos/litmus/chaoscenter/graphql/server/graph/model"
|
||||
"github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/authorization"
|
||||
"github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/probe"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func (r *mutationResolver) AddProbe(ctx context.Context, request model.ProbeRequest, projectID string) (*model.Probe, error) {
|
||||
logFields := logrus.Fields{
|
||||
"projectId": projectID,
|
||||
}
|
||||
|
||||
logrus.WithFields(logFields).Info("request received to create a probe")
|
||||
|
||||
err := authorization.ValidateRole(ctx, projectID,
|
||||
authorization.MutationRbacRules[authorization.AddProbe],
|
||||
model.InvitationAccepted.String())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Validate if probe type and probe properties match for the selected probe
|
||||
// HTTP Probe type and Property validation
|
||||
if request.Type == model.ProbeTypeHTTPProbe && request.HTTPProperties == nil {
|
||||
err := "probe type and properties don't match, selected http Probe but http properties are empty"
|
||||
logrus.WithFields(logFields).Error(err)
|
||||
return nil, errors.New(err)
|
||||
}
|
||||
// PROM Probe type and Property validation
|
||||
if request.Type == model.ProbeTypePromProbe && request.PromProperties == nil {
|
||||
err := "probe type and properties don't match, selected prom Probe but prom properties are empty"
|
||||
logrus.WithFields(logFields).Error(err)
|
||||
return nil, errors.New(err)
|
||||
}
|
||||
// CMD Probe type and Property validation
|
||||
if request.Type == model.ProbeTypeCmdProbe && request.CmdProperties == nil {
|
||||
err := "probe type and properties don't match, selected cmd Probe but cmd properties are empty"
|
||||
logrus.WithFields(logFields).Error(err)
|
||||
return nil, errors.New(err)
|
||||
}
|
||||
// K8S Probe type and Property validation
|
||||
if request.Type == model.ProbeTypeK8sProbe && request.K8sProperties == nil {
|
||||
err := "probe type and properties don't match, selected k8s Probe but k8s properties are empty"
|
||||
logrus.WithFields(logFields).Error(err)
|
||||
return nil, errors.New(err)
|
||||
}
|
||||
p := probe.NewProbeRepository(projectID)
|
||||
response, err := p.AddProbe(ctx, request)
|
||||
if err != nil {
|
||||
logrus.WithFields(logFields).Error(err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return response, err
|
||||
}
|
||||
|
||||
func (r *mutationResolver) UpdateProbe(ctx context.Context, request model.ProbeRequest, projectID string) (string, error) {
|
||||
logFields := logrus.Fields{
|
||||
"projectId": projectID,
|
||||
"probeName": request.Name,
|
||||
}
|
||||
|
||||
logrus.WithFields(logFields).WithField("probeID", request.Name).Info("request received to update probe")
|
||||
|
||||
err := authorization.ValidateRole(ctx, projectID,
|
||||
authorization.MutationRbacRules[authorization.UpdateProbe],
|
||||
model.InvitationAccepted.String())
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
p := probe.NewProbeRepository(projectID)
|
||||
response, err := p.UpdateProbe(ctx, request)
|
||||
if err != nil {
|
||||
logrus.WithFields(logFields).Error(err)
|
||||
return "", err
|
||||
}
|
||||
|
||||
return response, err
|
||||
}
|
||||
|
||||
func (r *mutationResolver) DeleteProbe(ctx context.Context, probeName string, projectID string) (bool, error) {
|
||||
logFields := logrus.Fields{
|
||||
"projectId": projectID,
|
||||
"probeName": probeName,
|
||||
}
|
||||
|
||||
logrus.WithFields(logFields).WithField("probeID", probeName).Info("request received to delete a probe")
|
||||
|
||||
err := authorization.ValidateRole(ctx, projectID,
|
||||
authorization.MutationRbacRules[authorization.DeleteProbe],
|
||||
model.InvitationAccepted.String())
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
p := probe.NewProbeRepository(projectID)
|
||||
response, err := p.DeleteProbe(ctx, probeName)
|
||||
if err != nil {
|
||||
logrus.WithFields(logFields).Error(err)
|
||||
return false, err
|
||||
}
|
||||
|
||||
return response, err
|
||||
}
|
||||
|
||||
func (r *queryResolver) ListProbes(ctx context.Context, projectID string, probeNames []string, filter *model.ProbeFilterInput) ([]*model.Probe, error) {
|
||||
logFields := logrus.Fields{
|
||||
"projectId": projectID,
|
||||
"probeNames": probeNames,
|
||||
}
|
||||
|
||||
logrus.WithFields(logFields).Info("request received to get probes")
|
||||
err := authorization.ValidateRole(ctx, projectID,
|
||||
authorization.MutationRbacRules[authorization.ListProbes],
|
||||
model.InvitationAccepted.String())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
p := probe.NewProbeRepository(projectID)
|
||||
response, err := p.ListProbes(ctx, probeNames, filter)
|
||||
if err != nil {
|
||||
logrus.WithFields(logFields).Error(err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return response, err
|
||||
}
|
||||
|
||||
func (r *queryResolver) GetProbe(ctx context.Context, projectID string, probeName string) (*model.Probe, error) {
|
||||
logFields := logrus.Fields{
|
||||
"projectId": projectID,
|
||||
"probeName": probeName,
|
||||
}
|
||||
|
||||
logrus.WithFields(logFields).Info("request received to get probe")
|
||||
|
||||
err := authorization.ValidateRole(ctx, projectID,
|
||||
authorization.MutationRbacRules[authorization.GetProbe],
|
||||
model.InvitationAccepted.String())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
p := probe.NewProbeRepository(projectID)
|
||||
response, err := p.GetProbe(ctx, probeName)
|
||||
if err != nil {
|
||||
logrus.WithFields(logFields).Error(err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return response, err
|
||||
}
|
||||
|
||||
func (r *queryResolver) GetProbeYaml(ctx context.Context, projectID string, request model.GetProbeYAMLRequest) (string, error) {
|
||||
logFields := logrus.Fields{
|
||||
"projectId": projectID,
|
||||
"probeName": request.ProbeName,
|
||||
}
|
||||
|
||||
logrus.WithFields(logFields).Info("request received to get probe YAML")
|
||||
|
||||
err := authorization.ValidateRole(ctx, projectID,
|
||||
authorization.MutationRbacRules[authorization.GetProbe],
|
||||
model.InvitationAccepted.String())
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
p := probe.NewProbeRepository(projectID)
|
||||
response, err := p.GetProbeYAMLData(ctx, request)
|
||||
if err != nil {
|
||||
logrus.WithFields(logFields).Error(err)
|
||||
return "", err
|
||||
}
|
||||
|
||||
return response, err
|
||||
}
|
||||
|
||||
func (r *queryResolver) GetProbeReference(ctx context.Context, projectID string, probeName string) (*model.GetProbeReferenceResponse, error) {
|
||||
logFields := logrus.Fields{
|
||||
"projectId": projectID,
|
||||
"probeName": probeName,
|
||||
}
|
||||
|
||||
logrus.WithFields(logFields).Info("request received to get probe references")
|
||||
|
||||
err := authorization.ValidateRole(ctx, projectID,
|
||||
authorization.MutationRbacRules[authorization.GetProbe],
|
||||
model.InvitationAccepted.String())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
p := probe.NewProbeRepository(projectID)
|
||||
response, err := p.GetProbeReference(ctx, probeName)
|
||||
if err != nil {
|
||||
logrus.WithFields(logFields).Error(err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return response, err
|
||||
}
|
||||
|
||||
func (r *queryResolver) GetProbesInExperimentRun(ctx context.Context, projectID string, experimentRunID string, faultName string) ([]*model.GetProbesInExperimentRunResponse, error) {
|
||||
logFields := logrus.Fields{
|
||||
"projectId": projectID,
|
||||
"experimentRunId": experimentRunID,
|
||||
}
|
||||
|
||||
logrus.WithFields(logFields).Info("request received to get probes of the experiment run")
|
||||
|
||||
err := authorization.ValidateRole(ctx, projectID,
|
||||
authorization.MutationRbacRules[authorization.GetProbe],
|
||||
model.InvitationAccepted.String())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
response, err := r.chaosExperimentHandler.GetProbesInExperimentRun(ctx, projectID, experimentRunID, faultName)
|
||||
if err != nil {
|
||||
logrus.WithFields(logFields).Error(err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return response, err
|
||||
}
|
||||
|
||||
func (r *queryResolver) ValidateUniqueProbe(ctx context.Context, projectID string, probeName string) (bool, error) {
|
||||
logFields := logrus.Fields{
|
||||
"projectId": projectID,
|
||||
"probeName": probeName,
|
||||
}
|
||||
|
||||
logrus.WithFields(logFields).Info("request received to validate probe uniqueness")
|
||||
|
||||
err := authorization.ValidateRole(ctx, projectID,
|
||||
authorization.MutationRbacRules[authorization.GetProbe],
|
||||
model.InvitationAccepted.String())
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
p := probe.NewProbeRepository(projectID)
|
||||
response, err := p.ValidateUniqueProbe(ctx, probeName)
|
||||
if err != nil {
|
||||
logrus.WithFields(logFields).Error(err)
|
||||
return false, err
|
||||
}
|
||||
|
||||
return response, err
|
||||
}
|
||||
|
|
@ -3,10 +3,11 @@ package graph
|
|||
import (
|
||||
"context"
|
||||
|
||||
chaos_experiment2 "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/chaos_experiment/ops"
|
||||
|
||||
"github.com/99designs/gqlgen/graphql"
|
||||
"github.com/litmuschaos/litmus/chaoscenter/graphql/server/graph/generated"
|
||||
"github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/authorization"
|
||||
chaos_experiment2 "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/chaos_experiment"
|
||||
"github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/chaos_experiment/handler"
|
||||
"github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/chaos_infrastructure"
|
||||
"github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/chaoshub"
|
||||
|
|
|
|||
|
|
@ -73,6 +73,11 @@ const (
|
|||
DeleteEnvironment RoleQuery = "DeleteEnvironment"
|
||||
GetEnvironment RoleQuery = "GetEnvironment"
|
||||
ListEnvironments RoleQuery = "ListEnvironments"
|
||||
AddProbe RoleQuery = "AddProbe"
|
||||
DeleteProbe RoleQuery = "DeleteProbe"
|
||||
UpdateProbe RoleQuery = "UpdateProbe"
|
||||
GetProbe RoleQuery = "GetProbe"
|
||||
ListProbes RoleQuery = "ListProbes"
|
||||
MemberRoleOwnerString = string(model.MemberRoleOwner)
|
||||
MemberRoleEditorString = string(model.MemberRoleEditor)
|
||||
MemberRoleViewerString = string(model.MemberRoleViewer)
|
||||
|
|
@ -147,4 +152,8 @@ var MutationRbacRules = map[RoleQuery][]string{
|
|||
DeleteEnvironment: {MemberRoleOwnerString, MemberRoleEditorString},
|
||||
GetEnvironment: {MemberRoleOwnerString, MemberRoleEditorString, MemberRoleViewerString},
|
||||
ListEnvironments: {MemberRoleOwnerString, MemberRoleEditorString, MemberRoleViewerString},
|
||||
AddProbe: {MemberRoleOwnerString, MemberRoleEditorString},
|
||||
UpdateProbe: {MemberRoleOwnerString, MemberRoleEditorString},
|
||||
GetProbe: {MemberRoleOwnerString, MemberRoleEditorString, MemberRoleViewerString},
|
||||
ListProbes: {MemberRoleOwnerString, MemberRoleEditorString, MemberRoleViewerString},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,11 @@ import (
|
|||
"strconv"
|
||||
"time"
|
||||
|
||||
chaosTypes "github.com/litmuschaos/chaos-operator/api/litmuschaos/v1alpha1"
|
||||
"github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/chaos_experiment/ops"
|
||||
|
||||
dbSchemaProbe "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/database/mongodb/probe"
|
||||
|
||||
"github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/authorization"
|
||||
"github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/chaos_infrastructure"
|
||||
"github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/gitops"
|
||||
|
|
@ -32,7 +37,7 @@ import (
|
|||
|
||||
// ChaosExperimentHandler is the handler for chaos experiment
|
||||
type ChaosExperimentHandler struct {
|
||||
chaosExperimentService types.Service
|
||||
chaosExperimentService ops.Service
|
||||
chaosExperimentRunService chaosExperimentRun.Service
|
||||
infrastructureService chaos_infrastructure.Service
|
||||
gitOpsService gitops.Service
|
||||
|
|
@ -43,7 +48,7 @@ type ChaosExperimentHandler struct {
|
|||
|
||||
// NewChaosExperimentHandler returns a new instance of ChaosWorkflowHandler
|
||||
func NewChaosExperimentHandler(
|
||||
chaosExperimentService types.Service,
|
||||
chaosExperimentService ops.Service,
|
||||
chaosExperimentRunService chaosExperimentRun.Service,
|
||||
infrastructureService chaos_infrastructure.Service,
|
||||
gitOpsService gitops.Service,
|
||||
|
|
@ -1184,3 +1189,100 @@ func (c *ChaosExperimentHandler) GetDBExperiment(query bson.D) (dbChaosExperimen
|
|||
}
|
||||
return experiment, nil
|
||||
}
|
||||
|
||||
func (c *ChaosExperimentHandler) GetProbesInExperimentRun(ctx context.Context, projectID string, experimentRunID string, faultName string) ([]*model.GetProbesInExperimentRunResponse, error) {
|
||||
var (
|
||||
probeDetails []*model.GetProbesInExperimentRunResponse
|
||||
probeStatusMap = make(map[string]model.ProbeVerdict)
|
||||
probeDescriptionMap = make(map[string]*string)
|
||||
executionData types.ExecutionData
|
||||
)
|
||||
|
||||
wfRun, err := c.chaosExperimentRunOperator.GetExperimentRun(bson.D{
|
||||
{"project_id", projectID},
|
||||
{"is_removed", false},
|
||||
{"experiment_run_id", experimentRunID},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err = json.Unmarshal([]byte(wfRun.ExecutionData), &executionData); err != nil {
|
||||
return nil, errors.New("failed to unmarshal workflow manifest")
|
||||
}
|
||||
|
||||
for _, _probe := range wfRun.Probes {
|
||||
if _probe.FaultName == faultName {
|
||||
|
||||
mode := "SOT"
|
||||
for _, probeName := range _probe.ProbeNames {
|
||||
probeStatusMap[probeName] = model.ProbeVerdictNa
|
||||
description := "Either probe is not executed or not evaluated"
|
||||
probeDescriptionMap[probeName] = &description
|
||||
|
||||
if err = json.Unmarshal([]byte(wfRun.ExecutionData), &executionData); err != nil {
|
||||
return nil, errors.New("failed to unmarshal workflow manifest")
|
||||
}
|
||||
|
||||
if len(executionData.Nodes) > 0 {
|
||||
for _, nodeData := range executionData.Nodes {
|
||||
if nodeData.Name == faultName {
|
||||
if nodeData.Type == "ChaosEngine" && nodeData.ChaosExp == nil {
|
||||
probeStatusMap[probeName] = model.ProbeVerdictNa
|
||||
} else if nodeData.Type == "ChaosEngine" && nodeData.ChaosExp != nil {
|
||||
probeStatusMap[probeName] = model.ProbeVerdictNa
|
||||
if nodeData.ChaosExp.ChaosResult != nil {
|
||||
probeStatusMap[probeName] = model.ProbeVerdictAwaited
|
||||
probeStatuses := nodeData.ChaosExp.ChaosResult.Status.ProbeStatuses
|
||||
|
||||
for _, probeStatus := range probeStatuses {
|
||||
if probeStatus.Name == probeName {
|
||||
mode = probeStatus.Mode
|
||||
|
||||
description := probeStatus.Status.Description
|
||||
probeDescriptionMap[probeStatus.Name] = &description
|
||||
|
||||
switch probeStatus.Status.Verdict {
|
||||
case chaosTypes.ProbeVerdictPassed:
|
||||
probeStatusMap[probeName] = model.ProbeVerdictPassed
|
||||
break
|
||||
case chaosTypes.ProbeVerdictFailed:
|
||||
probeStatusMap[probeName] = model.ProbeVerdictFailed
|
||||
break
|
||||
case chaosTypes.ProbeVerdictAwaited:
|
||||
probeStatusMap[probeName] = model.ProbeVerdictAwaited
|
||||
break
|
||||
default:
|
||||
probeStatusMap[probeName] = model.ProbeVerdictNa
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for _, probeName := range _probe.ProbeNames {
|
||||
singleProbe, err := dbSchemaProbe.GetProbeByName(ctx, probeName, projectID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
probeDetails = append(probeDetails, &model.GetProbesInExperimentRunResponse{
|
||||
Probe: singleProbe.GetOutputProbe(),
|
||||
Mode: model.Mode(mode),
|
||||
Status: &model.Status{
|
||||
Verdict: probeStatusMap[probeName],
|
||||
Description: probeDescriptionMap[probeName],
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return probeDetails, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package chaos_experiment
|
||||
package ops
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
|
@ -8,6 +8,9 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
chaosTypes "github.com/litmuschaos/chaos-operator/api/litmuschaos/v1alpha1"
|
||||
"github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/probe"
|
||||
|
||||
"github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/chaos_infrastructure"
|
||||
|
||||
"github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/database/mongodb"
|
||||
|
|
@ -26,7 +29,7 @@ import (
|
|||
"github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1"
|
||||
"github.com/ghodss/yaml"
|
||||
"github.com/google/uuid"
|
||||
chaosTypes "github.com/litmuschaos/chaos-operator/api/litmuschaos/v1alpha1"
|
||||
|
||||
scheduleTypes "github.com/litmuschaos/chaos-scheduler/api/litmuschaos/v1alpha1"
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
|
@ -146,6 +149,12 @@ func (c *chaosExperimentService) ProcessExperimentCreation(ctx context.Context,
|
|||
weightages []*dbChaosExperiment.WeightagesInput
|
||||
revision []dbChaosExperiment.ExperimentRevision
|
||||
)
|
||||
|
||||
probes, err := probe.ParseProbesFromManifest(wfType, input.ExperimentManifest)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if input.Weightages != nil {
|
||||
//TODO: Once we make the new chaos terminology change in APIs, then we can we the copier instead of for loop
|
||||
for _, v := range input.Weightages {
|
||||
|
|
@ -163,6 +172,7 @@ func (c *chaosExperimentService) ProcessExperimentCreation(ctx context.Context,
|
|||
ExperimentManifest: input.ExperimentManifest,
|
||||
UpdatedAt: timeNow,
|
||||
Weightages: weightages,
|
||||
Probes: probes,
|
||||
})
|
||||
|
||||
newChaosExperiment := dbChaosExperiment.ChaosExperimentRequest{
|
||||
|
|
@ -188,7 +198,7 @@ func (c *chaosExperimentService) ProcessExperimentCreation(ctx context.Context,
|
|||
RecentExperimentRunDetails: []dbChaosExperiment.ExperimentRunDetail{},
|
||||
}
|
||||
|
||||
err := c.chaosExperimentOperator.InsertChaosExperiment(ctx, newChaosExperiment)
|
||||
err = c.chaosExperimentOperator.InsertChaosExperiment(ctx, newChaosExperiment)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -11,6 +11,9 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/probe"
|
||||
"github.com/litmuschaos/litmus/chaoscenter/graphql/server/utils"
|
||||
|
||||
"github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/authorization"
|
||||
"github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/chaos_infrastructure"
|
||||
"github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/gitops"
|
||||
|
|
@ -644,7 +647,6 @@ func (c *ChaosExperimentRunHandler) RunChaosWorkFlow(ctx context.Context, projec
|
|||
|
||||
resKind := gjson.Get(workflow.Revision[0].ExperimentManifest, "kind").String()
|
||||
if strings.ToLower(resKind) == "cronworkflow" {
|
||||
//return nil, errors.New("cron-workflows cannot be re-run")
|
||||
return &model.RunChaosExperimentResponse{NotifyID: notifyID}, c.RunCronExperiment(ctx, projectID, workflow, r)
|
||||
}
|
||||
notifyID = uuid.New().String()
|
||||
|
|
@ -662,6 +664,7 @@ func (c *ChaosExperimentRunHandler) RunChaosWorkFlow(ctx context.Context, projec
|
|||
workflowManifest.Labels["notify_id"] = notifyID
|
||||
workflowManifest.Name = workflowManifest.Name + "-" + strconv.FormatInt(currentTime, 10)
|
||||
|
||||
var probes []dbChaosExperimentRun.Probes
|
||||
for i, template := range workflowManifest.Spec.Templates {
|
||||
artifact := template.Inputs.Artifacts
|
||||
if len(artifact) > 0 {
|
||||
|
|
@ -683,6 +686,23 @@ func (c *ChaosExperimentRunHandler) RunChaosWorkFlow(ctx context.Context, projec
|
|||
if meta.Annotations != nil {
|
||||
annotation = meta.Annotations
|
||||
}
|
||||
|
||||
var annotationArray []string
|
||||
for _, key := range annotation {
|
||||
var manifestAnnotation []dbChaosExperiment.ProbeAnnotations
|
||||
err := json.Unmarshal([]byte(key), &manifestAnnotation)
|
||||
if err != nil {
|
||||
return nil, errors.New("failed to unmarshal experiment annotation object")
|
||||
}
|
||||
for _, annotationKey := range manifestAnnotation {
|
||||
annotationArray = append(annotationArray, annotationKey.Name)
|
||||
}
|
||||
}
|
||||
probes = append(probes, dbChaosExperimentRun.Probes{
|
||||
artifact[0].Name,
|
||||
annotationArray,
|
||||
})
|
||||
|
||||
meta.Annotations = annotation
|
||||
|
||||
if meta.Labels == nil {
|
||||
|
|
@ -697,6 +717,9 @@ func (c *ChaosExperimentRunHandler) RunChaosWorkFlow(ctx context.Context, projec
|
|||
meta.Labels["workflow_run_id"] = "{{workflow.uid}}"
|
||||
}
|
||||
|
||||
if len(meta.Spec.Experiments[0].Spec.Probe) != 0 {
|
||||
meta.Spec.Experiments[0].Spec.Probe = utils.TransformProbe(meta.Spec.Experiments[0].Spec.Probe)
|
||||
}
|
||||
res, err := yaml.Marshal(&meta)
|
||||
if err != nil {
|
||||
return nil, errors.New("failed to marshal chaosengine")
|
||||
|
|
@ -815,6 +838,7 @@ func (c *ChaosExperimentRunHandler) RunChaosWorkFlow(ctx context.Context, projec
|
|||
Completed: false,
|
||||
ResiliencyScore: &resScore,
|
||||
ExecutionData: string(parsedData),
|
||||
Probes: probes,
|
||||
})
|
||||
if err != nil {
|
||||
logrus.Error("Failed to create run operation in db")
|
||||
|
|
@ -856,7 +880,6 @@ func (c *ChaosExperimentRunHandler) RunChaosWorkFlow(ctx context.Context, projec
|
|||
|
||||
func (c *ChaosExperimentRunHandler) RunCronExperiment(ctx context.Context, projectID string, workflow dbChaosExperiment.ChaosExperimentRequest, r *store.StateData) error {
|
||||
var (
|
||||
//usrID = currentUser.Name
|
||||
cronExperimentManifest v1alpha1.CronWorkflow
|
||||
)
|
||||
|
||||
|
|
@ -867,7 +890,7 @@ func (c *ChaosExperimentRunHandler) RunCronExperiment(ctx context.Context, proje
|
|||
return workflow.Revision[i].UpdatedAt > workflow.Revision[j].UpdatedAt
|
||||
})
|
||||
|
||||
err := json.Unmarshal([]byte(workflow.Revision[0].ExperimentManifest), &cronExperimentManifest)
|
||||
cronExperimentManifest, err := probe.GenerateCronExperimentManifestWithProbes(workflow.Revision[0].ExperimentManifest, workflow.ProjectID)
|
||||
if err != nil {
|
||||
return errors.New("failed to unmarshal experiment manifest")
|
||||
}
|
||||
|
|
@ -903,6 +926,9 @@ func (c *ChaosExperimentRunHandler) RunCronExperiment(ctx context.Context, proje
|
|||
meta.Labels["step_pod_name"] = "{{pod.name}}"
|
||||
meta.Labels["workflow_run_id"] = "{{workflow.uid}}"
|
||||
}
|
||||
if len(meta.Spec.Experiments[0].Spec.Probe) != 0 {
|
||||
meta.Spec.Experiments[0].Spec.Probe = utils.TransformProbe(meta.Spec.Experiments[0].Spec.Probe)
|
||||
}
|
||||
res, err := yaml.Marshal(&meta)
|
||||
if err != nil {
|
||||
return errors.New("failed to marshal chaosengine")
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package chaos_experiment
|
||||
|
||||
import (
|
||||
"github.com/litmuschaos/litmus/chaoscenter/graphql/server/graph/model"
|
||||
"github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/database/mongodb"
|
||||
"github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/database/mongodb/chaos_experiment_run"
|
||||
"github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/database/mongodb/chaos_infrastructure"
|
||||
|
|
@ -39,6 +40,22 @@ type ChaosExperimentRequest struct {
|
|||
TotalExperimentRuns int `bson:"total_experiment_runs"`
|
||||
}
|
||||
|
||||
// Probes details containing fault name and the probe name which it was mapped to
|
||||
type Probes struct {
|
||||
FaultName string `bson:"fault_name" json:"faultName"`
|
||||
ProbeNames []string `bson:"probe_names" json:"probeNames"`
|
||||
}
|
||||
|
||||
type ProbeAnnotations struct {
|
||||
Name string `json:"name"`
|
||||
Mode model.Mode `json:"mode"`
|
||||
}
|
||||
|
||||
type ProbesMatched struct {
|
||||
FaultName string `bson:"fault_name"`
|
||||
ProbeNames []string `bson:"probe_names"`
|
||||
}
|
||||
|
||||
// ChaosExperimentsWithRunDetails contains the required fields to be stored in the database for a chaos experiment input
|
||||
type ChaosExperimentsWithRunDetails struct {
|
||||
mongodb.ResourceDetails `bson:",inline"`
|
||||
|
|
@ -74,6 +91,7 @@ type ExperimentRevision struct {
|
|||
ExperimentManifest string `bson:"experiment_manifest"`
|
||||
UpdatedAt int64 `bson:"updated_at"`
|
||||
Weightages []*WeightagesInput `bson:"weightages"`
|
||||
Probes []Probes `bson:"probes"`
|
||||
}
|
||||
|
||||
// WeightagesInput contains the required fields to be stored in the database for a weightages input
|
||||
|
|
@ -147,3 +165,9 @@ type AggregatedExperimentStats struct {
|
|||
TotalExperiments []TotalFilteredData `bson:"total_experiments"`
|
||||
TotalFilteredExperiments []CategorizedExperimentRunStats `bson:"categorized_by_resiliency_score"`
|
||||
}
|
||||
|
||||
type AggregatedExperimentsWithProbes struct {
|
||||
TotalFilteredExperiments []TotalFilteredData `bson:"total_filtered_experiments"`
|
||||
ScheduledExperiments []ChaosExperimentsWithRunDetails `bson:"scheduled_experiments"`
|
||||
ProbesMatched []ProbesMatched `bson:"probes_matched"`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,9 @@ type ChaosExperimentRun struct {
|
|||
InfraID string `bson:"infra_id"`
|
||||
ExperimentRunID string `bson:"experiment_run_id"`
|
||||
ExperimentID string `bson:"experiment_id"`
|
||||
ExperimentName string `bson:"experiment_name"`
|
||||
Phase string `bson:"phase"`
|
||||
Probes []Probes `bson:"probes"`
|
||||
ExecutionData string `bson:"execution_data"`
|
||||
RevisionID string `bson:"revision_id"`
|
||||
NotifyID *string `bson:"notify_id"`
|
||||
|
|
@ -23,6 +25,11 @@ type ChaosExperimentRun struct {
|
|||
Completed bool `bson:"completed"`
|
||||
}
|
||||
|
||||
type Probes struct {
|
||||
FaultName string `bson:"fault_name" json:"faultName"`
|
||||
ProbeNames []string `bson:"probe_names" json:"probeNames"`
|
||||
}
|
||||
|
||||
type TotalFilteredData struct {
|
||||
Count int `bson:"count"`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,6 +38,8 @@ func (g *GetCollectionStruct) getCollection(collectionType int) (*mongo.Collecti
|
|||
return mongoClient.(*MongoClient).GitOpsCollection, nil
|
||||
case EnvironmentCollection:
|
||||
return mongoClient.(*MongoClient).EnvironmentCollection, nil
|
||||
case ChaosProbeCollection:
|
||||
return mongoClient.(*MongoClient).ChaosProbeCollection, nil
|
||||
default:
|
||||
return nil, errors.New("unknown collection name")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ const (
|
|||
UserCollection
|
||||
ProjectCollection
|
||||
EnvironmentCollection
|
||||
ChaosProbeCollection
|
||||
)
|
||||
|
||||
// MongoInterface requires a MongoClient that implements the Initialize method to create the Mongo DB client
|
||||
|
|
@ -48,6 +49,7 @@ type MongoClient struct {
|
|||
UserCollection *mongo.Collection
|
||||
ProjectCollection *mongo.Collection
|
||||
EnvironmentCollection *mongo.Collection
|
||||
ChaosProbeCollection *mongo.Collection
|
||||
}
|
||||
|
||||
var (
|
||||
|
|
@ -57,6 +59,7 @@ var (
|
|||
ChaosInfraCollection: "chaosInfrastructures",
|
||||
ChaosExperimentCollection: "chaosExperiments",
|
||||
ChaosExperimentRunsCollection: "chaosExperimentRuns",
|
||||
ChaosProbeCollection: "chaosProbes",
|
||||
ChaosHubCollection: "chaosHubs",
|
||||
ImageRegistryCollection: "image-registry",
|
||||
ServerConfigCollection: "server-config",
|
||||
|
|
@ -253,4 +256,27 @@ func (m *MongoClient) initAllCollection() {
|
|||
if err != nil {
|
||||
logrus.WithError(err).Fatal("failed to create indexes for environments collection")
|
||||
}
|
||||
// Initialize chaos probes collection
|
||||
err = m.Database.CreateCollection(context.TODO(), Collections[ChaosProbeCollection], nil)
|
||||
if err != nil {
|
||||
logrus.WithError(err).Error("failed to create chaosProbes collection")
|
||||
}
|
||||
|
||||
m.ChaosProbeCollection = m.Database.Collection(Collections[ChaosProbeCollection])
|
||||
_, err = m.ChaosProbeCollection.Indexes().CreateMany(backgroundContext, []mongo.IndexModel{
|
||||
{
|
||||
Keys: bson.M{
|
||||
"name": 1,
|
||||
},
|
||||
Options: options.Index().SetUnique(true),
|
||||
},
|
||||
{
|
||||
Keys: bson.D{
|
||||
{"project_id", 1},
|
||||
},
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
logrus.WithError(err).Error("failed to create indexes for chaosProbes collection")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,80 @@
|
|||
package probe
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/database/mongodb"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
)
|
||||
|
||||
// CreateProbe creates a probe of a specific type (HTTP, PROM, K8s or CMD)
|
||||
// as a shared entity in the database
|
||||
func CreateProbe(ctx context.Context, probe Probe) error {
|
||||
err := mongodb.Operator.Create(ctx, mongodb.ChaosProbeCollection, probe)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetAggregateProbes takes a mongo pipeline to retrieve the project details from the database
|
||||
func GetAggregateProbes(ctx context.Context, pipeline mongo.Pipeline) (*mongo.Cursor, error) {
|
||||
results, err := mongodb.Operator.Aggregate(ctx, mongodb.ChaosProbeCollection, pipeline)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return results, nil
|
||||
}
|
||||
|
||||
// IsProbeUnique returns true if probe is unique
|
||||
func IsProbeUnique(ctx context.Context, query bson.D) (bool, error) {
|
||||
count, err := mongodb.Operator.CountDocuments(ctx, mongodb.ChaosProbeCollection, query)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
if count > 0 {
|
||||
return false, nil
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// UpdateProbe updates details of a Probe
|
||||
func UpdateProbe(ctx context.Context, query bson.D, updateQuery bson.D) (*mongo.UpdateResult, error) {
|
||||
result, err := mongodb.Operator.Update(ctx, mongodb.ChaosProbeCollection, query, updateQuery)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if result.MatchedCount == 0 {
|
||||
return result, errors.New("no matching documents found")
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// UpdateProbes updates details of Probe
|
||||
func UpdateProbes(ctx context.Context, query bson.D, updateQuery bson.D) (*mongo.UpdateResult, error) {
|
||||
result, err := mongodb.Operator.UpdateMany(ctx, mongodb.ChaosProbeCollection, query, updateQuery)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if result.MatchedCount == 0 {
|
||||
return result, errors.New("no matching documents found")
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// GetProbeByName fetches the details of a single Probe with its Probe Name
|
||||
func GetProbeByName(ctx context.Context, probeName string, projectID string) (Probe, error) {
|
||||
var probe Probe
|
||||
result, err := mongodb.Operator.Get(ctx, mongodb.ChaosProbeCollection, bson.D{{"name", probeName}, {"project_id", projectID}, {"is_removed", false}})
|
||||
err = result.Decode(&probe)
|
||||
if err != nil {
|
||||
return Probe{}, err
|
||||
}
|
||||
|
||||
return probe, nil
|
||||
}
|
||||
|
|
@ -0,0 +1,281 @@
|
|||
package probe
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"strconv"
|
||||
|
||||
"github.com/litmuschaos/litmus/chaoscenter/graphql/server/graph/model"
|
||||
"github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/database/mongodb"
|
||||
|
||||
"github.com/litmuschaos/chaos-operator/api/litmuschaos/v1alpha1"
|
||||
)
|
||||
|
||||
type ProbeType string
|
||||
|
||||
type Probe struct {
|
||||
ProjectID string `bson:"project_id"`
|
||||
mongodb.ResourceDetails `bson:",inline"`
|
||||
mongodb.Audit `bson:",inline"`
|
||||
Type ProbeType `bson:"type"`
|
||||
HTTPProperties *HTTPProbe `bson:"http_properties,omitempty"`
|
||||
CMDProperties *CMDProbe `bson:"cmd_properties,omitempty"`
|
||||
PROMProperties *PROMProbe `bson:"prom_properties,omitempty"`
|
||||
K8SProperties *K8SProbe `bson:"k8s_properties,omitempty"`
|
||||
RecentExecutions []*model.ProbeRecentExecutions `bson:"recent_executions"`
|
||||
AverageSuccessPercentage float64 `bson:"average_success_percentage"`
|
||||
}
|
||||
|
||||
type ProbeResponseDetails struct {
|
||||
FaultName string `bson:"fault_name"`
|
||||
}
|
||||
|
||||
type Probes struct {
|
||||
FaultName string `bson:"fault_name"`
|
||||
}
|
||||
|
||||
type ExecutionHistory struct {
|
||||
ExperimentID string `bson:"experiment_id"`
|
||||
ExperimentName string `bson:"experiment_name"`
|
||||
UpdatedBy string `bson:"updated_by"`
|
||||
ExecutionData string `bson:"execution_data"`
|
||||
UpdatedAt int `bson:"updated_at"`
|
||||
Probes []Probes `bson:"probes"`
|
||||
Phase model.ExperimentRunStatus `bson:"phase"`
|
||||
}
|
||||
|
||||
type ProbeWithExecutionHistory struct {
|
||||
ProjectID string `bson:"project_id"`
|
||||
mongodb.ResourceDetails `bson:",inline"`
|
||||
mongodb.Audit `bson:",inline"`
|
||||
Type ProbeType `bson:"type"`
|
||||
HTTPProperties *HTTPProbe `bson:"http_properties,omitempty"`
|
||||
CMDProperties *CMDProbe `bson:"cmd_properties,omitempty"`
|
||||
PROMProperties *PROMProbe `bson:"prom_properties,omitempty"`
|
||||
K8SProperties *K8SProbe `bson:"k8s_properties,omitempty"`
|
||||
AverageSuccessPercentage float64 `bson:"average_success_percentage"`
|
||||
ExecutionHistory []ExecutionHistory `bson:"execution_history"`
|
||||
}
|
||||
|
||||
type CommonProbeProperties struct {
|
||||
ProbeTimeout string `bson:"probe_timeout"`
|
||||
Interval string `bson:"interval"`
|
||||
PollingInterval *string `bson:"polling_interval,omitempty"`
|
||||
InitialDelay *string `bson:"initial_delay,omitempty"`
|
||||
EvaluationTimeout *string `bson:"evaluation_timeout,omitempty"`
|
||||
Retry *int `bson:"retry,omitempty"`
|
||||
Attempt *int `bson:"attempt,omitempty"`
|
||||
StopOnFailure *bool `bson:"stop_on_failure,omitempty"`
|
||||
}
|
||||
|
||||
type HTTPProbe struct {
|
||||
URL string `bson:"url"`
|
||||
ProbeTimeout string `bson:"probe_timeout"`
|
||||
Interval string `bson:"interval"`
|
||||
EvaluationTimeout *string `bson:"evaluation_timeout,omitempty"`
|
||||
PollingInterval *string `bson:"polling_interval,omitempty"`
|
||||
InitialDelay *string `bson:"initial_delay,omitempty"`
|
||||
Retry *int `bson:"retry,omitempty"`
|
||||
Attempt *int `bson:"attempt,omitempty"`
|
||||
Method Method `bson:"method"`
|
||||
StopOnFailure *bool `bson:"stop_on_failure,omitempty"`
|
||||
InsecureSkipVerify *bool `bson:"insecure_skip_verify,omitempty"`
|
||||
}
|
||||
|
||||
type PROMProbe struct {
|
||||
Endpoint string `bson:"endpoint"`
|
||||
Query string `bson:"query"`
|
||||
EvaluationTimeout *string `bson:"evaluation_timeout,omitempty"`
|
||||
PollingInterval *string `bson:"polling_interval"`
|
||||
InitialDelay *string `bson:"initial_delay,omitempty"`
|
||||
QueryPath *string `bson:"query_path,omitempty"`
|
||||
ProbeTimeout string `bson:"probe_timeout"`
|
||||
Interval string `bson:"interval"`
|
||||
Retry *int `bson:"retry,omitempty"`
|
||||
Attempt *int `bson:"attempt,omitempty"`
|
||||
Comparator Comparator `bson:"comparator"`
|
||||
StopOnFailure *bool `bson:"stop_on_failure,omitempty"`
|
||||
}
|
||||
|
||||
type CMDProbe struct {
|
||||
Command string `bson:"command"`
|
||||
ProbeTimeout string `bson:"probe_timeout"`
|
||||
Interval string `bson:"interval"`
|
||||
EvaluationTimeout *string `bson:"evaluation_timeout,omitempty"`
|
||||
PollingInterval *string `bson:"polling_interval,omitempty"`
|
||||
InitialDelay *string `bson:"initial_delay,omitempty"`
|
||||
Retry *int `bson:"retry,omitempty"`
|
||||
Attempt *int `bson:"attempt,omitempty"`
|
||||
Comparator Comparator `bson:"comparator"`
|
||||
Source *v1alpha1.SourceDetails `bson:"source,omitempty"`
|
||||
StopOnFailure *bool `bson:"stop_on_failure,omitempty"`
|
||||
}
|
||||
|
||||
type K8SProbe struct {
|
||||
Group *string `bson:"group,omitempty"`
|
||||
Version string `bson:"version"`
|
||||
Resource string `bson:"resource"`
|
||||
ResourceNames *string `bson:"resourceNames,omitempty"`
|
||||
Namespace *string `bson:"namespace,omitempty"`
|
||||
FieldSelector *string `bson:"field_selector,omitempty"`
|
||||
LabelSelector *string `bson:"label_selector,omitempty"`
|
||||
Operation string `bson:"operation"`
|
||||
ProbeTimeout string `bson:"probe_timeout"`
|
||||
Interval string `bson:"interval"`
|
||||
InitialDelay *string `bson:"initial_delay,omitempty"`
|
||||
PollingInterval *string `bson:"polling_interval,omitempty"`
|
||||
EvaluationTimeout *string `bson:"evaluation_timeout,omitempty"`
|
||||
Retry *int `bson:"retry,omitempty"`
|
||||
Attempt *int `bson:"attempt,omitempty"`
|
||||
StopOnFailure *bool `bson:"stop_on_failure,omitempty"`
|
||||
}
|
||||
|
||||
type GET struct {
|
||||
Criteria string `bson:"criteria"`
|
||||
ResponseCode string `bson:"response_code"`
|
||||
}
|
||||
|
||||
type POST struct {
|
||||
ContentType *string `bson:"content_type,omitempty"`
|
||||
Body *string `bson:"body,omitempty"`
|
||||
BodyPath *string `bson:"body_path, omitempty"`
|
||||
Criteria string `bson:"criteria"`
|
||||
ResponseCode string `bson:"response_code"`
|
||||
}
|
||||
|
||||
type Method struct {
|
||||
GET *GET `bson:"get,omitempty"`
|
||||
POST *POST `bson:"post,omitempty"`
|
||||
}
|
||||
|
||||
type Comparator struct {
|
||||
Type string `bson:"type"`
|
||||
Value string `bson:"value"`
|
||||
Criteria string `bson:"criteria"`
|
||||
}
|
||||
|
||||
// GetOutputProbe
|
||||
func (probe *Probe) GetOutputProbe() *model.Probe {
|
||||
probeResponse := &model.Probe{
|
||||
ProjectID: probe.ProjectID,
|
||||
Name: probe.Name,
|
||||
Description: &probe.Description,
|
||||
Tags: probe.Tags,
|
||||
RecentExecutions: probe.RecentExecutions,
|
||||
CreatedAt: strconv.Itoa(int(probe.CreatedAt)),
|
||||
UpdatedAt: strconv.Itoa(int(probe.UpdatedAt)),
|
||||
Type: model.ProbeType(probe.Type),
|
||||
CreatedBy: &model.UserDetails{
|
||||
UserID: probe.CreatedBy,
|
||||
},
|
||||
UpdatedBy: &model.UserDetails{
|
||||
UserID: probe.UpdatedBy,
|
||||
},
|
||||
}
|
||||
|
||||
if model.ProbeType(probe.Type) == model.ProbeTypeHTTPProbe {
|
||||
probeResponse.HTTPProperties = &model.HTTPProbe{
|
||||
ProbeTimeout: probe.HTTPProperties.ProbeTimeout,
|
||||
Interval: probe.HTTPProperties.Interval,
|
||||
Attempt: probe.HTTPProperties.Attempt,
|
||||
Retry: probe.HTTPProperties.Retry,
|
||||
ProbePollingInterval: probe.HTTPProperties.PollingInterval,
|
||||
InitialDelay: probe.HTTPProperties.InitialDelay,
|
||||
EvaluationTimeout: probe.HTTPProperties.EvaluationTimeout,
|
||||
StopOnFailure: probe.HTTPProperties.StopOnFailure,
|
||||
URL: probe.HTTPProperties.URL,
|
||||
Method: &model.Method{},
|
||||
}
|
||||
|
||||
if probeResponse.HTTPProperties.InsecureSkipVerify != nil {
|
||||
probeResponse.HTTPProperties.InsecureSkipVerify = probe.HTTPProperties.InsecureSkipVerify
|
||||
}
|
||||
|
||||
if probe.HTTPProperties.Method.GET != nil {
|
||||
probeResponse.HTTPProperties.Method.Get = &model.Get{
|
||||
Criteria: probe.HTTPProperties.Method.GET.Criteria,
|
||||
ResponseCode: probe.HTTPProperties.Method.GET.ResponseCode,
|
||||
}
|
||||
} else if probe.HTTPProperties.Method.POST != nil {
|
||||
probeResponse.HTTPProperties.Method.Post = &model.Post{
|
||||
Criteria: probe.HTTPProperties.Method.POST.Criteria,
|
||||
ResponseCode: probe.HTTPProperties.Method.POST.ResponseCode,
|
||||
}
|
||||
|
||||
if probeResponse.HTTPProperties.Method.Post.ContentType != nil {
|
||||
probeResponse.HTTPProperties.Method.Post.ContentType = probe.HTTPProperties.Method.POST.ContentType
|
||||
}
|
||||
|
||||
if probeResponse.HTTPProperties.Method.Post.Body != nil {
|
||||
probeResponse.HTTPProperties.Method.Post.Body = probe.HTTPProperties.Method.POST.Body
|
||||
}
|
||||
|
||||
if probeResponse.HTTPProperties.Method.Post.BodyPath != nil {
|
||||
probeResponse.HTTPProperties.Method.Post.BodyPath = probe.HTTPProperties.Method.POST.BodyPath
|
||||
}
|
||||
}
|
||||
} else if model.ProbeType(probe.Type) == model.ProbeTypeCmdProbe {
|
||||
probeResponse.CmdProperties = &model.CMDProbe{
|
||||
ProbeTimeout: probe.CMDProperties.ProbeTimeout,
|
||||
Interval: probe.CMDProperties.Interval,
|
||||
Attempt: probe.CMDProperties.Attempt,
|
||||
Retry: probe.CMDProperties.Retry,
|
||||
ProbePollingInterval: probe.CMDProperties.PollingInterval,
|
||||
InitialDelay: probe.CMDProperties.InitialDelay,
|
||||
EvaluationTimeout: probe.CMDProperties.EvaluationTimeout,
|
||||
StopOnFailure: probe.CMDProperties.StopOnFailure,
|
||||
Command: probe.CMDProperties.Command,
|
||||
Comparator: &model.Comparator{
|
||||
Type: probe.CMDProperties.Comparator.Type,
|
||||
Value: probe.CMDProperties.Comparator.Value,
|
||||
Criteria: probe.CMDProperties.Comparator.Criteria,
|
||||
},
|
||||
}
|
||||
|
||||
// CMD Probe -> Source
|
||||
if probe.CMDProperties.Source != nil {
|
||||
jsonSource, _ := json.Marshal(probe.CMDProperties.Source)
|
||||
source := string(jsonSource)
|
||||
probeResponse.CmdProperties.Source = &source
|
||||
}
|
||||
|
||||
} else if model.ProbeType(probe.Type) == model.ProbeTypePromProbe {
|
||||
probeResponse.PromProperties = &model.PROMProbe{
|
||||
ProbeTimeout: probe.PROMProperties.ProbeTimeout,
|
||||
Interval: probe.PROMProperties.Interval,
|
||||
Attempt: probe.PROMProperties.Attempt,
|
||||
Retry: probe.PROMProperties.Retry,
|
||||
ProbePollingInterval: probe.PROMProperties.PollingInterval,
|
||||
InitialDelay: probe.PROMProperties.InitialDelay,
|
||||
EvaluationTimeout: probe.PROMProperties.EvaluationTimeout,
|
||||
StopOnFailure: probe.PROMProperties.StopOnFailure,
|
||||
Endpoint: probe.PROMProperties.Endpoint,
|
||||
Query: &probe.PROMProperties.Query,
|
||||
QueryPath: probe.PROMProperties.QueryPath,
|
||||
Comparator: &model.Comparator{
|
||||
Type: probe.PROMProperties.Comparator.Type,
|
||||
Value: probe.PROMProperties.Comparator.Value,
|
||||
Criteria: probe.PROMProperties.Comparator.Criteria,
|
||||
},
|
||||
}
|
||||
} else if model.ProbeType(probe.Type) == model.ProbeTypeK8sProbe {
|
||||
probeResponse.K8sProperties = &model.K8SProbe{
|
||||
ProbeTimeout: probe.K8SProperties.ProbeTimeout,
|
||||
Interval: probe.K8SProperties.Interval,
|
||||
Attempt: probe.K8SProperties.Attempt,
|
||||
Retry: probe.K8SProperties.Retry,
|
||||
ProbePollingInterval: probe.K8SProperties.PollingInterval,
|
||||
InitialDelay: probe.K8SProperties.InitialDelay,
|
||||
EvaluationTimeout: probe.K8SProperties.EvaluationTimeout,
|
||||
StopOnFailure: probe.K8SProperties.StopOnFailure,
|
||||
Group: probe.K8SProperties.Group,
|
||||
Version: probe.K8SProperties.Version,
|
||||
Resource: probe.K8SProperties.Resource,
|
||||
Namespace: probe.K8SProperties.Namespace,
|
||||
FieldSelector: probe.K8SProperties.FieldSelector,
|
||||
LabelSelector: probe.K8SProperties.LabelSelector,
|
||||
Operation: probe.K8SProperties.Operation,
|
||||
}
|
||||
}
|
||||
|
||||
return probeResponse
|
||||
}
|
||||
|
|
@ -12,9 +12,10 @@ import (
|
|||
"sync"
|
||||
"time"
|
||||
|
||||
chaosExperimentOps "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/chaos_experiment/ops"
|
||||
|
||||
"github.com/ghodss/yaml"
|
||||
"github.com/litmuschaos/litmus/chaoscenter/graphql/server/graph/model"
|
||||
chaos_experiment2 "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/chaos_experiment"
|
||||
chaos_infra "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/chaos_infrastructure"
|
||||
data_store "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/data-store"
|
||||
store "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/data-store"
|
||||
|
|
@ -55,11 +56,11 @@ type Service interface {
|
|||
type gitOpsService struct {
|
||||
gitOpsOperator *gitops.Operator
|
||||
chaosExperimentOps chaos_experiment.Operator
|
||||
chaosExperimentService chaos_experiment2.Service
|
||||
chaosExperimentService chaosExperimentOps.Service
|
||||
}
|
||||
|
||||
// NewGitOpsService returns a new instance of a gitOpsService
|
||||
func NewGitOpsService(gitOpsOperator *gitops.Operator, chaosExperimentService chaos_experiment2.Service, chaosExperimentOps chaos_experiment.Operator) Service {
|
||||
func NewGitOpsService(gitOpsOperator *gitops.Operator, chaosExperimentService chaosExperimentOps.Service, chaosExperimentOps chaos_experiment.Operator) Service {
|
||||
return &gitOpsService{
|
||||
gitOpsOperator: gitOpsOperator,
|
||||
chaosExperimentService: chaosExperimentService,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,938 @@
|
|||
package probe
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"sort"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/chaos_experiment"
|
||||
|
||||
"github.com/litmuschaos/chaos-operator/api/litmuschaos/v1alpha1"
|
||||
"github.com/litmuschaos/litmus/chaoscenter/graphql/server/graph/model"
|
||||
"github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/authorization"
|
||||
"github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/database/mongodb"
|
||||
dbChaosExperimentRun "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/database/mongodb/chaos_experiment_run"
|
||||
dbSchemaProbe "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/database/mongodb/probe"
|
||||
|
||||
"github.com/ghodss/yaml"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
)
|
||||
|
||||
type ProbeInterface interface {
|
||||
AddProbe(ctx context.Context, probe model.ProbeRequest) (*model.Probe, error)
|
||||
UpdateProbe(ctx context.Context, probe model.ProbeRequest) (string, error)
|
||||
ListProbes(ctx context.Context, probeNames []string, filter *model.ProbeFilterInput) ([]*model.Probe, error)
|
||||
DeleteProbe(ctx context.Context, probeName string) (bool, error)
|
||||
GetProbe(ctx context.Context, probeName string) (*model.Probe, error)
|
||||
GetProbeReference(ctx context.Context, probeName string) (*model.GetProbeReferenceResponse, error)
|
||||
GetProbeYAMLData(ctx context.Context, probe model.GetProbeYAMLRequest) (string, error)
|
||||
ValidateUniqueProbe(ctx context.Context, probeName string) (bool, error)
|
||||
}
|
||||
|
||||
type probe struct {
|
||||
ProjectID string
|
||||
}
|
||||
|
||||
func NewProbeRepository(projectID string) ProbeInterface {
|
||||
return &probe{
|
||||
|
||||
ProjectID: projectID,
|
||||
}
|
||||
}
|
||||
|
||||
func Error(logFields logrus.Fields, message string) error {
|
||||
logrus.WithFields(logFields).Error(message)
|
||||
return errors.New(message)
|
||||
}
|
||||
|
||||
// AddProbe - Create a new Probe
|
||||
func (p *probe) AddProbe(ctx context.Context, probe model.ProbeRequest) (*model.Probe, error) {
|
||||
// TODO: Add check if probe exists
|
||||
|
||||
var (
|
||||
currTime = time.Now().UnixMilli()
|
||||
)
|
||||
tkn := ctx.Value(authorization.AuthKey).(string)
|
||||
username, err := authorization.GetUsername(tkn)
|
||||
|
||||
logFields := logrus.Fields{
|
||||
|
||||
"projectId": p.ProjectID,
|
||||
"probeName": probe.Name,
|
||||
}
|
||||
|
||||
logrus.WithFields(logFields).Info("adding ", probe.Type, " probe")
|
||||
|
||||
// Shared Properties
|
||||
|
||||
newProbe := &dbSchemaProbe.Probe{
|
||||
ResourceDetails: mongodb.ResourceDetails{
|
||||
Name: probe.Name,
|
||||
Description: *probe.Description,
|
||||
Tags: probe.Tags,
|
||||
},
|
||||
ProjectID: p.ProjectID,
|
||||
Audit: mongodb.Audit{
|
||||
CreatedAt: currTime,
|
||||
UpdatedAt: currTime,
|
||||
IsRemoved: false,
|
||||
CreatedBy: username,
|
||||
UpdatedBy: username,
|
||||
},
|
||||
Type: dbSchemaProbe.ProbeType(probe.Type),
|
||||
}
|
||||
|
||||
// Check the respective probe type and modify the property response based on the type
|
||||
if probe.Type == model.ProbeTypeHTTPProbe && probe.HTTPProperties != nil {
|
||||
addHTTPProbeProperties(newProbe, probe)
|
||||
} else if probe.Type == model.ProbeTypeCmdProbe && probe.CmdProperties != nil {
|
||||
addCMDProbeProperties(newProbe, probe)
|
||||
} else if probe.Type == model.ProbeTypePromProbe && probe.PromProperties != nil {
|
||||
addPROMProbeProperties(newProbe, probe)
|
||||
} else if probe.Type == model.ProbeTypeK8sProbe && probe.K8sProperties != nil {
|
||||
addK8SProbeProperties(newProbe, probe)
|
||||
} else if probe.Type == model.ProbeTypeHTTPProbe && probe.HTTPProperties == nil {
|
||||
return nil, Error(logFields, "http probe type's properties are empty")
|
||||
} else if probe.Type == model.ProbeTypeCmdProbe && probe.CmdProperties == nil {
|
||||
return nil, Error(logFields, "cmd probe type's properties are empty")
|
||||
} else if probe.Type == model.ProbeTypePromProbe && probe.PromProperties == nil {
|
||||
return nil, Error(logFields, "prom probe type's properties are empty")
|
||||
} else if probe.Type == model.ProbeTypeK8sProbe && probe.K8sProperties == nil {
|
||||
return nil, Error(logFields, "k8s probe type's properties are empty")
|
||||
}
|
||||
|
||||
// Adding the new probe into database.
|
||||
err = dbSchemaProbe.CreateProbe(ctx, *newProbe)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return newProbe.GetOutputProbe(), nil
|
||||
}
|
||||
|
||||
// UpdateProbe - Update a new Probe
|
||||
func (p *probe) UpdateProbe(ctx context.Context, request model.ProbeRequest) (string, error) {
|
||||
tkn := ctx.Value(authorization.AuthKey).(string)
|
||||
username, err := authorization.GetUsername(tkn)
|
||||
|
||||
pr, err := dbSchemaProbe.GetProbeByName(ctx, request.Name, p.ProjectID)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
logFields := logrus.Fields{
|
||||
"projectId": p.ProjectID,
|
||||
"probeName": pr.Name,
|
||||
}
|
||||
uniqueProbe, err := p.ValidateUniqueProbe(ctx, request.Name)
|
||||
if err != nil {
|
||||
return "", err
|
||||
} else if uniqueProbe == true {
|
||||
return "", Error(logFields, "probe name doesn't exist")
|
||||
}
|
||||
|
||||
if request.Type != model.ProbeType(pr.Type) {
|
||||
return "", Error(logFields, "mismatched probe types")
|
||||
}
|
||||
|
||||
// Shared Properties
|
||||
newProbe := &dbSchemaProbe.Probe{
|
||||
ResourceDetails: mongodb.ResourceDetails{
|
||||
Name: request.Name,
|
||||
Description: *request.Description,
|
||||
Tags: request.Tags,
|
||||
},
|
||||
ProjectID: p.ProjectID,
|
||||
Audit: mongodb.Audit{
|
||||
CreatedAt: pr.CreatedAt,
|
||||
UpdatedAt: time.Now().UnixMilli(),
|
||||
IsRemoved: false,
|
||||
CreatedBy: pr.CreatedBy,
|
||||
UpdatedBy: username,
|
||||
},
|
||||
Type: pr.Type,
|
||||
}
|
||||
|
||||
// Check the respective probe type and modify the property response based on the type
|
||||
if request.Type == model.ProbeTypeHTTPProbe && request.HTTPProperties != nil {
|
||||
addHTTPProbeProperties(newProbe, request)
|
||||
} else if request.Type == model.ProbeTypeCmdProbe && request.CmdProperties != nil {
|
||||
addCMDProbeProperties(newProbe, request)
|
||||
} else if request.Type == model.ProbeTypePromProbe && request.PromProperties != nil {
|
||||
addPROMProbeProperties(newProbe, request)
|
||||
} else if request.Type == model.ProbeTypeK8sProbe && request.K8sProperties != nil {
|
||||
addK8SProbeProperties(newProbe, request)
|
||||
} else if request.Type == model.ProbeTypeHTTPProbe && request.HTTPProperties == nil {
|
||||
return "", errors.New("http probe type's properties are empty")
|
||||
} else if request.Type == model.ProbeTypeCmdProbe && request.CmdProperties == nil {
|
||||
return "", errors.New("cmd probe type's properties are empty")
|
||||
} else if request.Type == model.ProbeTypePromProbe && request.PromProperties == nil {
|
||||
return "", errors.New("prom probe type's properties are empty")
|
||||
} else if request.Type == model.ProbeTypePromProbe && request.K8sProperties == nil {
|
||||
return "", errors.New("k8s probe type's properties are empty")
|
||||
}
|
||||
|
||||
var updateQuery bson.D
|
||||
updateQuery = bson.D{
|
||||
{"$set", newProbe},
|
||||
}
|
||||
|
||||
filterQuery := bson.D{
|
||||
{"name", request.Name},
|
||||
{"project_id", p.ProjectID},
|
||||
{"is_removed", false},
|
||||
}
|
||||
|
||||
_, err = dbSchemaProbe.UpdateProbe(ctx, filterQuery, updateQuery)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return "Updated successfully", nil
|
||||
}
|
||||
|
||||
// GetProbe - List a single Probe
|
||||
func (p *probe) GetProbe(ctx context.Context, probeName string) (*model.Probe, error) {
|
||||
|
||||
probe, err := dbSchemaProbe.GetProbeByName(ctx, probeName, p.ProjectID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return probe.GetOutputProbe(), nil
|
||||
}
|
||||
|
||||
// GetProbeYAMLData - Get the probe yaml data compatible with the chaos engine manifest
|
||||
func (p *probe) GetProbeYAMLData(ctx context.Context, probeRequest model.GetProbeYAMLRequest) (string, error) {
|
||||
|
||||
probe, err := dbSchemaProbe.GetProbeByName(ctx, probeRequest.ProbeName, p.ProjectID)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
if model.ProbeType(probe.Type) == model.ProbeTypeHTTPProbe {
|
||||
|
||||
var _probe HTTPProbeAttributes
|
||||
|
||||
_probe.Name = probe.Name
|
||||
_probe.Type = string(probe.Type)
|
||||
_probe.Mode = string(probeRequest.Mode)
|
||||
_probe.HTTPProbeInputs = v1alpha1.HTTPProbeInputs{
|
||||
URL: probe.HTTPProperties.URL,
|
||||
}
|
||||
|
||||
if probe.HTTPProperties.InsecureSkipVerify != nil {
|
||||
_probe.HTTPProbeInputs.InsecureSkipVerify = *probe.HTTPProperties.InsecureSkipVerify
|
||||
}
|
||||
|
||||
if probe.HTTPProperties.Method.GET != nil {
|
||||
_probe.HTTPProbeInputs = v1alpha1.HTTPProbeInputs{
|
||||
Method: v1alpha1.HTTPMethod{
|
||||
Get: &v1alpha1.GetMethod{
|
||||
Criteria: probe.HTTPProperties.Method.GET.Criteria,
|
||||
ResponseCode: probe.HTTPProperties.Method.GET.ResponseCode,
|
||||
},
|
||||
},
|
||||
}
|
||||
} else if probe.HTTPProperties.Method.POST != nil {
|
||||
_probe.HTTPProbeInputs = v1alpha1.HTTPProbeInputs{
|
||||
Method: v1alpha1.HTTPMethod{
|
||||
Post: &v1alpha1.PostMethod{
|
||||
Criteria: probe.HTTPProperties.Method.POST.Criteria,
|
||||
ResponseCode: probe.HTTPProperties.Method.POST.ResponseCode,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
if probe.HTTPProperties.Method.POST.ContentType != nil {
|
||||
_probe.HTTPProbeInputs.Method.Post.ContentType = *probe.HTTPProperties.Method.POST.ContentType
|
||||
}
|
||||
|
||||
if probe.HTTPProperties.Method.POST.Body != nil {
|
||||
_probe.HTTPProbeInputs.Method.Post.Body = *probe.HTTPProperties.Method.POST.Body
|
||||
}
|
||||
|
||||
if probe.HTTPProperties.Method.POST.BodyPath != nil {
|
||||
_probe.HTTPProbeInputs.Method.Post.BodyPath = *probe.HTTPProperties.Method.POST.BodyPath
|
||||
}
|
||||
}
|
||||
|
||||
_probe.RunProperties = v1alpha1.RunProperty{
|
||||
ProbeTimeout: probe.HTTPProperties.ProbeTimeout,
|
||||
Interval: probe.HTTPProperties.Interval,
|
||||
}
|
||||
|
||||
if probe.HTTPProperties.Retry != nil {
|
||||
_probe.RunProperties.Retry = *probe.HTTPProperties.Retry
|
||||
}
|
||||
|
||||
if probe.HTTPProperties.Attempt != nil {
|
||||
_probe.RunProperties.Attempt = *probe.HTTPProperties.Attempt
|
||||
}
|
||||
|
||||
if probe.HTTPProperties.PollingInterval != nil {
|
||||
_probe.RunProperties.ProbePollingInterval = *probe.HTTPProperties.PollingInterval
|
||||
}
|
||||
|
||||
if probe.HTTPProperties.EvaluationTimeout != nil {
|
||||
_probe.RunProperties.EvaluationTimeout = *probe.HTTPProperties.EvaluationTimeout
|
||||
}
|
||||
|
||||
if probe.HTTPProperties.InitialDelay != nil {
|
||||
_probe.RunProperties.InitialDelay = *probe.HTTPProperties.InitialDelay
|
||||
}
|
||||
|
||||
if probe.HTTPProperties.StopOnFailure != nil {
|
||||
_probe.RunProperties.StopOnFailure = *probe.HTTPProperties.StopOnFailure
|
||||
}
|
||||
|
||||
y, err := yaml.Marshal(_probe)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(y), err
|
||||
} else if model.ProbeType(probe.Type) == model.ProbeTypeCmdProbe {
|
||||
|
||||
var _probe CMDProbeAttributes
|
||||
|
||||
_probe.Name = probe.Name
|
||||
_probe.Type = string(probe.Type)
|
||||
_probe.Mode = string(probeRequest.Mode)
|
||||
_probe.CmdProbeInputs = v1alpha1.CmdProbeInputs{
|
||||
Command: probe.CMDProperties.Command,
|
||||
Comparator: v1alpha1.ComparatorInfo{
|
||||
Type: probe.CMDProperties.Comparator.Type,
|
||||
Criteria: probe.CMDProperties.Comparator.Criteria,
|
||||
Value: probe.CMDProperties.Comparator.Value,
|
||||
},
|
||||
}
|
||||
|
||||
if probe.CMDProperties.Source != nil {
|
||||
// TODO: Add source volume and volume mount types
|
||||
_probe.CmdProbeInputs.Source = &v1alpha1.SourceDetails{
|
||||
Image: probe.CMDProperties.Source.Image,
|
||||
HostNetwork: probe.CMDProperties.Source.HostNetwork,
|
||||
InheritInputs: probe.CMDProperties.Source.InheritInputs,
|
||||
Args: probe.CMDProperties.Source.Args,
|
||||
ENVList: probe.CMDProperties.Source.ENVList,
|
||||
Labels: probe.CMDProperties.Source.Labels,
|
||||
Annotations: probe.CMDProperties.Source.Annotations,
|
||||
Command: probe.CMDProperties.Source.Command,
|
||||
ImagePullPolicy: probe.CMDProperties.Source.ImagePullPolicy,
|
||||
Privileged: probe.CMDProperties.Source.Privileged,
|
||||
NodeSelector: probe.CMDProperties.Source.NodeSelector,
|
||||
ImagePullSecrets: probe.CMDProperties.Source.ImagePullSecrets,
|
||||
}
|
||||
}
|
||||
|
||||
_probe.RunProperties = v1alpha1.RunProperty{
|
||||
ProbeTimeout: probe.CMDProperties.ProbeTimeout,
|
||||
Interval: probe.CMDProperties.Interval,
|
||||
}
|
||||
|
||||
if probe.CMDProperties.Retry != nil {
|
||||
_probe.RunProperties.Retry = *probe.CMDProperties.Retry
|
||||
}
|
||||
|
||||
if probe.CMDProperties.Attempt != nil {
|
||||
_probe.RunProperties.Attempt = *probe.CMDProperties.Attempt
|
||||
}
|
||||
|
||||
if probe.CMDProperties.PollingInterval != nil {
|
||||
_probe.RunProperties.ProbePollingInterval = *probe.CMDProperties.PollingInterval
|
||||
}
|
||||
|
||||
if probe.CMDProperties.EvaluationTimeout != nil {
|
||||
_probe.RunProperties.EvaluationTimeout = *probe.CMDProperties.EvaluationTimeout
|
||||
}
|
||||
|
||||
if probe.CMDProperties.InitialDelay != nil {
|
||||
_probe.RunProperties.InitialDelay = *probe.CMDProperties.InitialDelay
|
||||
}
|
||||
|
||||
if probe.CMDProperties.StopOnFailure != nil {
|
||||
_probe.RunProperties.StopOnFailure = *probe.CMDProperties.StopOnFailure
|
||||
}
|
||||
|
||||
y, err := yaml.Marshal(_probe)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(y), err
|
||||
} else if model.ProbeType(probe.Type) == model.ProbeTypePromProbe {
|
||||
|
||||
var _probe PROMProbeAttributes
|
||||
|
||||
_probe.Name = probe.Name
|
||||
_probe.Type = string(probe.Type)
|
||||
_probe.Mode = string(probeRequest.Mode)
|
||||
_probe.PromProbeInputs = v1alpha1.PromProbeInputs{
|
||||
Endpoint: probe.PROMProperties.Endpoint,
|
||||
Query: probe.PROMProperties.Query,
|
||||
Comparator: v1alpha1.ComparatorInfo{
|
||||
Type: probe.PROMProperties.Comparator.Type,
|
||||
Criteria: probe.PROMProperties.Comparator.Criteria,
|
||||
Value: probe.PROMProperties.Comparator.Value,
|
||||
},
|
||||
}
|
||||
|
||||
if probe.PROMProperties.QueryPath != nil {
|
||||
_probe.PromProbeInputs.QueryPath = *probe.PROMProperties.QueryPath
|
||||
}
|
||||
|
||||
_probe.RunProperties = v1alpha1.RunProperty{
|
||||
ProbeTimeout: probe.PROMProperties.ProbeTimeout,
|
||||
Interval: probe.PROMProperties.Interval,
|
||||
}
|
||||
|
||||
if probe.PROMProperties.Retry != nil {
|
||||
_probe.RunProperties.Retry = *probe.PROMProperties.Retry
|
||||
}
|
||||
|
||||
if probe.PROMProperties.Attempt != nil {
|
||||
_probe.RunProperties.Attempt = *probe.PROMProperties.Attempt
|
||||
}
|
||||
|
||||
if probe.PROMProperties.PollingInterval != nil {
|
||||
_probe.RunProperties.ProbePollingInterval = *probe.PROMProperties.PollingInterval
|
||||
}
|
||||
|
||||
if probe.PROMProperties.EvaluationTimeout != nil {
|
||||
_probe.RunProperties.EvaluationTimeout = *probe.PROMProperties.EvaluationTimeout
|
||||
}
|
||||
|
||||
if probe.PROMProperties.InitialDelay != nil {
|
||||
_probe.RunProperties.InitialDelay = *probe.PROMProperties.InitialDelay
|
||||
}
|
||||
|
||||
if probe.PROMProperties.StopOnFailure != nil {
|
||||
_probe.RunProperties.StopOnFailure = *probe.PROMProperties.StopOnFailure
|
||||
}
|
||||
|
||||
y, err := yaml.Marshal(_probe)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(y), err
|
||||
} else if model.ProbeType(probe.Type) == model.ProbeTypeK8sProbe {
|
||||
|
||||
var _probe K8SProbeAttributes
|
||||
|
||||
_probe.Name = probe.Name
|
||||
_probe.Type = string(probe.Type)
|
||||
_probe.Mode = string(probeRequest.Mode)
|
||||
_probe.K8sProbeInputs.Version = probe.K8SProperties.Version
|
||||
_probe.K8sProbeInputs.Resource = probe.K8SProperties.Resource
|
||||
_probe.K8sProbeInputs.Operation = probe.K8SProperties.Operation
|
||||
|
||||
if probe.K8SProperties.Group != nil {
|
||||
_probe.K8sProbeInputs.Group = *probe.K8SProperties.Group
|
||||
}
|
||||
|
||||
if probe.K8SProperties.ResourceNames != nil {
|
||||
_probe.K8sProbeInputs.ResourceNames = *probe.K8SProperties.ResourceNames
|
||||
}
|
||||
|
||||
if probe.K8SProperties.Namespace != nil {
|
||||
_probe.K8sProbeInputs.Namespace = *probe.K8SProperties.Namespace
|
||||
}
|
||||
|
||||
if probe.K8SProperties.FieldSelector != nil {
|
||||
_probe.K8sProbeInputs.FieldSelector = *probe.K8SProperties.FieldSelector
|
||||
}
|
||||
|
||||
if probe.K8SProperties.LabelSelector != nil {
|
||||
_probe.K8sProbeInputs.LabelSelector = *probe.K8SProperties.LabelSelector
|
||||
}
|
||||
|
||||
_probe.RunProperties = v1alpha1.RunProperty{
|
||||
ProbeTimeout: probe.K8SProperties.ProbeTimeout,
|
||||
Interval: probe.K8SProperties.Interval,
|
||||
}
|
||||
|
||||
if probe.K8SProperties.Retry != nil {
|
||||
_probe.RunProperties.Retry = *probe.K8SProperties.Retry
|
||||
}
|
||||
|
||||
if probe.K8SProperties.Attempt != nil {
|
||||
_probe.RunProperties.Attempt = *probe.K8SProperties.Attempt
|
||||
}
|
||||
|
||||
if probe.K8SProperties.PollingInterval != nil {
|
||||
_probe.RunProperties.ProbePollingInterval = *probe.K8SProperties.PollingInterval
|
||||
}
|
||||
|
||||
if probe.K8SProperties.EvaluationTimeout != nil {
|
||||
_probe.RunProperties.EvaluationTimeout = *probe.K8SProperties.EvaluationTimeout
|
||||
}
|
||||
|
||||
if probe.K8SProperties.InitialDelay != nil {
|
||||
_probe.RunProperties.InitialDelay = *probe.K8SProperties.InitialDelay
|
||||
}
|
||||
|
||||
if probe.K8SProperties.StopOnFailure != nil {
|
||||
_probe.RunProperties.StopOnFailure = *probe.K8SProperties.StopOnFailure
|
||||
}
|
||||
|
||||
y, err := yaml.Marshal(_probe)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(y), err
|
||||
}
|
||||
|
||||
return "", err
|
||||
}
|
||||
|
||||
// ListProbes - List a single/all Probes
|
||||
func (p *probe) ListProbes(ctx context.Context, probeNames []string, filter *model.ProbeFilterInput) ([]*model.Probe, error) {
|
||||
var pipeline mongo.Pipeline
|
||||
|
||||
// Match the Probe Names from the input array
|
||||
if probeNames != nil && len(probeNames) != 0 {
|
||||
matchProbeName := bson.D{
|
||||
{
|
||||
Key: "$match", Value: bson.D{
|
||||
{"name", bson.D{
|
||||
{"$in", probeNames},
|
||||
}},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
pipeline = append(pipeline, matchProbeName)
|
||||
}
|
||||
|
||||
// Match Filter options
|
||||
if filter != nil {
|
||||
// Filtering based on multi-select probe type
|
||||
if filter.Type != nil && len(filter.Type) != 0 {
|
||||
matchProbeType := bson.D{
|
||||
{
|
||||
Key: "$match", Value: bson.D{
|
||||
{"type", bson.D{
|
||||
{"$in", filter.Type},
|
||||
}},
|
||||
},
|
||||
},
|
||||
}
|
||||
pipeline = append(pipeline, matchProbeType)
|
||||
}
|
||||
|
||||
// Filtering based on Probe Name
|
||||
if filter.Name != nil && *filter.Name != "" {
|
||||
matchProbeNameStage := bson.D{
|
||||
{"$match", bson.D{
|
||||
{"name", bson.D{
|
||||
{"$regex", filter.Name},
|
||||
}},
|
||||
}},
|
||||
}
|
||||
pipeline = append(pipeline, matchProbeNameStage)
|
||||
}
|
||||
|
||||
// Filtering based on date range (experiment's last updated time)
|
||||
if filter.DateRange != nil {
|
||||
endDate := time.Now().UnixMilli()
|
||||
startDate, _ := strconv.ParseInt(filter.DateRange.StartDate, 10, 64)
|
||||
if filter.DateRange.EndDate != nil {
|
||||
endDate, _ = strconv.ParseInt(*filter.DateRange.EndDate, 10, 64)
|
||||
}
|
||||
|
||||
filterProbeDateStage := bson.D{
|
||||
{
|
||||
"$match",
|
||||
bson.D{{"updated_at", bson.D{
|
||||
{"$lte", endDate},
|
||||
{"$gte", startDate},
|
||||
}}},
|
||||
},
|
||||
}
|
||||
pipeline = append(pipeline, filterProbeDateStage)
|
||||
}
|
||||
}
|
||||
|
||||
// Match with identifiers
|
||||
matchIdentifierStage := bson.D{
|
||||
{
|
||||
Key: "$match", Value: bson.D{
|
||||
{"project_id", p.ProjectID},
|
||||
{"is_removed", false},
|
||||
},
|
||||
},
|
||||
}
|
||||
pipeline = append(pipeline, matchIdentifierStage)
|
||||
|
||||
var allProbes []dbSchemaProbe.Probe
|
||||
|
||||
probeCursor, err := dbSchemaProbe.GetAggregateProbes(ctx, pipeline)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = probeCursor.All(context.Background(), &allProbes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var probeDetails []*model.Probe
|
||||
|
||||
for _, probe := range allProbes {
|
||||
var lastTenExecutions []*model.ProbeRecentExecutions
|
||||
recentExecutions, err := GetProbeExecutionHistoryInExperimentRuns(p.ProjectID, probe.Name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for i, executions := range recentExecutions {
|
||||
if len(recentExecutions) > 10 && i < (len(recentExecutions)-10) {
|
||||
continue
|
||||
} else {
|
||||
lastTenExecutions = append(lastTenExecutions, executions)
|
||||
}
|
||||
}
|
||||
|
||||
probeDetail := probe.GetOutputProbe()
|
||||
|
||||
probeDetail.RecentExecutions = lastTenExecutions
|
||||
|
||||
referencedByCount := len(recentExecutions)
|
||||
probeDetail.ReferencedBy = &referencedByCount
|
||||
|
||||
probeDetails = append(probeDetails, probeDetail)
|
||||
}
|
||||
|
||||
return probeDetails, nil
|
||||
}
|
||||
|
||||
func GetProbeExecutionHistoryInExperimentRuns(projectID string, probeName string) ([]*model.ProbeRecentExecutions, error) {
|
||||
var (
|
||||
pipeline mongo.Pipeline
|
||||
expRuns []dbChaosExperimentRun.ChaosExperimentRun
|
||||
executionData chaos_experiment.ExecutionData
|
||||
probeStatusMap = map[string]model.ProbeVerdict{}
|
||||
recentExecutions []*model.ProbeRecentExecutions
|
||||
)
|
||||
|
||||
// Match with identifiers
|
||||
matchIdentifierStage := bson.D{
|
||||
{"$match", bson.D{
|
||||
{"project_id", projectID},
|
||||
{"probes.probe_names", probeName},
|
||||
}},
|
||||
}
|
||||
|
||||
pipeline = append(pipeline, matchIdentifierStage)
|
||||
|
||||
// Call aggregation on pipeline
|
||||
experimentRunOperator := dbChaosExperimentRun.NewChaosExperimentRunOperator(mongodb.Operator)
|
||||
expRunCursor, err := experimentRunOperator.GetAggregateExperimentRuns(pipeline)
|
||||
if err != nil {
|
||||
return nil, errors.New("DB aggregate stage error: " + err.Error())
|
||||
}
|
||||
|
||||
if err = expRunCursor.All(context.Background(), &expRuns); err != nil {
|
||||
return nil, errors.New("error decoding experiment run cursor: " + err.Error())
|
||||
}
|
||||
|
||||
for _, execution := range expRuns {
|
||||
faultName := execution.Probes[0].FaultName
|
||||
|
||||
probeStatusMap = make(map[string]model.ProbeVerdict)
|
||||
|
||||
if err = json.Unmarshal([]byte(execution.ExecutionData), &executionData); err != nil {
|
||||
return nil, errors.New("failed to unmarshal experiment manifest")
|
||||
}
|
||||
|
||||
probeStatusMap[probeName] = model.ProbeVerdictNa
|
||||
|
||||
for _, probe := range execution.Probes {
|
||||
if faultName == probe.FaultName {
|
||||
if len(executionData.Nodes) > 0 {
|
||||
|
||||
for _, nodeData := range executionData.Nodes {
|
||||
if nodeData.Name == faultName {
|
||||
if nodeData.Type == "ChaosEngine" && nodeData.ChaosExp == nil {
|
||||
probeStatusMap[probeName] = model.ProbeVerdictNa
|
||||
} else if nodeData.Type == "ChaosEngine" && nodeData.ChaosExp != nil {
|
||||
probeStatusMap[probeName] = model.ProbeVerdictNa
|
||||
|
||||
if nodeData.ChaosExp.ChaosResult != nil {
|
||||
probeStatusMap[probeName] = model.ProbeVerdictAwaited
|
||||
probeStatuses := nodeData.ChaosExp.ChaosResult.Status.ProbeStatuses
|
||||
|
||||
for _, probeStatus := range probeStatuses {
|
||||
|
||||
if probeStatus.Name == probeName {
|
||||
|
||||
switch probeStatus.Status.Verdict {
|
||||
case v1alpha1.ProbeVerdictPassed:
|
||||
probeStatusMap[probeName] = model.ProbeVerdictPassed
|
||||
case v1alpha1.ProbeVerdictFailed:
|
||||
probeStatusMap[probeName] = model.ProbeVerdictFailed
|
||||
case v1alpha1.ProbeVerdictAwaited:
|
||||
probeStatusMap[probeName] = model.ProbeVerdictAwaited
|
||||
default:
|
||||
probeStatusMap[probeName] = model.ProbeVerdictNa
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
recentExecutions = append(recentExecutions, &model.ProbeRecentExecutions{
|
||||
FaultName: faultName,
|
||||
Status: &model.Status{
|
||||
Verdict: probeStatusMap[probeName],
|
||||
},
|
||||
ExecutedByExperiment: &model.ExecutedByExperiment{
|
||||
ExperimentID: execution.ExperimentID,
|
||||
ExperimentName: execution.ExperimentName,
|
||||
UpdatedAt: int(execution.UpdatedAt),
|
||||
UpdatedBy: &model.UserDetails{
|
||||
Username: execution.UpdatedBy,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return recentExecutions, nil
|
||||
}
|
||||
|
||||
// DeleteProbe - Deletes a single Probe
|
||||
func (p *probe) DeleteProbe(ctx context.Context, probeName string) (bool, error) {
|
||||
|
||||
_, err := dbSchemaProbe.GetProbeByName(ctx, probeName, p.ProjectID)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
tkn := ctx.Value(authorization.AuthKey).(string)
|
||||
username, err := authorization.GetUsername(tkn)
|
||||
|
||||
Time := time.Now().UnixMilli()
|
||||
|
||||
query := bson.D{
|
||||
{"name", probeName},
|
||||
{"project_id", p.ProjectID},
|
||||
{"is_removed", false},
|
||||
}
|
||||
update := bson.D{
|
||||
{"$set", bson.D{
|
||||
{"is_removed", true},
|
||||
{"updated_at", Time},
|
||||
{"updated_by", username},
|
||||
}},
|
||||
}
|
||||
|
||||
_, err = dbSchemaProbe.UpdateProbe(ctx, query, update)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// GetProbeReference - Get the experiment details the probe is referencing to
|
||||
func (p *probe) GetProbeReference(ctx context.Context, probeName string) (*model.GetProbeReferenceResponse, error) {
|
||||
|
||||
var pipeline mongo.Pipeline
|
||||
|
||||
// Matching with identifiers
|
||||
matchIdentifiersStage := bson.D{
|
||||
{
|
||||
"$match", bson.D{{
|
||||
"$and", bson.A{
|
||||
bson.D{
|
||||
{"project_id", p.ProjectID},
|
||||
{"name", probeName},
|
||||
{"is_removed", false},
|
||||
},
|
||||
},
|
||||
}},
|
||||
},
|
||||
}
|
||||
pipeline = append(pipeline, matchIdentifiersStage)
|
||||
|
||||
experimentWithSelectedProbeName := bson.D{
|
||||
{
|
||||
"$lookup",
|
||||
bson.D{
|
||||
{"from", "chaosExperimentRuns"},
|
||||
{
|
||||
"pipeline", bson.A{
|
||||
bson.D{{"$match", bson.D{
|
||||
{"probes.probe_names", bson.D{
|
||||
{"$eq", probeName},
|
||||
}},
|
||||
}}},
|
||||
bson.D{
|
||||
{"$project", bson.D{
|
||||
{"experiment_name", 1},
|
||||
{"probes.fault_name", 1},
|
||||
{"phase", 1},
|
||||
{"updated_at", 1},
|
||||
{"updated_by", 1},
|
||||
{"execution_data", 1},
|
||||
{"experiment_id", 1},
|
||||
}},
|
||||
},
|
||||
},
|
||||
},
|
||||
{"as", "execution_history"},
|
||||
},
|
||||
},
|
||||
}
|
||||
pipeline = append(pipeline, experimentWithSelectedProbeName)
|
||||
|
||||
// Call aggregation on pipeline
|
||||
probeCursor, err := dbSchemaProbe.GetAggregateProbes(ctx, pipeline)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var (
|
||||
totalRuns = 0
|
||||
executionData chaos_experiment.ExecutionData
|
||||
probeRuns []dbSchemaProbe.ProbeWithExecutionHistory
|
||||
recentExecutions []*model.RecentExecutions
|
||||
recentExecutionsMap = make(map[string][]*model.RecentExecutions)
|
||||
)
|
||||
|
||||
if err = probeCursor.All(context.Background(), &probeRuns); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, individualExecution := range probeRuns[0].ExecutionHistory {
|
||||
|
||||
faultName := individualExecution.Probes[0].FaultName
|
||||
mode := "SOT"
|
||||
|
||||
totalRuns++
|
||||
var executionHistoryResponse []*model.ExecutionHistory
|
||||
|
||||
for _, execution := range probeRuns[0].ExecutionHistory {
|
||||
|
||||
status := model.ProbeVerdictNa
|
||||
|
||||
if err = json.Unmarshal([]byte(execution.ExecutionData), &executionData); err != nil {
|
||||
return nil, errors.New("failed to unmarshal experiment manifest")
|
||||
}
|
||||
|
||||
for _, probe := range execution.Probes {
|
||||
if faultName == probe.FaultName {
|
||||
if len(executionData.Nodes) > 0 {
|
||||
for _, nodeData := range executionData.Nodes {
|
||||
if nodeData.Name == faultName {
|
||||
if nodeData.Type == "ChaosEngine" && nodeData.ChaosExp == nil {
|
||||
status = model.ProbeVerdictNa
|
||||
} else if nodeData.Type == "ChaosEngine" && nodeData.ChaosExp != nil {
|
||||
status = model.ProbeVerdictNa
|
||||
|
||||
if nodeData.ChaosExp.ChaosResult != nil {
|
||||
status = model.ProbeVerdictAwaited
|
||||
probeStatuses := nodeData.ChaosExp.ChaosResult.Status.ProbeStatuses
|
||||
|
||||
for _, probeStatus := range probeStatuses {
|
||||
if probeStatus.Name == probeRuns[0].Name {
|
||||
mode = probeStatus.Mode
|
||||
switch probeStatus.Status.Verdict {
|
||||
case v1alpha1.ProbeVerdictPassed:
|
||||
status = model.ProbeVerdictPassed
|
||||
break
|
||||
case v1alpha1.ProbeVerdictFailed:
|
||||
status = model.ProbeVerdictFailed
|
||||
break
|
||||
case v1alpha1.ProbeVerdictAwaited:
|
||||
status = model.ProbeVerdictAwaited
|
||||
break
|
||||
default:
|
||||
status = model.ProbeVerdictNa
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
executionHistoryResponse = append(executionHistoryResponse, &model.ExecutionHistory{
|
||||
Status: &model.Status{
|
||||
Verdict: status,
|
||||
},
|
||||
ExecutedByExperiment: &model.ExecutedByExperiment{
|
||||
ExperimentID: execution.ExperimentID,
|
||||
ExperimentName: execution.ExperimentName,
|
||||
UpdatedAt: execution.UpdatedAt,
|
||||
//UpdatedBy: harness.FilterUserDetails(execution.UpdatedBy, userDetails),
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for i, j := 0, len(executionHistoryResponse)-1; i < j; i, j = i+1, j-1 {
|
||||
j := len(executionHistoryResponse) - i - 1
|
||||
executionHistoryResponse[i], executionHistoryResponse[j] = executionHistoryResponse[j], executionHistoryResponse[i]
|
||||
}
|
||||
|
||||
recentExecutionsMap[faultName] = append(recentExecutionsMap[faultName], &model.RecentExecutions{
|
||||
FaultName: faultName,
|
||||
Mode: model.Mode(mode),
|
||||
ExecutionHistory: executionHistoryResponse,
|
||||
})
|
||||
}
|
||||
|
||||
for fault := range recentExecutionsMap {
|
||||
if len(recentExecutionsMap[fault]) != 0 {
|
||||
recentExecutions = append(recentExecutions, recentExecutionsMap[fault][0])
|
||||
}
|
||||
}
|
||||
|
||||
sort.Slice(recentExecutions, func(i, j int) bool {
|
||||
return recentExecutions[i].ExecutionHistory[len(recentExecutions[i].ExecutionHistory)-1].ExecutedByExperiment.UpdatedAt > recentExecutions[j].ExecutionHistory[len(recentExecutions[j].ExecutionHistory)-1].ExecutedByExperiment.UpdatedAt
|
||||
})
|
||||
|
||||
_probeReference := &model.GetProbeReferenceResponse{
|
||||
ProjectID: probeRuns[0].ProjectID,
|
||||
Name: probeRuns[0].Name,
|
||||
TotalRuns: totalRuns,
|
||||
RecentExecutions: recentExecutions,
|
||||
}
|
||||
|
||||
return _probeReference, err
|
||||
}
|
||||
|
||||
// ValidateUniqueProbe - Validates the uniqueness of the probe, returns true if unique
|
||||
func (p *probe) ValidateUniqueProbe(ctx context.Context, probeName string) (bool, error) {
|
||||
|
||||
query := bson.D{
|
||||
{"name", probeName},
|
||||
{"project_id", p.ProjectID},
|
||||
{"is_removed", false},
|
||||
}
|
||||
|
||||
isUnique, err := dbSchemaProbe.IsProbeUnique(ctx, query)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return isUnique, nil
|
||||
}
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
package probe
|
||||
|
||||
import (
|
||||
"github.com/litmuschaos/chaos-operator/api/litmuschaos/v1alpha1"
|
||||
"github.com/litmuschaos/litmus/chaoscenter/graphql/server/graph/model"
|
||||
)
|
||||
|
||||
type HTTPProbeAttributes struct {
|
||||
// Name of probe
|
||||
Name string `json:"name,omitempty"`
|
||||
// Type of probe
|
||||
Type string `json:"type,omitempty"`
|
||||
// inputs needed for the http probe
|
||||
HTTPProbeInputs v1alpha1.HTTPProbeInputs `json:"httpProbe/inputs,omitempty"`
|
||||
// RunProperty contains timeout, retry and interval for the probe
|
||||
RunProperties v1alpha1.RunProperty `json:"runProperties,omitempty"`
|
||||
// mode for k8s probe
|
||||
// it can be SOT, EOT, Edge
|
||||
Mode string `json:"mode,omitempty"`
|
||||
}
|
||||
|
||||
// HTTPMethod define the http method details
|
||||
type HTTPMethod struct {
|
||||
Get *v1alpha1.GetMethod `json:"get,omitempty"`
|
||||
Post *v1alpha1.PostMethod `json:"post,omitempty"`
|
||||
}
|
||||
|
||||
type CMDProbeAttributes struct {
|
||||
// Name of probe
|
||||
Name string `json:"name,omitempty"`
|
||||
// Type of probe
|
||||
Type string `json:"type,omitempty"`
|
||||
// inputs needed for the cmd probe
|
||||
CmdProbeInputs v1alpha1.CmdProbeInputs `json:"cmdProbe/inputs,omitempty"`
|
||||
// RunProperty contains timeout, retry and interval for the probe
|
||||
RunProperties v1alpha1.RunProperty `json:"runProperties,omitempty"`
|
||||
// mode for k8s probe
|
||||
// it can be SOT, EOT, Edge
|
||||
Mode string `json:"mode,omitempty"`
|
||||
// ResponseTimeout Flag to hold the flag to response timeout for the cmdProbe
|
||||
ResponseTimeout int `json:"responseTimeout,omitempty"`
|
||||
}
|
||||
|
||||
type ProbeWithVerdict struct {
|
||||
Name string `json:"name"`
|
||||
Verdict model.ProbeVerdict `json:"verdict"`
|
||||
}
|
||||
|
||||
type PROMProbeAttributes struct {
|
||||
// Name of probe
|
||||
Name string `json:"name,omitempty"`
|
||||
// Type of probe
|
||||
Type string `json:"type,omitempty"`
|
||||
// inputs needed for the prometheus probe
|
||||
PromProbeInputs v1alpha1.PromProbeInputs `json:"promProbe/inputs,omitempty"`
|
||||
// RunProperty contains timeout, retry and interval for the probe
|
||||
RunProperties v1alpha1.RunProperty `json:"runProperties,omitempty"`
|
||||
// mode for k8s probe
|
||||
// it can be SOT, EOT, Edge
|
||||
Mode string `json:"mode,omitempty"`
|
||||
}
|
||||
|
||||
type K8SProbeAttributes struct {
|
||||
// Name of probe
|
||||
Name string `json:"name,omitempty"`
|
||||
// Type of probe
|
||||
Type string `json:"type,omitempty"`
|
||||
// inputs needed for the k8s probe
|
||||
K8sProbeInputs v1alpha1.K8sProbeInputs `json:"k8sProbe/inputs,omitempty"`
|
||||
// RunProperty contains timeout, retry and interval for the probe
|
||||
RunProperties v1alpha1.RunProperty `json:"runProperties,omitempty"`
|
||||
// mode for k8s probe
|
||||
// it can be SOT, EOT, Edge
|
||||
Mode string `json:"mode,omitempty"`
|
||||
}
|
||||
|
|
@ -0,0 +1,892 @@
|
|||
package probe
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
argoTypes "github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1"
|
||||
"github.com/litmuschaos/litmus/chaoscenter/graphql/server/graph/model"
|
||||
dbChaosExperiment "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/database/mongodb/chaos_experiment"
|
||||
dbSchemaProbe "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/database/mongodb/probe"
|
||||
|
||||
"github.com/ghodss/yaml"
|
||||
"github.com/litmuschaos/chaos-operator/api/litmuschaos/v1alpha1"
|
||||
)
|
||||
|
||||
func addHTTPProbeProperties(newProbe *dbSchemaProbe.Probe, request model.ProbeRequest) *dbSchemaProbe.Probe {
|
||||
|
||||
newProbe.HTTPProperties = &dbSchemaProbe.HTTPProbe{
|
||||
// Common Probe Properties
|
||||
ProbeTimeout: request.HTTPProperties.ProbeTimeout,
|
||||
Interval: request.HTTPProperties.Interval,
|
||||
EvaluationTimeout: request.HTTPProperties.EvaluationTimeout,
|
||||
// Unique Properties for HTTP Probe
|
||||
URL: request.HTTPProperties.URL,
|
||||
Method: dbSchemaProbe.Method{},
|
||||
}
|
||||
// HTTP Probe -> Attempt
|
||||
newProbe.HTTPProperties.Attempt = request.HTTPProperties.Attempt
|
||||
|
||||
// HTTP Probe -> Retry
|
||||
newProbe.HTTPProperties.Retry = request.HTTPProperties.Retry
|
||||
|
||||
// HTTP Probe -> ProbePollingInterval
|
||||
newProbe.HTTPProperties.PollingInterval = request.HTTPProperties.ProbePollingInterval
|
||||
|
||||
// HTTP Probe -> EvaluationTimeout
|
||||
newProbe.HTTPProperties.EvaluationTimeout = request.HTTPProperties.EvaluationTimeout
|
||||
|
||||
// HTTP Probe -> InitialDelay
|
||||
newProbe.HTTPProperties.InitialDelay = request.HTTPProperties.InitialDelay
|
||||
|
||||
// HTTP Probe -> StopOnFailureEnabled
|
||||
newProbe.HTTPProperties.StopOnFailure = request.HTTPProperties.StopOnFailure
|
||||
|
||||
// HTTP Probe -> InsecureSkipVerify
|
||||
newProbe.HTTPProperties.InsecureSkipVerify = request.HTTPProperties.InsecureSkipVerify
|
||||
|
||||
// HTTP Probe -> Method [GET or POST]
|
||||
if request.HTTPProperties.Method.Get != nil {
|
||||
newProbe.HTTPProperties.Method.GET = &dbSchemaProbe.GET{
|
||||
Criteria: request.HTTPProperties.Method.Get.Criteria,
|
||||
ResponseCode: request.HTTPProperties.Method.Get.ResponseCode,
|
||||
}
|
||||
} else if request.HTTPProperties.Method.Post != nil {
|
||||
newProbe.HTTPProperties.Method.POST = &dbSchemaProbe.POST{
|
||||
Criteria: request.HTTPProperties.Method.Post.Criteria,
|
||||
ResponseCode: request.HTTPProperties.Method.Post.ResponseCode,
|
||||
}
|
||||
|
||||
newProbe.HTTPProperties.Method.POST.ContentType = request.HTTPProperties.Method.Post.ContentType
|
||||
|
||||
newProbe.HTTPProperties.Method.POST.Body = request.HTTPProperties.Method.Post.Body
|
||||
|
||||
newProbe.HTTPProperties.Method.POST.BodyPath = request.HTTPProperties.Method.Post.BodyPath
|
||||
|
||||
}
|
||||
|
||||
return newProbe
|
||||
}
|
||||
|
||||
func addCMDProbeProperties(newProbe *dbSchemaProbe.Probe, request model.ProbeRequest) *dbSchemaProbe.Probe {
|
||||
newProbe.CMDProperties = &dbSchemaProbe.CMDProbe{
|
||||
// Common Probe Properties
|
||||
ProbeTimeout: request.CmdProperties.ProbeTimeout,
|
||||
Interval: request.CmdProperties.Interval,
|
||||
// Unique Properties for CMD Probe
|
||||
Command: request.CmdProperties.Command,
|
||||
Comparator: dbSchemaProbe.Comparator{
|
||||
Type: request.CmdProperties.Comparator.Type,
|
||||
Value: request.CmdProperties.Comparator.Value,
|
||||
Criteria: request.CmdProperties.Comparator.Criteria,
|
||||
},
|
||||
}
|
||||
// CMD Probe -> Attempt
|
||||
newProbe.CMDProperties.Attempt = request.CmdProperties.Attempt
|
||||
|
||||
// CMD Probe -> Retry
|
||||
newProbe.CMDProperties.Retry = request.CmdProperties.Retry
|
||||
|
||||
// CMD Probe -> ProbePollingInterval
|
||||
newProbe.CMDProperties.PollingInterval = request.CmdProperties.ProbePollingInterval
|
||||
|
||||
// CMD Probe -> EvaluationTimeout
|
||||
newProbe.CMDProperties.EvaluationTimeout = request.CmdProperties.EvaluationTimeout
|
||||
|
||||
// CMD Probe -> InitialDelaySeconds
|
||||
newProbe.CMDProperties.InitialDelay = request.CmdProperties.InitialDelay
|
||||
|
||||
// CMD Probe -> StopOnFailureEnabled
|
||||
newProbe.CMDProperties.StopOnFailure = request.CmdProperties.StopOnFailure
|
||||
|
||||
// CMD Probe -> Source
|
||||
if request.CmdProperties.Source != nil {
|
||||
var source *v1alpha1.SourceDetails
|
||||
err := json.Unmarshal([]byte(*request.CmdProperties.Source), &source)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
newProbe.CMDProperties.Source = &v1alpha1.SourceDetails{
|
||||
Image: source.Image,
|
||||
HostNetwork: source.HostNetwork,
|
||||
InheritInputs: source.InheritInputs,
|
||||
Args: source.Args,
|
||||
ENVList: source.ENVList,
|
||||
Labels: source.Labels,
|
||||
Annotations: source.Annotations,
|
||||
Command: source.Command,
|
||||
ImagePullPolicy: source.ImagePullPolicy,
|
||||
Privileged: source.Privileged,
|
||||
NodeSelector: source.NodeSelector,
|
||||
Volumes: source.Volumes,
|
||||
VolumesMount: source.VolumesMount,
|
||||
ImagePullSecrets: source.ImagePullSecrets,
|
||||
}
|
||||
}
|
||||
|
||||
return newProbe
|
||||
}
|
||||
|
||||
func addPROMProbeProperties(newProbe *dbSchemaProbe.Probe, request model.ProbeRequest) *dbSchemaProbe.Probe {
|
||||
newProbe.PROMProperties = &dbSchemaProbe.PROMProbe{
|
||||
// Common Probe Properties
|
||||
ProbeTimeout: request.PromProperties.ProbeTimeout,
|
||||
Interval: request.PromProperties.Interval,
|
||||
// Unique Properties for PROM Probe
|
||||
Endpoint: request.PromProperties.Endpoint,
|
||||
Comparator: dbSchemaProbe.Comparator{
|
||||
Type: request.PromProperties.Comparator.Type,
|
||||
Value: request.PromProperties.Comparator.Value,
|
||||
Criteria: request.PromProperties.Comparator.Criteria,
|
||||
},
|
||||
}
|
||||
// PROM Probe -> Attempt
|
||||
newProbe.PROMProperties.Attempt = request.PromProperties.Attempt
|
||||
|
||||
// PROM Probe -> Retry
|
||||
newProbe.PROMProperties.Retry = request.PromProperties.Retry
|
||||
|
||||
// PROM Probe -> ProbePollingInterval
|
||||
newProbe.PROMProperties.PollingInterval = request.PromProperties.ProbePollingInterval
|
||||
|
||||
// PROM Probe -> EvaluationTimeout
|
||||
newProbe.PROMProperties.EvaluationTimeout = request.PromProperties.EvaluationTimeout
|
||||
|
||||
// PROM Probe -> InitialDelaySeconds
|
||||
newProbe.PROMProperties.InitialDelay = request.PromProperties.InitialDelay
|
||||
|
||||
// PROM Probe -> StopOnFailureEnabled
|
||||
newProbe.PROMProperties.StopOnFailure = request.PromProperties.StopOnFailure
|
||||
|
||||
// PROM Probe -> Query
|
||||
newProbe.PROMProperties.Query = *request.PromProperties.Query
|
||||
|
||||
// PROM Probe -> Query Path
|
||||
newProbe.PROMProperties.QueryPath = request.PromProperties.QueryPath
|
||||
|
||||
return newProbe
|
||||
}
|
||||
|
||||
func addK8SProbeProperties(newProbe *dbSchemaProbe.Probe, request model.ProbeRequest) *dbSchemaProbe.Probe {
|
||||
newProbe.K8SProperties = &dbSchemaProbe.K8SProbe{
|
||||
// Common Probe Properties
|
||||
ProbeTimeout: request.K8sProperties.ProbeTimeout,
|
||||
Interval: request.K8sProperties.Interval,
|
||||
// Unique Properties for K8S Probe
|
||||
Version: request.K8sProperties.Version,
|
||||
Resource: request.K8sProperties.Resource,
|
||||
Operation: request.K8sProperties.Operation,
|
||||
}
|
||||
|
||||
// PROM Probe -> Attempt
|
||||
newProbe.K8SProperties.Attempt = request.K8sProperties.Attempt
|
||||
|
||||
// PROM Probe -> Retry
|
||||
newProbe.K8SProperties.Retry = request.K8sProperties.Retry
|
||||
|
||||
// PROM Probe -> ProbePollingInterval
|
||||
newProbe.K8SProperties.PollingInterval = request.K8sProperties.ProbePollingInterval
|
||||
|
||||
// PROM Probe -> EvaluationTimeout
|
||||
newProbe.K8SProperties.EvaluationTimeout = request.K8sProperties.EvaluationTimeout
|
||||
|
||||
// K8S Probe -> StopOnFailureEnabled
|
||||
newProbe.K8SProperties.StopOnFailure = request.K8sProperties.StopOnFailure
|
||||
|
||||
// K8S Probe -> Group
|
||||
newProbe.K8SProperties.Group = request.K8sProperties.Group
|
||||
|
||||
// K8S Probe -> Namespace
|
||||
newProbe.K8SProperties.Namespace = request.K8sProperties.Namespace
|
||||
|
||||
// K8S Probe -> Field Selector
|
||||
newProbe.K8SProperties.FieldSelector = request.K8sProperties.FieldSelector
|
||||
|
||||
// K8S Probe -> Label Selector
|
||||
newProbe.K8SProperties.LabelSelector = request.K8sProperties.LabelSelector
|
||||
|
||||
return newProbe
|
||||
}
|
||||
|
||||
// GenerateProbeManifest - Generates the types and returns a marshalled probe attribute configuration
|
||||
func GenerateProbeManifest(probe *model.Probe, mode model.Mode) (string, error) {
|
||||
if probe.Type == model.ProbeTypeHTTPProbe {
|
||||
|
||||
httpProbeURL := probe.HTTPProperties.URL
|
||||
var _probe HTTPProbeAttributes
|
||||
|
||||
_probe.Name = probe.Name
|
||||
_probe.Type = string(probe.Type)
|
||||
_probe.Mode = string(mode)
|
||||
|
||||
if probe.HTTPProperties.InsecureSkipVerify != nil {
|
||||
_probe.HTTPProbeInputs = v1alpha1.HTTPProbeInputs{
|
||||
InsecureSkipVerify: *probe.HTTPProperties.InsecureSkipVerify,
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if probe.HTTPProperties.Method.Get != nil {
|
||||
|
||||
_probe.HTTPProbeInputs = v1alpha1.HTTPProbeInputs{
|
||||
URL: httpProbeURL,
|
||||
Method: v1alpha1.HTTPMethod{
|
||||
Get: &v1alpha1.GetMethod{
|
||||
Criteria: probe.HTTPProperties.Method.Get.Criteria,
|
||||
ResponseCode: probe.HTTPProperties.Method.Get.ResponseCode,
|
||||
},
|
||||
},
|
||||
}
|
||||
} else if probe.HTTPProperties.Method.Post != nil {
|
||||
_probe.HTTPProbeInputs = v1alpha1.HTTPProbeInputs{
|
||||
URL: httpProbeURL,
|
||||
Method: v1alpha1.HTTPMethod{
|
||||
Post: &v1alpha1.PostMethod{
|
||||
Criteria: probe.HTTPProperties.Method.Post.Criteria,
|
||||
ResponseCode: probe.HTTPProperties.Method.Post.ResponseCode,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
if probe.HTTPProperties.Method.Post.ContentType != nil {
|
||||
_probe.HTTPProbeInputs.Method.Post.ContentType = *probe.HTTPProperties.Method.Post.ContentType
|
||||
}
|
||||
|
||||
if probe.HTTPProperties.Method.Post.Body != nil {
|
||||
_probe.HTTPProbeInputs.Method.Post.Body = *probe.HTTPProperties.Method.Post.Body
|
||||
}
|
||||
|
||||
if probe.HTTPProperties.Method.Post.BodyPath != nil {
|
||||
_probe.HTTPProbeInputs.Method.Post.BodyPath = *probe.HTTPProperties.Method.Post.BodyPath
|
||||
}
|
||||
}
|
||||
|
||||
_probe.RunProperties = v1alpha1.RunProperty{
|
||||
ProbeTimeout: probe.HTTPProperties.ProbeTimeout,
|
||||
Interval: probe.HTTPProperties.Interval,
|
||||
}
|
||||
|
||||
if probe.HTTPProperties.Attempt != nil {
|
||||
_probe.RunProperties.Attempt = *probe.HTTPProperties.Attempt
|
||||
}
|
||||
|
||||
if probe.HTTPProperties.Retry != nil {
|
||||
_probe.RunProperties.Retry = *probe.HTTPProperties.Retry
|
||||
}
|
||||
|
||||
if probe.HTTPProperties.ProbePollingInterval != nil {
|
||||
_probe.RunProperties.ProbePollingInterval = *probe.HTTPProperties.ProbePollingInterval
|
||||
}
|
||||
|
||||
if probe.HTTPProperties.EvaluationTimeout != nil {
|
||||
_probe.RunProperties.EvaluationTimeout = *probe.HTTPProperties.EvaluationTimeout
|
||||
}
|
||||
|
||||
if probe.HTTPProperties.StopOnFailure != nil {
|
||||
_probe.RunProperties.StopOnFailure = *probe.HTTPProperties.StopOnFailure
|
||||
}
|
||||
|
||||
y, err := json.Marshal(_probe)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(y), err
|
||||
} else if probe.Type == model.ProbeTypeCmdProbe {
|
||||
|
||||
var _probe CMDProbeAttributes
|
||||
|
||||
_probe.Name = probe.Name
|
||||
_probe.Type = string(probe.Type)
|
||||
_probe.Mode = string(mode)
|
||||
_probe.CmdProbeInputs = v1alpha1.CmdProbeInputs{
|
||||
Command: probe.CmdProperties.Command,
|
||||
Comparator: v1alpha1.ComparatorInfo{
|
||||
Type: probe.CmdProperties.Comparator.Type,
|
||||
Criteria: probe.CmdProperties.Comparator.Criteria,
|
||||
Value: probe.CmdProperties.Comparator.Value,
|
||||
},
|
||||
}
|
||||
|
||||
_probe.RunProperties = v1alpha1.RunProperty{
|
||||
ProbeTimeout: probe.CmdProperties.ProbeTimeout,
|
||||
Interval: probe.CmdProperties.Interval,
|
||||
}
|
||||
|
||||
if probe.CmdProperties.Attempt != nil {
|
||||
_probe.RunProperties.Attempt = *probe.CmdProperties.Attempt
|
||||
}
|
||||
|
||||
if probe.CmdProperties.Retry != nil {
|
||||
_probe.RunProperties.Retry = *probe.CmdProperties.Retry
|
||||
}
|
||||
|
||||
if probe.CmdProperties.ProbePollingInterval != nil {
|
||||
_probe.RunProperties.ProbePollingInterval = *probe.CmdProperties.ProbePollingInterval
|
||||
}
|
||||
|
||||
if probe.CmdProperties.EvaluationTimeout != nil {
|
||||
_probe.RunProperties.EvaluationTimeout = *probe.CmdProperties.EvaluationTimeout
|
||||
}
|
||||
|
||||
if probe.CmdProperties.InitialDelay != nil {
|
||||
_probe.RunProperties.InitialDelay = *probe.CmdProperties.InitialDelay
|
||||
}
|
||||
|
||||
if probe.CmdProperties.StopOnFailure != nil {
|
||||
_probe.RunProperties.StopOnFailure = *probe.CmdProperties.StopOnFailure
|
||||
}
|
||||
|
||||
y, err := json.Marshal(_probe)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(y), err
|
||||
} else if probe.Type == model.ProbeTypePromProbe {
|
||||
|
||||
var _probe PROMProbeAttributes
|
||||
|
||||
_probe.Name = probe.Name
|
||||
_probe.Type = string(probe.Type)
|
||||
_probe.Mode = string(mode)
|
||||
_probe.PromProbeInputs = v1alpha1.PromProbeInputs{
|
||||
Endpoint: probe.PromProperties.Endpoint,
|
||||
Comparator: v1alpha1.ComparatorInfo{
|
||||
Type: probe.PromProperties.Comparator.Type,
|
||||
Criteria: probe.PromProperties.Comparator.Criteria,
|
||||
Value: probe.PromProperties.Comparator.Value,
|
||||
},
|
||||
}
|
||||
|
||||
if probe.PromProperties.Query != nil {
|
||||
_probe.PromProbeInputs.Query = *probe.PromProperties.Query
|
||||
}
|
||||
|
||||
if probe.PromProperties.QueryPath != nil {
|
||||
_probe.PromProbeInputs.QueryPath = *probe.PromProperties.QueryPath
|
||||
}
|
||||
|
||||
_probe.RunProperties = v1alpha1.RunProperty{
|
||||
ProbeTimeout: probe.PromProperties.ProbeTimeout,
|
||||
Interval: probe.PromProperties.Interval,
|
||||
}
|
||||
|
||||
if probe.PromProperties.Attempt != nil {
|
||||
_probe.RunProperties.Attempt = *probe.PromProperties.Attempt
|
||||
}
|
||||
|
||||
if probe.PromProperties.Retry != nil {
|
||||
_probe.RunProperties.Retry = *probe.PromProperties.Retry
|
||||
}
|
||||
|
||||
if probe.PromProperties.ProbePollingInterval != nil {
|
||||
_probe.RunProperties.ProbePollingInterval = *probe.PromProperties.ProbePollingInterval
|
||||
}
|
||||
|
||||
if probe.PromProperties.EvaluationTimeout != nil {
|
||||
_probe.RunProperties.EvaluationTimeout = *probe.PromProperties.EvaluationTimeout
|
||||
}
|
||||
|
||||
if probe.PromProperties.InitialDelay != nil {
|
||||
_probe.RunProperties.InitialDelay = *probe.PromProperties.InitialDelay
|
||||
}
|
||||
|
||||
if probe.PromProperties.StopOnFailure != nil {
|
||||
_probe.RunProperties.StopOnFailure = *probe.PromProperties.StopOnFailure
|
||||
}
|
||||
|
||||
y, err := json.Marshal(_probe)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(y), err
|
||||
} else if probe.Type == model.ProbeTypeK8sProbe {
|
||||
|
||||
var _probe K8SProbeAttributes
|
||||
|
||||
_probe.Name = probe.Name
|
||||
_probe.Type = string(probe.Type)
|
||||
_probe.Mode = string(mode)
|
||||
_probe.K8sProbeInputs.Version = probe.K8sProperties.Version
|
||||
_probe.K8sProbeInputs.Resource = probe.K8sProperties.Resource
|
||||
_probe.K8sProbeInputs.Operation = probe.K8sProperties.Operation
|
||||
|
||||
if probe.K8sProperties.Group != nil {
|
||||
_probe.K8sProbeInputs.Group = *probe.K8sProperties.Group
|
||||
}
|
||||
|
||||
if probe.K8sProperties.Namespace != nil {
|
||||
_probe.K8sProbeInputs.Namespace = *probe.K8sProperties.Namespace
|
||||
}
|
||||
|
||||
if probe.K8sProperties.FieldSelector != nil {
|
||||
_probe.K8sProbeInputs.FieldSelector = *probe.K8sProperties.FieldSelector
|
||||
}
|
||||
|
||||
if probe.K8sProperties.LabelSelector != nil {
|
||||
_probe.K8sProbeInputs.LabelSelector = *probe.K8sProperties.LabelSelector
|
||||
}
|
||||
|
||||
_probe.RunProperties = v1alpha1.RunProperty{
|
||||
ProbeTimeout: probe.K8sProperties.ProbeTimeout,
|
||||
Interval: probe.K8sProperties.Interval,
|
||||
}
|
||||
|
||||
if probe.K8sProperties.Attempt != nil {
|
||||
_probe.RunProperties.Attempt = *probe.K8sProperties.Attempt
|
||||
}
|
||||
|
||||
if probe.K8sProperties.Retry != nil {
|
||||
_probe.RunProperties.Retry = *probe.K8sProperties.Retry
|
||||
}
|
||||
|
||||
if probe.K8sProperties.ProbePollingInterval != nil {
|
||||
_probe.RunProperties.ProbePollingInterval = *probe.K8sProperties.ProbePollingInterval
|
||||
}
|
||||
|
||||
if probe.K8sProperties.EvaluationTimeout != nil {
|
||||
_probe.RunProperties.EvaluationTimeout = *probe.K8sProperties.EvaluationTimeout
|
||||
}
|
||||
|
||||
if probe.K8sProperties.InitialDelay != nil {
|
||||
_probe.RunProperties.InitialDelay = *probe.K8sProperties.InitialDelay
|
||||
}
|
||||
|
||||
if probe.K8sProperties.StopOnFailure != nil {
|
||||
_probe.RunProperties.StopOnFailure = *probe.K8sProperties.StopOnFailure
|
||||
}
|
||||
|
||||
y, err := json.Marshal(_probe)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(y), err
|
||||
}
|
||||
return "", nil
|
||||
}
|
||||
|
||||
// ParseProbesFromManifest - Parses the manifest to return probes which is stored in the DB
|
||||
func ParseProbesFromManifest(wfType *dbChaosExperiment.ChaosExperimentType, manifest string) ([]dbChaosExperiment.Probes, error) {
|
||||
var (
|
||||
probes []dbChaosExperiment.Probes
|
||||
nonCronManifest argoTypes.Workflow
|
||||
cronManifest argoTypes.CronWorkflow
|
||||
)
|
||||
|
||||
if *wfType == "cronexperiment" {
|
||||
err := json.Unmarshal([]byte(manifest), &cronManifest)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to unmarshal experiment manifest, error: %s", err.Error())
|
||||
}
|
||||
|
||||
for _, template := range cronManifest.Spec.WorkflowSpec.Templates {
|
||||
artifact := template.Inputs.Artifacts
|
||||
|
||||
if len(artifact) > 0 {
|
||||
if artifact[0].Raw == nil {
|
||||
continue
|
||||
}
|
||||
var data = artifact[0].Raw.Data
|
||||
if len(data) > 0 {
|
||||
var (
|
||||
meta v1alpha1.ChaosEngine
|
||||
annotation = make(map[string]string)
|
||||
)
|
||||
|
||||
err := yaml.Unmarshal([]byte(data), &meta)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to unmarshal chaosengine, error: %s", err.Error())
|
||||
}
|
||||
if strings.ToLower(meta.Kind) == "chaosengine" {
|
||||
if meta.Annotations != nil {
|
||||
annotation = meta.Annotations
|
||||
}
|
||||
var annotationArray []string
|
||||
for _, key := range annotation {
|
||||
|
||||
var manifestAnnotation []dbChaosExperiment.ProbeAnnotations
|
||||
err := json.Unmarshal([]byte(key), &manifestAnnotation)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to unmarshal experiment annotation object, error: %s", err.Error())
|
||||
}
|
||||
for _, annotationKey := range manifestAnnotation {
|
||||
annotationArray = append(annotationArray, annotationKey.Name)
|
||||
}
|
||||
}
|
||||
probes = append(probes, dbChaosExperiment.Probes{
|
||||
artifact[0].Name,
|
||||
annotationArray,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
err := json.Unmarshal([]byte(manifest), &nonCronManifest)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to unmarshal experiment manifest, error: %s", err.Error())
|
||||
}
|
||||
|
||||
for _, template := range nonCronManifest.Spec.Templates {
|
||||
artifact := template.Inputs.Artifacts
|
||||
|
||||
if len(artifact) > 0 {
|
||||
if artifact[0].Raw == nil {
|
||||
continue
|
||||
}
|
||||
var data = artifact[0].Raw.Data
|
||||
if len(data) > 0 {
|
||||
var (
|
||||
meta v1alpha1.ChaosEngine
|
||||
annotation = make(map[string]string)
|
||||
)
|
||||
|
||||
err := yaml.Unmarshal([]byte(data), &meta)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to unmarshal chaosengine, error: %s", err.Error())
|
||||
}
|
||||
if strings.ToLower(meta.Kind) == "chaosengine" {
|
||||
if meta.Annotations != nil {
|
||||
annotation = meta.Annotations
|
||||
}
|
||||
var annotationArray []string
|
||||
for _, key := range annotation {
|
||||
|
||||
var manifestAnnotation []dbChaosExperiment.ProbeAnnotations
|
||||
err := json.Unmarshal([]byte(key), &manifestAnnotation)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to unmarshal experiment annotation object, error: %s", err.Error())
|
||||
}
|
||||
for _, annotationKey := range manifestAnnotation {
|
||||
annotationArray = append(annotationArray, annotationKey.Name)
|
||||
}
|
||||
}
|
||||
probes = append(probes, dbChaosExperiment.Probes{
|
||||
artifact[0].Name,
|
||||
annotationArray,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return probes, nil
|
||||
}
|
||||
|
||||
// GenerateExperimentManifestWithProbes - uses GenerateProbeManifest to get and store the respective probe attribute into Raw Data template for Non Cron Workflow
|
||||
func GenerateExperimentManifestWithProbes(manifest string, projectID string) (argoTypes.Workflow, error) {
|
||||
|
||||
var (
|
||||
probes []v1alpha1.ProbeAttributes
|
||||
backgroundContext = context.Background()
|
||||
nonCronManifest argoTypes.Workflow
|
||||
httpProbe HTTPProbeAttributes
|
||||
cmdProbe CMDProbeAttributes
|
||||
promProbe PROMProbeAttributes
|
||||
k8sProbe K8SProbeAttributes
|
||||
)
|
||||
|
||||
ctx, cancel := context.WithTimeout(backgroundContext, 10*time.Second)
|
||||
defer cancel()
|
||||
|
||||
err := json.Unmarshal([]byte(manifest), &nonCronManifest)
|
||||
if err != nil {
|
||||
return argoTypes.Workflow{}, fmt.Errorf("failed to unmarshal experiment manifest, error: %s", err.Error())
|
||||
}
|
||||
|
||||
for i, template := range nonCronManifest.Spec.Templates {
|
||||
artifact := template.Inputs.Artifacts
|
||||
|
||||
if len(artifact) > 0 {
|
||||
if artifact[0].Raw == nil {
|
||||
continue
|
||||
}
|
||||
var data = artifact[0].Raw.Data
|
||||
if len(data) > 0 {
|
||||
var (
|
||||
meta v1alpha1.ChaosEngine
|
||||
annotation = make(map[string]string)
|
||||
)
|
||||
|
||||
err := yaml.Unmarshal([]byte(data), &meta)
|
||||
if err != nil {
|
||||
return argoTypes.Workflow{}, fmt.Errorf("failed to unmarshal chaosengine, error: %s", err.Error())
|
||||
}
|
||||
if strings.ToLower(meta.Kind) == "chaosengine" {
|
||||
|
||||
probes = meta.Spec.Experiments[0].Spec.Probe
|
||||
|
||||
if meta.Annotations != nil {
|
||||
annotation = meta.Annotations
|
||||
}
|
||||
|
||||
for _, key := range annotation {
|
||||
var manifestAnnotation []dbChaosExperiment.ProbeAnnotations
|
||||
if strings.HasPrefix(key, "[{\"name\"") {
|
||||
err := json.Unmarshal([]byte(key), &manifestAnnotation)
|
||||
if err != nil {
|
||||
return argoTypes.Workflow{}, fmt.Errorf("failed to unmarshal experiment annotation object, error: %s", err.Error())
|
||||
}
|
||||
for _, annotationKey := range manifestAnnotation {
|
||||
probe, err := dbSchemaProbe.GetProbeByName(ctx, annotationKey.Name, projectID)
|
||||
if err != nil {
|
||||
return argoTypes.Workflow{}, fmt.Errorf("failed to fetch probe details, error: %s", err.Error())
|
||||
}
|
||||
|
||||
probeManifestString, err := GenerateProbeManifest(probe.GetOutputProbe(), annotationKey.Mode)
|
||||
if err != nil {
|
||||
return argoTypes.Workflow{}, fmt.Errorf("failed to generate probe manifest, error: %s", err.Error())
|
||||
}
|
||||
|
||||
if model.ProbeType(probe.Type) == model.ProbeTypeHTTPProbe {
|
||||
err := json.Unmarshal([]byte(probeManifestString), &httpProbe)
|
||||
if err != nil {
|
||||
return argoTypes.Workflow{}, fmt.Errorf("failed to unmarshal http probe, error: %s", err.Error())
|
||||
}
|
||||
|
||||
probes = append(probes, v1alpha1.ProbeAttributes{
|
||||
Name: httpProbe.Name,
|
||||
Type: httpProbe.Type,
|
||||
HTTPProbeInputs: &v1alpha1.HTTPProbeInputs{
|
||||
URL: httpProbe.HTTPProbeInputs.URL,
|
||||
InsecureSkipVerify: httpProbe.HTTPProbeInputs.InsecureSkipVerify,
|
||||
Method: v1alpha1.HTTPMethod(httpProbe.HTTPProbeInputs.Method),
|
||||
},
|
||||
RunProperties: httpProbe.RunProperties,
|
||||
Mode: httpProbe.Mode,
|
||||
})
|
||||
} else if model.ProbeType(probe.Type) == model.ProbeTypeCmdProbe {
|
||||
err := json.Unmarshal([]byte(probeManifestString), &cmdProbe)
|
||||
if err != nil {
|
||||
return argoTypes.Workflow{}, fmt.Errorf("failed to unmarshal cmd probe, error: %s", err.Error())
|
||||
}
|
||||
|
||||
probes = append(probes, v1alpha1.ProbeAttributes{
|
||||
Name: cmdProbe.Name,
|
||||
Type: cmdProbe.Type,
|
||||
CmdProbeInputs: &v1alpha1.CmdProbeInputs{
|
||||
Command: cmdProbe.CmdProbeInputs.Command,
|
||||
Comparator: cmdProbe.CmdProbeInputs.Comparator,
|
||||
},
|
||||
RunProperties: cmdProbe.RunProperties,
|
||||
Mode: cmdProbe.Mode,
|
||||
})
|
||||
} else if model.ProbeType(probe.Type) == model.ProbeTypePromProbe {
|
||||
err := json.Unmarshal([]byte(probeManifestString), &promProbe)
|
||||
if err != nil {
|
||||
return argoTypes.Workflow{}, fmt.Errorf("failed to unmarshal prom probe, error: %s", err.Error())
|
||||
}
|
||||
|
||||
probes = append(probes, v1alpha1.ProbeAttributes{
|
||||
Name: promProbe.Name,
|
||||
Type: promProbe.Type,
|
||||
PromProbeInputs: &v1alpha1.PromProbeInputs{
|
||||
Endpoint: promProbe.PromProbeInputs.Endpoint,
|
||||
Query: promProbe.PromProbeInputs.Query,
|
||||
QueryPath: promProbe.PromProbeInputs.QueryPath,
|
||||
Comparator: promProbe.PromProbeInputs.Comparator,
|
||||
},
|
||||
RunProperties: promProbe.RunProperties,
|
||||
Mode: promProbe.Mode,
|
||||
})
|
||||
} else if model.ProbeType(probe.Type) == model.ProbeTypeK8sProbe {
|
||||
err := json.Unmarshal([]byte(probeManifestString), &k8sProbe)
|
||||
if err != nil {
|
||||
return argoTypes.Workflow{}, fmt.Errorf("failed to unmarshal k8s probe, error: %s", err.Error())
|
||||
}
|
||||
|
||||
probes = append(probes, v1alpha1.ProbeAttributes{
|
||||
Name: k8sProbe.Name,
|
||||
Type: k8sProbe.Type,
|
||||
K8sProbeInputs: &v1alpha1.K8sProbeInputs{
|
||||
Group: k8sProbe.K8sProbeInputs.Group,
|
||||
Version: k8sProbe.K8sProbeInputs.Version,
|
||||
Resource: k8sProbe.K8sProbeInputs.Resource,
|
||||
ResourceNames: k8sProbe.K8sProbeInputs.ResourceNames,
|
||||
Namespace: k8sProbe.K8sProbeInputs.Namespace,
|
||||
FieldSelector: k8sProbe.K8sProbeInputs.FieldSelector,
|
||||
LabelSelector: k8sProbe.K8sProbeInputs.LabelSelector,
|
||||
Operation: k8sProbe.K8sProbeInputs.Operation,
|
||||
},
|
||||
RunProperties: k8sProbe.RunProperties,
|
||||
Mode: k8sProbe.Mode,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if len(meta.Spec.Experiments) > 0 {
|
||||
meta.Spec.Experiments[0].Spec.Probe = probes
|
||||
}
|
||||
|
||||
res, err := yaml.Marshal(&meta)
|
||||
if err != nil {
|
||||
return argoTypes.Workflow{}, errors.New("failed to marshal chaosengine")
|
||||
}
|
||||
nonCronManifest.Spec.Templates[i].Inputs.Artifacts[0].Raw.Data = string(res)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nonCronManifest, nil
|
||||
}
|
||||
|
||||
// GenerateCronExperimentManifestWithProbes - uses GenerateProbeManifest to get and store the respective probe attribute into Raw Data template
|
||||
func GenerateCronExperimentManifestWithProbes(manifest string, projectID string) (argoTypes.CronWorkflow, error) {
|
||||
|
||||
var (
|
||||
probes []v1alpha1.ProbeAttributes
|
||||
backgroundContext = context.Background()
|
||||
cronManifest argoTypes.CronWorkflow
|
||||
httpProbe HTTPProbeAttributes
|
||||
cmdProbe CMDProbeAttributes
|
||||
promProbe PROMProbeAttributes
|
||||
k8sProbe K8SProbeAttributes
|
||||
)
|
||||
|
||||
ctx, cancel := context.WithTimeout(backgroundContext, 10*time.Second)
|
||||
defer cancel()
|
||||
|
||||
if err := json.Unmarshal([]byte(manifest), &cronManifest); err != nil {
|
||||
return argoTypes.CronWorkflow{}, fmt.Errorf("failed to unmarshal experiment manifest, error: %s", err.Error())
|
||||
}
|
||||
|
||||
for i, template := range cronManifest.Spec.WorkflowSpec.Templates {
|
||||
artifact := template.Inputs.Artifacts
|
||||
|
||||
if len(artifact) > 0 {
|
||||
if artifact[0].Raw == nil {
|
||||
continue
|
||||
}
|
||||
var data = artifact[0].Raw.Data
|
||||
if len(data) > 0 {
|
||||
var (
|
||||
meta v1alpha1.ChaosEngine
|
||||
annotation = make(map[string]string)
|
||||
)
|
||||
|
||||
if err := yaml.Unmarshal([]byte(data), &meta); err != nil {
|
||||
return argoTypes.CronWorkflow{}, fmt.Errorf("failed to unmarshal chaosengine, error: %s", err.Error())
|
||||
}
|
||||
|
||||
if strings.ToLower(meta.Kind) == "chaosengine" {
|
||||
|
||||
probes = meta.Spec.Experiments[0].Spec.Probe
|
||||
|
||||
if meta.Annotations != nil {
|
||||
annotation = meta.Annotations
|
||||
}
|
||||
|
||||
for _, key := range annotation {
|
||||
var manifestAnnotation []dbChaosExperiment.ProbeAnnotations
|
||||
err := json.Unmarshal([]byte(key), &manifestAnnotation)
|
||||
if err != nil {
|
||||
return argoTypes.CronWorkflow{}, fmt.Errorf("failed to unmarshal experiment annotation object, error: %s", err.Error())
|
||||
}
|
||||
for _, annotationKey := range manifestAnnotation {
|
||||
probe, err := dbSchemaProbe.GetProbeByName(ctx, annotationKey.Name, projectID)
|
||||
if err != nil {
|
||||
return argoTypes.CronWorkflow{}, fmt.Errorf("failed to fetch probe details, error: %s", err.Error())
|
||||
}
|
||||
|
||||
probeManifestString, err := GenerateProbeManifest(probe.GetOutputProbe(), annotationKey.Mode)
|
||||
|
||||
if model.ProbeType(probe.Type) == model.ProbeTypeHTTPProbe {
|
||||
if err := json.Unmarshal([]byte(probeManifestString), &httpProbe); err != nil {
|
||||
return argoTypes.CronWorkflow{}, fmt.Errorf("failed to unmarshal http probe, error: %s", err.Error())
|
||||
}
|
||||
|
||||
probes = append(probes, v1alpha1.ProbeAttributes{
|
||||
Name: httpProbe.Name,
|
||||
Type: httpProbe.Type,
|
||||
HTTPProbeInputs: &v1alpha1.HTTPProbeInputs{
|
||||
URL: httpProbe.HTTPProbeInputs.URL,
|
||||
InsecureSkipVerify: httpProbe.HTTPProbeInputs.InsecureSkipVerify,
|
||||
Method: v1alpha1.HTTPMethod(httpProbe.HTTPProbeInputs.Method),
|
||||
},
|
||||
RunProperties: httpProbe.RunProperties,
|
||||
Mode: httpProbe.Mode,
|
||||
})
|
||||
} else if model.ProbeType(probe.Type) == model.ProbeTypeCmdProbe {
|
||||
if err := json.Unmarshal([]byte(probeManifestString), &cmdProbe); err != nil {
|
||||
return argoTypes.CronWorkflow{}, fmt.Errorf("failed to unmarshal cmd probe, error: %s", err.Error())
|
||||
}
|
||||
|
||||
probes = append(probes, v1alpha1.ProbeAttributes{
|
||||
Name: cmdProbe.Name,
|
||||
Type: cmdProbe.Type,
|
||||
CmdProbeInputs: &v1alpha1.CmdProbeInputs{
|
||||
Command: cmdProbe.CmdProbeInputs.Command,
|
||||
Comparator: cmdProbe.CmdProbeInputs.Comparator,
|
||||
},
|
||||
RunProperties: cmdProbe.RunProperties,
|
||||
Mode: cmdProbe.Mode,
|
||||
})
|
||||
} else if model.ProbeType(probe.Type) == model.ProbeTypePromProbe {
|
||||
if err := json.Unmarshal([]byte(probeManifestString), &promProbe); err != nil {
|
||||
return argoTypes.CronWorkflow{}, fmt.Errorf("failed to unmarshal prom probe, error: %s", err.Error())
|
||||
}
|
||||
|
||||
probes = append(probes, v1alpha1.ProbeAttributes{
|
||||
Name: promProbe.Name,
|
||||
Type: promProbe.Type,
|
||||
PromProbeInputs: &v1alpha1.PromProbeInputs{
|
||||
Endpoint: promProbe.PromProbeInputs.Endpoint,
|
||||
Query: promProbe.PromProbeInputs.Query,
|
||||
QueryPath: promProbe.PromProbeInputs.QueryPath,
|
||||
Comparator: promProbe.PromProbeInputs.Comparator,
|
||||
},
|
||||
RunProperties: promProbe.RunProperties,
|
||||
Mode: promProbe.Mode,
|
||||
})
|
||||
} else if model.ProbeType(probe.Type) == model.ProbeTypeK8sProbe {
|
||||
if err := json.Unmarshal([]byte(probeManifestString), &k8sProbe); err != nil {
|
||||
return argoTypes.CronWorkflow{}, fmt.Errorf("failed to unmarshal k8s probe, error: %s", err.Error())
|
||||
}
|
||||
|
||||
probes = append(probes, v1alpha1.ProbeAttributes{
|
||||
Name: k8sProbe.Name,
|
||||
Type: k8sProbe.Type,
|
||||
K8sProbeInputs: &v1alpha1.K8sProbeInputs{
|
||||
Group: k8sProbe.K8sProbeInputs.Group,
|
||||
Version: k8sProbe.K8sProbeInputs.Version,
|
||||
Resource: k8sProbe.K8sProbeInputs.Resource,
|
||||
ResourceNames: k8sProbe.K8sProbeInputs.ResourceNames,
|
||||
Namespace: k8sProbe.K8sProbeInputs.Namespace,
|
||||
FieldSelector: k8sProbe.K8sProbeInputs.FieldSelector,
|
||||
LabelSelector: k8sProbe.K8sProbeInputs.LabelSelector,
|
||||
Operation: k8sProbe.K8sProbeInputs.Operation,
|
||||
},
|
||||
RunProperties: k8sProbe.RunProperties,
|
||||
Mode: k8sProbe.Mode,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if len(meta.Spec.Experiments) > 0 {
|
||||
meta.Spec.Experiments[0].Spec.Probe = probes
|
||||
}
|
||||
|
||||
res, err := yaml.Marshal(&meta)
|
||||
if err != nil {
|
||||
return argoTypes.CronWorkflow{}, fmt.Errorf("failed to marshal chaosengine, error: %s", err.Error())
|
||||
}
|
||||
cronManifest.Spec.WorkflowSpec.Templates[i].Inputs.Artifacts[0].Raw.Data = string(res)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return cronManifest, nil
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
package utils
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"github.com/litmuschaos/chaos-operator/api/litmuschaos/v1alpha1"
|
||||
"github.com/litmuschaos/litmus/chaoscenter/graphql/server/graph/model"
|
||||
)
|
||||
|
||||
func TransformProbe(probeList []v1alpha1.ProbeAttributes) []v1alpha1.ProbeAttributes {
|
||||
var updateProbeList []v1alpha1.ProbeAttributes
|
||||
|
||||
for _, probe := range probeList {
|
||||
updatedProbe := v1alpha1.ProbeAttributes{
|
||||
Name: probe.Name,
|
||||
Type: probe.Type,
|
||||
Mode: probe.Mode,
|
||||
Data: probe.Data,
|
||||
RunProperties: v1alpha1.RunProperty{
|
||||
ProbeTimeout: validateUnits(probe.RunProperties.ProbeTimeout, "s"),
|
||||
Interval: validateUnits(probe.RunProperties.Interval, "s"),
|
||||
Retry: probe.RunProperties.Retry,
|
||||
Attempt: probe.RunProperties.Attempt,
|
||||
InitialDelay: validateUnits(probe.RunProperties.InitialDelay, "s"),
|
||||
EvaluationTimeout: validateUnits(probe.RunProperties.EvaluationTimeout, "s"),
|
||||
ProbePollingInterval: validateUnits(probe.RunProperties.ProbePollingInterval, "s"),
|
||||
StopOnFailure: probe.RunProperties.StopOnFailure,
|
||||
},
|
||||
}
|
||||
|
||||
if probe.RunProperties.InitialDelaySeconds != 0 {
|
||||
updatedProbe.RunProperties.InitialDelay = validateUnits(strconv.Itoa(probe.RunProperties.InitialDelaySeconds), "s")
|
||||
}
|
||||
|
||||
switch model.ProbeType(probe.Type) {
|
||||
case model.ProbeTypeHTTPProbe:
|
||||
updatedProbe.RunProperties.ProbeTimeout = validateUnits(probe.RunProperties.ProbeTimeout, "ms")
|
||||
updatedProbe.HTTPProbeInputs = probe.HTTPProbeInputs
|
||||
case model.ProbeTypeCmdProbe:
|
||||
updatedProbe.CmdProbeInputs = probe.CmdProbeInputs
|
||||
case model.ProbeTypeK8sProbe:
|
||||
updatedProbe.K8sProbeInputs = probe.K8sProbeInputs
|
||||
case model.ProbeTypePromProbe:
|
||||
updatedProbe.PromProbeInputs = probe.PromProbeInputs
|
||||
}
|
||||
updateProbeList = append(updateProbeList, updatedProbe)
|
||||
}
|
||||
return updateProbeList
|
||||
}
|
||||
|
|
@ -6,6 +6,7 @@ import (
|
|||
"fmt"
|
||||
"math/rand"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
|
@ -17,6 +18,7 @@ import (
|
|||
)
|
||||
|
||||
const GRPCErrorPrefix string = "rpc error: code = Unknown desc ="
|
||||
const UnitValidationRegex string = `\b(\d+(\.\d+)?)((ns|us|ms|s|m|h))\b`
|
||||
|
||||
// WriteHeaders adds important headers to API responses
|
||||
func WriteHeaders(w *gin.ResponseWriter, statusCode int) {
|
||||
|
|
@ -122,3 +124,17 @@ func ParseGRPCError(err error) error {
|
|||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func validateUnits(value string, unit string) string {
|
||||
if len(value) == 0 {
|
||||
return ""
|
||||
}
|
||||
matched, err := regexp.MatchString(UnitValidationRegex, value)
|
||||
if err != nil {
|
||||
return value
|
||||
}
|
||||
if !matched {
|
||||
return fmt.Sprintf("%s%s", value, unit)
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,11 +7,11 @@ require (
|
|||
github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32
|
||||
github.com/gorilla/websocket v1.5.0
|
||||
github.com/kelseyhightower/envconfig v1.4.0
|
||||
github.com/litmuschaos/chaos-operator v0.0.0-20230109130222-de7c74a937a9
|
||||
github.com/litmuschaos/chaos-operator v0.0.0-20230718113617-6819a4be12e4
|
||||
github.com/sirupsen/logrus v1.8.1
|
||||
gopkg.in/yaml.v2 v2.4.0
|
||||
k8s.io/api v0.23.3
|
||||
k8s.io/apimachinery v0.23.3
|
||||
k8s.io/api v0.26.0
|
||||
k8s.io/apimachinery v0.26.0
|
||||
k8s.io/client-go v12.0.0+incompatible
|
||||
)
|
||||
|
||||
|
|
@ -20,7 +20,7 @@ require (
|
|||
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/emicklei/go-restful v2.15.0+incompatible // indirect
|
||||
github.com/go-logr/logr v1.2.2 // indirect
|
||||
github.com/go-logr/logr v1.2.3 // indirect
|
||||
github.com/go-openapi/jsonpointer v0.19.5 // indirect
|
||||
github.com/go-openapi/jsonreference v0.19.6 // indirect
|
||||
github.com/go-openapi/swag v0.19.15 // indirect
|
||||
|
|
@ -43,7 +43,7 @@ require (
|
|||
golang.org/x/net v0.6.0 // indirect
|
||||
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 // indirect
|
||||
golang.org/x/sys v0.5.0 // indirect
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
|
||||
golang.org/x/term v0.5.0 // indirect
|
||||
golang.org/x/text v0.7.0 // indirect
|
||||
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 // indirect
|
||||
google.golang.org/appengine v1.6.7 // indirect
|
||||
|
|
@ -52,11 +52,11 @@ require (
|
|||
google.golang.org/protobuf v1.28.1 // indirect
|
||||
gopkg.in/inf.v0 v0.9.1 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
k8s.io/klog/v2 v2.40.1 // indirect
|
||||
k8s.io/klog/v2 v2.80.1 // indirect
|
||||
k8s.io/kube-openapi v0.0.0-20220124234850-424119656bbf // indirect
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 // indirect
|
||||
k8s.io/utils v0.0.0-20221107191617-1a15be271d1d // indirect
|
||||
sigs.k8s.io/controller-runtime v0.11.1 // indirect
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.2.1 // indirect
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
|
||||
sigs.k8s.io/yaml v1.3.0 // indirect
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -91,8 +91,8 @@ github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7
|
|||
github.com/go-logr/logr v0.2.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU=
|
||||
github.com/go-logr/logr v0.4.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU=
|
||||
github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||
github.com/go-logr/logr v1.2.2 h1:ahHml/yUpnlb96Rp8HCvtYVPY8ZYpxq3g7UYchIYwbs=
|
||||
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||
github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0=
|
||||
github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||
github.com/go-openapi/jsonpointer v0.19.2/go.mod h1:3akKfEdA7DF1sugOqz1dVQHBcuDBPKZGEoHC/NkiQRg=
|
||||
github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg=
|
||||
github.com/go-openapi/jsonpointer v0.19.5 h1:gZr+CIYByUqjcgeLXnQu2gHYQC9o73G2XUeOFYEICuY=
|
||||
|
|
@ -209,8 +209,8 @@ github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA=
|
|||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/litmuschaos/chaos-operator v0.0.0-20230109130222-de7c74a937a9 h1:5VkAw2Zqf6xXEElnmFTVuNiP+YVZqH2Qr2t/yv6eI5g=
|
||||
github.com/litmuschaos/chaos-operator v0.0.0-20230109130222-de7c74a937a9/go.mod h1:jRA6jKGed6ytLDJ7897yr2Kr2ygg+cuRXJqwvNmE4Bw=
|
||||
github.com/litmuschaos/chaos-operator v0.0.0-20230718113617-6819a4be12e4 h1:GVU1jK8Gb9OaYuU3iDyU/FE3uZYmBwAEB95VY41SYJ8=
|
||||
github.com/litmuschaos/chaos-operator v0.0.0-20230718113617-6819a4be12e4/go.mod h1:i6wMEZRQoHjUy4bhq6ePuA2FChX1b7WBR2lH09iM0tU=
|
||||
github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
||||
github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
||||
github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
|
||||
|
|
@ -375,8 +375,9 @@ golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|||
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.5.0 h1:n2a8QNdAb0sZNpU9R1ALUXBbY+w51fCQDN+7EdxNBsY=
|
||||
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||
golang.org/x/text v0.3.8 h1:nAL+RVCQ9uMn3vJZbV+MRnydTJFPf8qqY42YiA6MrqY=
|
||||
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
|
||||
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
|
|
@ -564,15 +565,15 @@ k8s.io/gengo v0.0.0-20210813121822-485abfe95c7c/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAE
|
|||
k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE=
|
||||
k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y=
|
||||
k8s.io/klog/v2 v2.8.0/go.mod h1:hy9LJ/NvuK+iVyP4Ehqva4HxZG/oXyIS3n3Jmire4Ec=
|
||||
k8s.io/klog/v2 v2.40.1 h1:P4RRucWk/lFOlDdkAr3mc7iWFkgKrZY9qZMAgek06S4=
|
||||
k8s.io/klog/v2 v2.40.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
|
||||
k8s.io/klog/v2 v2.80.1 h1:atnLQ121W371wYYFawwYx1aEY2eUfs4l3J72wtgAwV4=
|
||||
k8s.io/klog/v2 v2.80.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
|
||||
k8s.io/kube-openapi v0.0.0-20210305001622-591a79e4bda7/go.mod h1:wXW5VT87nVfh/iLV8FpR2uDvrFyomxbtb1KivDbvPTE=
|
||||
k8s.io/kube-openapi v0.0.0-20220124234850-424119656bbf h1:M9XBsiMslw2lb2ZzglC0TOkBPK5NQi0/noUrdnoFwUg=
|
||||
k8s.io/kube-openapi v0.0.0-20220124234850-424119656bbf/go.mod h1:sX9MT8g7NVZM5lVL/j8QyCCJe8YSMW30QvGZWaCIDIk=
|
||||
k8s.io/utils v0.0.0-20201110183641-67b214c5f920/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
k8s.io/utils v0.0.0-20210802155522-efc7438f0176/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 h1:HNSDgDCrr/6Ly3WEGKZftiE7IY19Vz2GdbOCyI4qqhc=
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
k8s.io/utils v0.0.0-20221107191617-1a15be271d1d h1:0Smp/HP1OH4Rvhe+4B8nWGERtlqAGSftbSbbmm45oFs=
|
||||
k8s.io/utils v0.0.0-20221107191617-1a15be271d1d/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
|
||||
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
|
||||
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
|
||||
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
|
||||
|
|
@ -580,8 +581,8 @@ sigs.k8s.io/controller-runtime v0.11.1 h1:7YIHT2QnHJArj/dk9aUkYhfqfK5cIxPOX5gPEC
|
|||
sigs.k8s.io/controller-runtime v0.11.1/go.mod h1:KKwLiTooNGu+JmLZGn9Sl3Gjmfj66eMbCQznLP5zcqA=
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.0.2/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK1F7G282QMXDPYydCw=
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.1.0/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK1F7G282QMXDPYydCw=
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.2.1 h1:bKCqE9GvQ5tiVHn5rfn1r+yao3aLQEaLzkkmAkf+A6Y=
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.2.1/go.mod h1:j/nl6xW8vLS49O8YvXW1ocPhZawJtm+Yrr7PPRQ0Vg4=
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 h1:PRbqxJClWWYMNV1dhaG4NsibJbArud9kFxnAMREiWFE=
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.2.3/go.mod h1:qjx8mGObPmV2aSZepjQjbmb2ihdVs8cGKBraizNC69E=
|
||||
sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc=
|
||||
sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo=
|
||||
sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8=
|
||||
|
|
|
|||
|
|
@ -70,8 +70,8 @@ func getChaosData(nodeStatus v1alpha13.NodeStatus, engineName, engineNS string,
|
|||
expRes.Annotations = nil
|
||||
cd.ChaosResult = expRes
|
||||
cd.ProbeSuccessPercentage = expRes.Status.ExperimentStatus.ProbeSuccessPercentage
|
||||
if expRes.Status.ExperimentStatus.FailureOutput != nil {
|
||||
cd.FailStep = expRes.Status.ExperimentStatus.FailureOutput.FailedStep
|
||||
if expRes.Status.ExperimentStatus.ErrorOutput != nil {
|
||||
cd.FailStep = fmt.Sprintf("%s : %s", expRes.Status.ExperimentStatus.ErrorOutput.ErrorCode, expRes.Status.ExperimentStatus.ErrorOutput.Reason)
|
||||
}
|
||||
}
|
||||
return cd, nil
|
||||
|
|
|
|||
|
|
@ -493,7 +493,7 @@ func (g *gitOpsService) syncDBToGit(ctx context.Context, config GitConfig) error
|
|||
} else {
|
||||
err = g.updateWorkflow(string(data), wfID, file, config)
|
||||
if err != nil {
|
||||
logrus.Error("Error while updating workflow db entry : " + file + " | " + err.Error())
|
||||
logrus.Error("Error while updating experiment db entry : " + file + " | " + err.Error())
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue