Skip to content

Commit

Permalink
fix: set default timeout of 15 minutes
Browse files Browse the repository at this point in the history
  • Loading branch information
lenaschoenburg committed Oct 12, 2022
1 parent 272f74f commit e8263eb
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions go-chaos/cmd/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,20 @@ func start_worker(cmd *cobra.Command, args []string) {
func handleZbChaosJob(client worker.JobClient, job entities.Job) {
ctx := context.Background()

var jobVariables ZbChaosVariables
jobVariables := ZbChaosVariables {
provider: ChaosProvider {
timeout: 15 * 60, // 15 minute default timeout
},
}
err := job.GetVariablesAs(&jobVariables)
if err != nil {
// Can't parse variables, no sense in retrying
_, _ = client.NewFailJobCommand().JobKey(job.Key).Retries(0).Send(ctx)
return
}

commandCtx, cancelCommand := context.WithTimeout(ctx, 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)
Expand Down

0 comments on commit e8263eb

Please sign in to comment.