diff --git a/go-chaos/Dockerfile b/go-chaos/Dockerfile index 02e339cf8..a1641ee34 100644 --- a/go-chaos/Dockerfile +++ b/go-chaos/Dockerfile @@ -1,6 +1,6 @@ # syntax=docker/dockerfile:1.4 FROM golang:alpine as builder - +RUN apk update && apk upgrade && apk add --no-cache ca-certificates && update-ca-certificates WORKDIR /app COPY --link go.mod go.sum . @@ -9,12 +9,13 @@ RUN go mod download COPY --link cmd/ ./cmd COPY --link internal ./internal COPY --link main.go ./ -RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o zbchaos main.go +RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o zbchaos main.go FROM scratch WORKDIR /app +COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ COPY --from=builder /app/zbchaos /usr/local/bin/ ENTRYPOINT ["zbchaos"] diff --git a/go-chaos/cmd/worker.go b/go-chaos/cmd/worker.go index 35d9bd81e..86df8f83c 100644 --- a/go-chaos/cmd/worker.go +++ b/go-chaos/cmd/worker.go @@ -38,14 +38,14 @@ var workerCommand = &cobra.Command{ } type ChaosProvider struct { - path string - args []string - timeout int64 + Path string + Arguments []string + Timeout int64 } type ZbChaosVariables struct { - clusterId string - provider ChaosProvider + ClusterId *string + Provider ChaosProvider } func start_worker(cmd *cobra.Command, args []string) { @@ -71,8 +71,8 @@ func handleZbChaosJob(client worker.JobClient, job entities.Job) { ctx := context.Background() jobVariables := ZbChaosVariables{ - provider: ChaosProvider{ - timeout: 15 * 60, // 15 minute default timeout + Provider: ChaosProvider{ + Timeout: 15 * 60, // 15 minute default Timeout }, } err := job.GetVariablesAs(&jobVariables) @@ -82,11 +82,13 @@ func handleZbChaosJob(client worker.JobClient, job entities.Job) { return } - timeout := time.Duration(jobVariables.provider.timeout) * time.Second + timeout := time.Duration(jobVariables.Provider.Timeout) * time.Second commandCtx, cancelCommand := context.WithTimeout(ctx, timeout) defer cancelCommand() - err = runZbChaosCommand(jobVariables.provider.args, commandCtx) + commandArgs := append([]string{"--namespace", *jobVariables.ClusterId + "-zeebe"}, jobVariables.Provider.Arguments...) + + err = runZbChaosCommand(commandArgs, commandCtx) if err != nil { _, _ = client.NewFailJobCommand().JobKey(job.Key).Retries(job.Retries - 1).Send(ctx) return