Skip to content

Commit

Permalink
cloud, plz: fix for job duplicate check
Browse files Browse the repository at this point in the history
  • Loading branch information
yorugac committed Nov 10, 2023
1 parent ff20c6c commit 41989da
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion controllers/k6_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,17 @@ func createJobSpecs(ctx context.Context, log logr.Logger, k6 v1alpha1.TestRunI,
Namespace: k6.NamespacedName().Namespace,
}

// is it possible to implement this delay with resourceVersion of the job?
t, _ := v1alpha1.LastUpdate(k6, v1alpha1.CloudTestRun)
if time.Since(t).Minutes() <= 1 {
// try again before checking for existence
return ctrl.Result{RequeueAfter: time.Second}, nil
}

if err := r.Get(ctx, namespacedName, found); err == nil || !errors.IsNotFound(err) {
if err == nil {
err = fmt.Errorf("job with the name %s exists; make sure you've deleted your previous run", namespacedName.Name)
}

log.Info(err.Error())
return ctrl.Result{}, err
}
Expand Down

0 comments on commit 41989da

Please sign in to comment.