From b1a5e24862dce55b2b9a6d19da23327f7f79d13b Mon Sep 17 00:00:00 2001 From: Olha Yevtushenko Date: Thu, 1 Feb 2024 19:44:05 +0200 Subject: [PATCH] fix: duplicate job should be an error only after wait period --- api/v1alpha1/zz_generated.deepcopy.go | 1 + controllers/k6_create.go | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index 873c1f1c..ffc2f65e 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -237,6 +237,7 @@ func (in *Pod) DeepCopyInto(out *Pod) { } in.Resources.DeepCopyInto(&out.Resources) in.SecurityContext.DeepCopyInto(&out.SecurityContext) + in.ContainerSecurityContext.DeepCopyInto(&out.ContainerSecurityContext) if in.EnvFrom != nil { in, out := &in.EnvFrom, &out.EnvFrom *out = make([]v1.EnvFromSource, len(*in)) diff --git a/controllers/k6_create.go b/controllers/k6_create.go index 23e2fdab..87aa64de 100644 --- a/controllers/k6_create.go +++ b/controllers/k6_create.go @@ -88,8 +88,9 @@ func createJobSpecs(ctx context.Context, log logr.Logger, k6 v1alpha1.TestRunI, log.Info(err.Error()) // is it possible to implement this delay with resourceVersion of the job? - t, _ := v1alpha1.LastUpdate(k6, v1alpha1.CloudTestRun) - if time.Since(t).Seconds() <= 30 { + t, condUpdated := v1alpha1.LastUpdate(k6, v1alpha1.CloudTestRun) + // if condition has not been updated yet or has been updated very recently + if !condUpdated || time.Since(t).Seconds() <= 30 { // try again before returning an error return ctrl.Result{RequeueAfter: time.Second * 10}, true, nil }