Skip to content

Commit

Permalink
Merge pull request #219 from zeebe-io/os-zbchaos-fixes
Browse files Browse the repository at this point in the history
Fix zbchaos worker issues
  • Loading branch information
lenaschoenburg authored Nov 9, 2022
2 parents 303f0b0 + 74c65a3 commit 8689985
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
5 changes: 3 additions & 2 deletions go-chaos/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 .
Expand All @@ -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"]
Expand Down
20 changes: 11 additions & 9 deletions go-chaos/cmd/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit 8689985

Please sign in to comment.