Skip to content

Commit

Permalink
feat(operator): add-pressure-exec replace job(get pod log)
Browse files Browse the repository at this point in the history
  • Loading branch information
moonman committed May 15, 2023
1 parent 828d9ea commit 14e5922
Show file tree
Hide file tree
Showing 9 changed files with 521 additions and 339 deletions.
21 changes: 16 additions & 5 deletions shardingsphere-operator/api/v1alpha1/shardingsphere_chaos_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,24 @@ type ShardingSphereChaos struct {

// ShardingSphereChaosSpec defines the desired state of ShardingSphereChaos
type ShardingSphereChaosSpec struct {
InjectJob JobSpec `json:"injectJob,omitempty"`
EmbedChaos `json:",inline"`
Expect Expect `json:"expect,omitempty"`
InjectJob JobSpec `json:"injectJob,omitempty"`
EmbedChaos `json:",inline"`
PressureCfg PressureCfg `json:"pressureCfg"`
}

type Expect struct {
Verify string `json:"verify,omitempty"`
type PressureCfg struct {
ZkHost string `json:"zkHost,omitempty"`
SsHost string `json:"ssHost"`
Duration metav1.Duration `json:"duration"`
ReqTime metav1.Duration `json:"reqTime"`
DistSQLs []DistSQL `json:"distSQLs,omitempty"`
ConcurrentNum int `json:"concurrentNum"`
ReqNum int `json:"reqNum"`
}

type DistSQL struct {
SQL string `json:"sql"`
Args []string `json:"args"`
}

type Script string
Expand Down
61 changes: 45 additions & 16 deletions shardingsphere-operator/api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (
"flag"
"strings"

"github.com/apache/shardingsphere-on-cloud/shardingsphere-operator/pkg/pressure"

"github.com/apache/shardingsphere-on-cloud/shardingsphere-operator/api/v1alpha1"
"github.com/apache/shardingsphere-on-cloud/shardingsphere-operator/pkg/controllers"
sschaos "github.com/apache/shardingsphere-on-cloud/shardingsphere-operator/pkg/kubernetes/chaosmesh"
Expand Down Expand Up @@ -179,14 +181,15 @@ var featureGatesHandlers = map[string]FeatureGateHandler{
return err
}
if err := (&controllers.ShardingSphereChaosReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
Log: mgr.GetLogger(),
Chaos: sschaos.NewChaos(mgr.GetClient()),
Job: job.NewJob(mgr.GetClient()),
ConfigMap: configmap.NewConfigMapClient(mgr.GetClient()),
Events: mgr.GetEventRecorderFor("shardingsphere-chaos-controller"),
ClientSet: clientset,
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
Log: mgr.GetLogger(),
Chaos: sschaos.NewChaos(mgr.GetClient()),
Job: job.NewJob(mgr.GetClient()),
ExecRecorder: make([]*pressure.Pressure, 0),
ConfigMap: configmap.NewConfigMapClient(mgr.GetClient()),
Events: mgr.GetEventRecorderFor("shardingsphere-chaos-controller"),
ClientSet: clientset,
}).SetupWithManager(mgr); err != nil {
logger.Error(err, "unable to create controller", "controller", "ShardingSphereChaos")
return err
Expand Down
4 changes: 3 additions & 1 deletion shardingsphere-operator/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ require (
bou.ke/monkey v1.0.2
github.com/antlr/antlr4 v0.0.0-20181218183524-be58ebffde8e
github.com/chaos-mesh/chaos-mesh/api v0.0.0-20230410023700-25a841a23cd2
github.com/golang/mock v1.6.0
github.com/database-mesh/golang-sdk v0.0.0-20230420101548-53265cd9883a
github.com/go-logr/logr v1.2.4
github.com/golang/mock v1.6.0
github.com/onsi/ginkgo/v2 v2.8.0
github.com/onsi/gomega v1.26.0
github.com/prometheus/client_golang v1.14.0
Expand All @@ -25,6 +25,7 @@ require (
require github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 // indirect

require (
github.com/DATA-DOG/go-sqlmock v1.5.0 // indirect
github.com/aws/aws-sdk-go-v2 v1.17.5 // indirect
github.com/aws/aws-sdk-go-v2/config v1.18.4 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.13.4 // indirect
Expand All @@ -50,6 +51,7 @@ require (
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/go-sql-driver/mysql v1.7.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
Expand Down
6 changes: 6 additions & 0 deletions shardingsphere-operator/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ bou.ke/monkey v1.0.2/go.mod h1:OqickVX3tNx6t33n1xvtTtu85YN5s6cKwVug+oHMaIA=
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60=
github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 h1:s6gZFSlWYmbqAuRjVTiNNhvNRfY2Wxp9nhfyel4rklc=
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137/go.mod h1:OMCwj8VM1Kc9e19TLln2VL61YJF0x1XFtfdL4JdbSyE=
Expand Down Expand Up @@ -93,6 +95,10 @@ github.com/go-openapi/jsonreference v0.20.2 h1:3sVjiK66+uXK/6oQ8xgcRKcFgQ5KXa2Kv
github.com/go-openapi/jsonreference v0.20.2/go.mod h1:Bl1zwGIM8/wsvqjsOQLJ/SH+En5Ap4rVB5KVcIDZG2k=
github.com/go-openapi/swag v0.22.3 h1:yMBqmnQ0gyZvEb/+KzuWZOXgllrXT4SADYbvDaXHv/g=
github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14=
github.com/go-sql-driver/mysql v1.7.0 h1:ueSltNNllEqE3qcWBTD0iQd3IpL/6U+mJxLkazJ7YPc=
github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
github.com/go-sql-driver/mysql v1.7.1 h1:lUIinVbN1DY0xBg0eMOzmmtGoHwWBbvnWubQUrtU8EI=
github.com/go-sql-driver/mysql v1.7.1/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
Expand Down
Loading

0 comments on commit 14e5922

Please sign in to comment.