Skip to content

Commit

Permalink
Fixing JobIterationDelay (kube-burner#476)
Browse files Browse the repository at this point in the history
Fix JobIterationDelay

Signed-off-by: Raul Sevilla <[email protected]>
  • Loading branch information
rsevilla87 authored Sep 28, 2023
1 parent d44263c commit a49c87f
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 14 deletions.
6 changes: 3 additions & 3 deletions docs/reference/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ In this section is described global job configuration, it holds the following pa
| `GCTimeout` | Garbage collection timeout | Duration | 1h |
| `waitWhenFinished` | Wait for all pods to be running when all jobs are completed | Boolean | false |

!!! note
!!! note
The precedence order to wait on resources is Global.waitWhenFinished > Job.waitWhenFinished > Job.podWait

kube-burner connects k8s clusters using the following methods in this order:
Expand All @@ -55,7 +55,7 @@ This section contains the list of jobs `kube-burner` will execute. Each job can
| `podWait` | Wait for all pods to be running before moving forward to the next job iteration | Boolean | false |
| `waitWhenFinished` | Wait for all pods to be running when all iterations are completed | Boolean | true |
| `maxWaitTimeout` | Maximum wait timeout per namespace | Duration| 4h |
| `jobIterationDelay` | How long to wait between each job iteration | Duration| 0s |
| `jobIterationDelay` | How long to wait between each job iteration. This is also the wait interval between each delete operation | Duration| 0s |
| `jobPause` | How long to pause after finishing the job | Duration| 0s |
| `qps` | Limit object creation queries per second | Integer | 0 |
| `burst` | Maximum burst for throttle | Integer | 0 |
Expand Down Expand Up @@ -163,7 +163,7 @@ objects:
labelSelector: {kube-burner-job: cluster-density}
objectTemplate: templates/deployment_patch_add_label.json
patchType: "application/strategic-merge-patch+json"
apiVersion: apps/v1s
apiVersion: apps/v1
```

Where:
Expand Down
2 changes: 1 addition & 1 deletion pkg/burner/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ func (ex *Executor) RunCreateJobWithChurn() {
// Determine the number of job iterations to churn (min 1)
numToChurn := int(math.Max(float64(ex.ChurnPercent*ex.JobIterations/100), 1))
now := time.Now().UTC()
rand.Seed(now.UnixNano())
rand.NewSource(now.UnixNano())
// Create timer for the churn duration
timer := time.After(ex.ChurnDuration)
// Patch to label namespaces for deletion
Expand Down
14 changes: 7 additions & 7 deletions pkg/burner/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"k8s.io/apimachinery/pkg/util/wait"
)

func setupDeleteJob(jobConfig *config.Job) Executor {
func setupDeleteJob(jobConfig config.Job) Executor {
var ex Executor
log.Debugf("Preparing delete job: %s", jobConfig.Name)
mapper := newRESTMapper()
Expand All @@ -53,7 +53,6 @@ func setupDeleteJob(jobConfig *config.Job) Executor {
log.Debugf("Job %s: Delete %s with selector %s", jobConfig.Name, gvk.Kind, labels.Set(obj.labelSelector))
ex.objects = append(ex.objects, obj)
}
jobConfig.PreLoadImages = false
return ex
}

Expand Down Expand Up @@ -86,18 +85,19 @@ func (ex *Executor) RunDeleteJob() {
var err error
if obj.Namespaced {
log.Debugf("Removing %s/%s from namespace %s", item.GetKind(), item.GetName(), item.GetNamespace())
} else {
log.Debugf("Removing %s/%s", item.GetKind(), item.GetName())
}
if obj.Namespaced {
err = DynamicClient.Resource(obj.gvr).Namespace(item.GetNamespace()).Delete(context.TODO(), item.GetName(), metav1.DeleteOptions{})
} else {
log.Debugf("Removing %s/%s", item.GetKind(), item.GetName())
err = DynamicClient.Resource(obj.gvr).Delete(context.TODO(), item.GetName(), metav1.DeleteOptions{})
}
if err != nil {
log.Errorf("Error found removing %s %s: %s", item.GetKind(), item.GetName(), err)
log.Errorf("Error found removing %s/%s: %s", item.GetKind(), item.GetName(), err)
}
}(item)
if ex.JobIterationDelay > 0 {
log.Infof("Sleeping for %v", ex.JobIterationDelay)
time.Sleep(ex.JobIterationDelay)
}
}
if ex.Job.WaitForDeletion {
wait.PollUntilContextCancel(context.TODO(), 2*time.Second, true, func(ctx context.Context) (done bool, err error) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/burner/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ func newExecutorList(configSpec config.Spec, uuid string, timeout time.Duration)
case config.CreationJob:
ex = setupCreateJob(job)
case config.DeletionJob:
ex = setupDeleteJob(&job)
ex = setupDeleteJob(job)
case config.PatchJob:
ex = setupPatchJob(job)
default:
Expand Down
7 changes: 5 additions & 2 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,17 +132,20 @@ func Parse(uuid string, f io.Reader) (Spec, error) {
if err := validateDNS1123(); err != nil {
return configSpec, err
}
for _, job := range configSpec.Jobs {
for i, job := range configSpec.Jobs {
if len(job.Namespace) > 62 {
log.Warnf("Namespace %s length has > 62 characters, truncating it", job.Namespace)
job.Namespace = job.Namespace[:57]
configSpec.Jobs[i].Namespace = job.Namespace[:57]
}
if !job.NamespacedIterations && job.Churn {
log.Fatal("Cannot have Churn enabled without Namespaced Iterations also enabled")
}
if job.JobIterations < 1 && job.JobType == CreationJob {
log.Fatalf("Job %s has < 1 iterations", job.Name)
}
if job.JobType == DeletionJob {
configSpec.Jobs[i].PreLoadImages = false
}
}
configSpec.GlobalConfig.UUID = uuid
if configSpec.GlobalConfig.IndexerConfig.MetricsDirectory == "collected-metrics" {
Expand Down

0 comments on commit a49c87f

Please sign in to comment.