Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update images and config #175

Merged
merged 4 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion chaosmeta-deploy/templates/chaosmeta-daemon.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ spec:
# chaos-role.chaosmeta.io: chaosmeta-daemon
containers:
- name: chaosmeta-daemon
image: registry.cn-hangzhou.aliyuncs.com/chaosmeta/chaosmeta-daemon:v0.5.3
image: registry.cn-hangzhou.aliyuncs.com/chaosmeta/chaosmeta-daemon:v0.5.1
securityContext:
privileged: true
volumeMounts:
Expand Down
9 changes: 5 additions & 4 deletions chaosmeta-deploy/templates/chaosmeta-inject.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ spec:
- --leader-elect
command:
- /manager
image: registry.cn-hangzhou.aliyuncs.com/chaosmeta/chaosmeta-inject-controller:v0.1.2
image: registry.cn-hangzhou.aliyuncs.com/chaosmeta/chaosmeta-inject-controller:v0.1.3
imagePullPolicy: Always
env:
- name: DEFAULTNAMESPACE
Expand All @@ -262,7 +262,7 @@ spec:
livenessProbe:
httpGet:
path: /healthz
port: 8081
port: 8083
initialDelaySeconds: 20
periodSeconds: 20
failureThreshold: 3
Expand All @@ -274,7 +274,7 @@ spec:
readinessProbe:
httpGet:
path: /readyz
port: 8081
port: 8083
initialDelaySeconds: 20
periodSeconds: 20
failureThreshold: 3
Expand Down Expand Up @@ -374,12 +374,13 @@ data:
"executor": {
"mode": "daemonset",
"executor": "chaosmetad",
"version": "0.5.3",
"version": "0.5.1",
"agentConfig": {
"agentPort": 29595
},
"daemonsetConfig": {
"localExecPath": "/tmp",
"daemonName": "chaosmeta-daemon",
"daemonNs": "chaosmeta",
"daemonLabel": {
"app.chaosmeta.io": "chaosmeta-daemon"
Expand Down
4 changes: 2 additions & 2 deletions chaosmeta-deploy/templates/chaosmeta-platform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ spec:
serviceAccountName: chaosmeta-platform
containers:
- name: chaosmeta-platform
image: registry.cn-hangzhou.aliyuncs.com/chaosmeta/chaosmeta-platform:v0.6.1
image: registry.cn-hangzhou.aliyuncs.com/chaosmeta/chaosmeta-platform:v0.6.3
resources:
requests:
cpu: "1"
Expand All @@ -101,7 +101,7 @@ spec:
- name: chaosmeta-config
mountPath: /home/admin/conf
- name: chaosmeta-platform-frontend
image: registry.cn-hangzhou.aliyuncs.com/chaosmeta/chaosmeta-platform-frontend:v0.6.1
image: registry.cn-hangzhou.aliyuncs.com/chaosmeta/chaosmeta-platform-frontend:v0.6.3
imagePullPolicy: Always
ports:
- containerPort: 8000
Expand Down
2 changes: 1 addition & 1 deletion chaosmeta-deploy/templates/chaosmeta-workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ spec:
- args:
- server
env: []
image: registry.cn-hangzhou.aliyuncs.com/chaosmeta/argocli:v3.4.10
image: registry.cn-hangzhou.aliyuncs.com/chaosmeta/argocli:v3.4.10.3
name: argo-server
ports:
- containerPort: 2746
Expand Down
14 changes: 7 additions & 7 deletions chaosmeta-inject-operator/config/chaosmeta-inject.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"executor": {
"mode": "daemonset",
"executor": "chaosmetad",
"version": "0.5.3",
"version": "0.5.1",
"agentConfig": {
"agentPort": 29595
},
Expand All @@ -21,14 +21,14 @@
"daemonName": "chaosmeta-daemon"
},
"middlewareConfig" : {
"url" : "https://shell-api.alipay.com",
"url" : "todo",
"mistConfig" : {
"antVipUrl" : "antvip-pool.stable.alipay.net",
"bkmiUrl" : "bkmi-pool.stable.global.alipay.com",
"appName" : "antchaos",
"antVipUrl" : "todo",
"bkmiUrl" : "todo",
"appName" : "chaosmetainject",
"tenant" : "ALIPAY",
"mode" : "local",
"secretName" : "antchaos_fault_inject_offline"
"mode" : "todo",
"secretName" : "todo"
}
}
}
Expand Down
24 changes: 0 additions & 24 deletions chaosmeta-inject-operator/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,6 @@ require (
sigs.k8s.io/controller-runtime v0.14.1
)

require (
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/hashicorp/go-multierror v1.1.0 // indirect
github.com/jpillora/backoff v1.0.0 // indirect
github.com/magiconair/properties v1.8.5 // indirect
github.com/natefinch/lumberjack v2.0.0+incompatible // indirect
github.com/valyala/fastjson v1.5.1 // indirect
gitlab.alipay-inc.com/naming/naming-sdk-go v1.2.3 // indirect
gitlab.alipay-inc.com/sofa-go/sofa-antvip-client-go v1.6.8 // indirect
gitlab.alipay-inc.com/sofa-go/sofa-bolt-go v0.3.4 // indirect
gitlab.alipay-inc.com/sofa-go/sofa-bolt-simplemap-go v0.2.1 // indirect
gitlab.alipay-inc.com/sofa-go/sofa-conn-go v0.2.7 // indirect
gitlab.alipay-inc.com/sofa-go/sofa-helper-go v0.1.0 // indirect
gitlab.alipay-inc.com/sofa-go/sofa-hessian-go v0.2.4 // indirect
gitlab.alipay-inc.com/sofa-go/sofa-logger-go v0.2.5 // indirect
gitlab.alipay-inc.com/sofa-go/sofa-registry-client-go v1.1.0 // indirect
gitlab.alipay-inc.com/sofa-go/sofa-registry-proto-go v0.1.1 // indirect
gitlab.alipay-inc.com/sofa-go/sofa-syncpool-go v0.1.3 // indirect
gitlab.alipay-inc.com/sofa-go/sofa-writer-go v0.2.4 // indirect
google.golang.org/genproto v0.0.0-20220502173005-c8bf987b8c21 // indirect
google.golang.org/grpc v1.49.0 // indirect
)

require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
Expand Down Expand Up @@ -73,7 +50,6 @@ require (
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
gitlab.alipay-inc.com/mist-sdk/mist_sdk_go v1.0.5
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.24.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions chaosmeta-inject-operator/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,8 @@ github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PK
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/tidwall/pretty v1.0.1/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
github.com/traas-stack/chaosmeta/chaosmeta-common v0.0.0-20240102105916-8f3b8d9accc5 h1:1RpFVSqiERGKUq2Yc6nioKEa0VyCXu0+t9vXpmK1WQ4=
github.com/traas-stack/chaosmeta/chaosmeta-common v0.0.0-20240102105916-8f3b8d9accc5/go.mod h1:291sLBmT/cXwucSh4T3kRmLX7JRlSNq5HY66PQtt4ow=
github.com/traas-stack/chaosmeta/chaosmeta-common v0.0.0-20240304074218-2b1da1d93caa h1:Z/0R8DkSZb0YBUN5wVDKmKiWV9D0vYC8iie6/DQuzmk=
github.com/traas-stack/chaosmeta/chaosmeta-common v0.0.0-20240304074218-2b1da1d93caa/go.mod h1:291sLBmT/cXwucSh4T3kRmLX7JRlSNq5HY66PQtt4ow=
github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=
github.com/valyala/fastjson v1.5.1 h1:SXaQZVSwLjZOVhDEhjiCcDtnX0Feu7Z7A1+C5atpoHM=
github.com/valyala/fastjson v1.5.1/go.mod h1:CLCAqky6SMuOcxStkYQvblddUtoRxhYMGLrsQns1aXY=
Expand Down
31 changes: 14 additions & 17 deletions chaosmeta-inject-operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ func main() {
var enableLeaderElection bool
var probeAddr string
//flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.")
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
flag.BoolVar(&enableLeaderElection, "leader-elect", false,
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8083", "The address the probe endpoint binds to.")
flag.BoolVar(&enableLeaderElection, "leader-elect", true,
"Enable leader election for controller manager. "+
"Enabling this will ensure there is only one active controller manager.")
opts := zap.Options{
Expand All @@ -85,13 +85,20 @@ func main() {

ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts)))

err := global.InitKubernetesClient()
if err != nil {
setupLog.Error(err, "init global client fail")
os.Exit(1)
}

mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Scheme: scheme,
//MetricsBindAddress: metricsAddr,
Port: 9443,
HealthProbeBindAddress: probeAddr,
LeaderElection: enableLeaderElection,
LeaderElectionID: "9cb44693.chaosmeta.io",
Port: 9443,
HealthProbeBindAddress: probeAddr,
LeaderElection: enableLeaderElection,
LeaderElectionID: "9cb44693.chaosmeta.io",
LeaderElectionNamespace: "chaosmeta",
// LeaderElectionReleaseOnCancel defines if the leader should step down voluntarily
// when the Manager ends. This requires the binary to immediately end when the
// Manager is stopped, otherwise, this setting is unsafe. Setting this significantly
Expand Down Expand Up @@ -141,23 +148,13 @@ func main() {
setupLog.Error(err, "set APIServer client error")
os.Exit(1)
}
setupLog.Info(fmt.Sprintf("set APIServer for cloud object success: %v", t))

err = initwebhook.InitCert(setupLog, ComponentInject)
if err != nil {
setupLog.Error(err, "init cert failed")
os.Exit(1)
}
// set executor
//if err = remoteexecutor.SetGlobalRemoteExecutor(&mainConfig.Executor, mgr.GetConfig(), mgr.GetScheme()); err != nil {
// setupLog.Error(err, "set remote executor error")
// os.Exit(1)
//}

err = global.InitKubernetesClient()
if err != nil {
setupLog.Error(err, "init global client fail")
os.Exit(1)
}
// start watching
if err = (&controllers.ExperimentReconciler{
Client: mgr.GetClient(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/traas-stack/chaosmeta/chaosmeta-inject-operator/pkg/executor/remoteexecutor/middlewareexecutor/common"
"github.com/traas-stack/chaosmeta/chaosmeta-inject-operator/pkg/model"
"os"
"sigs.k8s.io/controller-runtime/pkg/log"
"strings"
)

Expand All @@ -31,9 +32,12 @@ type MiddleWareExecutor struct {

func (r *MiddleWareExecutor) CheckExecutorWay(ctx context.Context) error {
// 对本机执行一次查询
logger := log.FromContext(ctx)
checkCmd := "ls"
host := os.Getenv("LOCAL_IP")
logger.Info("hostip", "ip: ", host)
res := r.Middleware.ExecCmdTask(ctx, host, checkCmd)
logger.Info("CheckExecutorWay", "res", res)
if !res.Success {
return fmt.Errorf(res.Message)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,13 @@ package auth

import (
"github.com/traas-stack/chaosmeta/chaosmeta-inject-operator/pkg/config"
"gitlab.alipay-inc.com/mist-sdk/mist_sdk_go/mist"
"log"
)

type MistClient struct {
Config config.MistConfig
}

func (r *MistClient) MistConfig() (string, string) {
config := mist.NewMistConfig()
// 线下/线上AntVipUrl和BkmiUrl具体配置参看上面的 参数说明
config.SetAntVipUrl(r.Config.AntVipUrl)
config.SetBkmiUrl(r.Config.BkmiUrl)

config.SetAppName(r.Config.AppName)
config.SetTenant(r.Config.Tenant)

// 线下/线上Mode具体配置参看上面的 参数说明
config.SetMode(r.Config.Mode)

client := mist.NewMistClient(config)
ak, sk, _, _, err := client.GetSecretInfo(r.Config.SecretName)
if err != nil {
log.Println(err)
return "", ""
}
return ak, sk
// internal code
return "", ""
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ func (r *TseMiddleware) ExecCmdTask(ctx context.Context, host string, cmd string
Success: false,
Message: "fail to exec",
}
fmt.Println("ExecCmdTask")
requestBody := &TseTaskRequest{}
requestBody.Ip = host
requestBody.Exeurl = cmdPrefix + cmd
Expand All @@ -59,19 +60,25 @@ func (r *TseMiddleware) ExecCmdTask(ctx context.Context, host string, cmd string
requestBody.Key = ak
requestBody.User = "root"
requestBody.Sign = hmacSha1(requestBody, sk)
fmt.Println("RequestBody", requestBody)
requestBodyStr, err := json.Marshal(requestBody)
if err != nil {
errResult.Message = err.Error()
return errResult
}
execTaskUrl := fmt.Sprintf("%s/api/task", r.TseUrl)
req, err := http.NewRequest("POST", execTaskUrl, bytes.NewBuffer(requestBodyStr))
if err != nil {
fmt.Println(err)
errResult.Message = err.Error()
return errResult
}
client := &http.Client{}
req.Header.Set("Content-Type", "application/json")
resp, err := client.Do(req)
if err != nil {
fmt.Println(err)
errResult.Message = err.Error()
return errResult
}
result := &common.TaskResult{}
Expand All @@ -82,9 +89,10 @@ func (r *TseMiddleware) ExecCmdTask(ctx context.Context, host string, cmd string
}
err = json.Unmarshal(body, result)
if err != nil {
errResult.Message = err.Error()
return errResult
}
return common.TaskResult{}
return *result
}

func hmacSha1(tseTaskRequest *TseTaskRequest, key string) string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ func AutoSelectRemoteExecutor(ctx context.Context, config *config.ExecutorConfig
/**
* 启动时通道自动选择
*/
config.DaemonsetConfig.DaemonName = "chaosmeta-daemon"
logger := log.FromContext(ctx)
daemonSetRemoteExecutor := &daemonsetexecutor.DaemonsetRemoteExecutor{
RESTConfig: restConfig,
Expand All @@ -74,7 +73,6 @@ func AutoSelectRemoteExecutor(ctx context.Context, config *config.ExecutorConfig
DaemonsetLabel: config.DaemonsetConfig.DaemonLabel,
DaemonsetName: config.DaemonsetConfig.DaemonName,
}
//logger.Info("%v", config)
if err := daemonSetRemoteExecutor.CheckExecutorWay(ctx); err == nil {
globalRemoteExecutor = daemonSetRemoteExecutor
logger.Info("select daemonSet way")
Expand All @@ -96,6 +94,9 @@ func AutoSelectRemoteExecutor(ctx context.Context, config *config.ExecutorConfig
logger.Info("select middleware way")
globalRemoteExecutor = middlewareRemoteExecutor
return nil
} else {
globalRemoteExecutor = middlewareRemoteExecutor
logger.Error(err, "fail to check middleware way")
}

agentExecutor := &agentexecutor.AgentRemoteExecutor{
Expand Down
5 changes: 3 additions & 2 deletions chaosmeta-inject-operator/pkg/phasehandler/inject/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,12 @@ func solveRunning(ctx context.Context, wg *sync.WaitGroup, exp *v1alpha1.Experim

return
} else {
if expInfo.Status == v1alpha1.SuccessStatusType || expInfo.Status == v1alpha1.FailedStatusType || expInfo.Status == v1alpha1.RunningStatusType {
logger.Info("inject Handler", "expinfo", expInfo, "exp", exp)
if expInfo != nil && len(expInfo.Status) != 0 && (expInfo.Status == v1alpha1.SuccessStatusType || expInfo.Status == v1alpha1.FailedStatusType || expInfo.Status == v1alpha1.RunningStatusType) {
targetSubExp[i].StartTime, targetSubExp[i].UpdateTime = expInfo.CreateTime, expInfo.UpdateTime
targetSubExp[i].Status, targetSubExp[i].Message = expInfo.Status, expInfo.Message
} else {
logger.Error(fmt.Errorf("unexpected status"), fmt.Sprintf("expInfo.Status is %s", expInfo.Status))
logger.Error(fmt.Errorf("unexpected status"), fmt.Sprintf("expInfo is %s", expInfo))
return
}
}
Expand Down
4 changes: 2 additions & 2 deletions chaosmeta-inject-operator/pkg/phasehandler/recover/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,11 @@ func solveRunning(ctx context.Context, wg *sync.WaitGroup, exp *v1alpha1.Experim

return
} else {
if expInfo.Status == v1alpha1.SuccessStatusType || expInfo.Status == v1alpha1.FailedStatusType || expInfo.Status == v1alpha1.RunningStatusType {
if expInfo != nil && len(expInfo.Status) != 0 && (expInfo.Status == v1alpha1.SuccessStatusType || expInfo.Status == v1alpha1.FailedStatusType || expInfo.Status == v1alpha1.RunningStatusType) {
targetSubExp[i].Status, targetSubExp[i].Message = expInfo.Status, expInfo.Message
targetSubExp[i].StartTime, targetSubExp[i].UpdateTime = expInfo.CreateTime, expInfo.UpdateTime
} else {
logger.Error(fmt.Errorf("unexpected status"), fmt.Sprintf("expInfo.Status is %s", expInfo.Status))
logger.Error(fmt.Errorf("unexpected status"), fmt.Sprintf("expInfo is %s", expInfo))
return
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func GetWorkflowStruct(experimentInstanceId string, nodes []*experiment_instance
},
Resource: &v1alpha1.ResourceTemplate{
Action: "create",
FailureCondition: "status.status == failed",
FailureCondition: "status.status in (failed, partSuccess)",
SuccessCondition: "status.phase == recover,status.status == success",
Manifest: fmt.Sprintf("{{inputs.parameters.%s}}", ParametersName),
},
Expand Down