Skip to content

Commit

Permalink
Add WaitFor
Browse files Browse the repository at this point in the history
Signed-off-by: Raul Sevilla <rsevilla@redhat.com>
  • Loading branch information
rsevilla87 committed Sep 3, 2020
1 parent 23482fa commit 3afa0f2
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 15 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -124,6 +124,7 @@ All the magic `kube-burner` does is described in the configuration file. This fi
| cleanup | Cleanup clean up old namespaces | Boolean | true | true |
| podWait | Wait for all pods to be running before moving forward to the next job iteration | Boolean | true | true |
| waitWhenFinished | Wait for all pods to be running when all iterations are completed | Boolean | true | false |
| waitFor | List containing the objects Kind wait for. Wait for all if empty | List | ["Deployments", "Build"]| [] |
| jobIterationDelay | How many milliseconds to wait between each job iteration | Integer | 2000 | false |
| jobPause | How many milliseconds to pause after finishing the job | Integer | 10000 | 0 |
| qps | Limit object creation queries per second | Integer | 25 | 0 |
Expand Down
46 changes: 31 additions & 15 deletions pkg/burner/burner.go
Expand Up @@ -157,21 +157,37 @@ func getExecutor(jobConfig config.Job) Executor {
unstructured: uns,
inputVars: o.InputVars,
}
switch kind := obj.unstructured.GetKind(); kind {
case "Deployment":
obj.waitFunc = waitForDeployments
case "ReplicaSet":
obj.waitFunc = waitForRS
case "ReplicationController":
obj.waitFunc = waitForRC
case "DaemonSet":
obj.waitFunc = waitForDS
case "Pod":
obj.waitFunc = waitForPod
case "Build":
obj.waitFunc = waitForBuild
default:
log.Infof("Resource of kind %s has no wait function", kind)
if jobConfig.PodWait || jobConfig.WaitWhenFinished {
waitFor := true
if len(jobConfig.WaitFor) > 0 {
waitFor = false
for _, kind := range jobConfig.WaitFor {
if obj.unstructured.GetKind() == kind {
waitFor = true
break
}
}
}
if waitFor {
kind := obj.unstructured.GetKind()
switch kind {
case "Deployment":
obj.waitFunc = waitForDeployments
case "ReplicaSet":
obj.waitFunc = waitForRS
case "ReplicationController":
obj.waitFunc = waitForRC
case "DaemonSet":
obj.waitFunc = waitForDS
case "Pod":
obj.waitFunc = waitForPod
case "Build":
obj.waitFunc = waitForBuild
}
if obj.waitFunc != nil {
log.Debugf("Added wait function for %s", kind)
}
}
}
log.Infof("Job %s: %d iterations with %d %s replicas", jobConfig.Name, jobConfig.JobIterations, obj.replicas, restMapping.GroupVersionKind.Kind)
ex.objects = append(ex.objects, obj)
Expand Down
2 changes: 2 additions & 0 deletions pkg/config/types.go
Expand Up @@ -97,6 +97,8 @@ type Job struct {
PodWait bool `yaml:"podWait"`
// WaitWhenFinished Wait for pods to be running when all iterations are completed
WaitWhenFinished bool `yaml:"waitWhenFinished"`
// WaitFor list of objects to wait for, if not specified wait for all
WaitFor []string `yaml:"waitFor"`
// Cleanup clean up old namespaces
Cleanup bool `yaml:"cleanup"`
// whether to create namespaces or not with each iteration
Expand Down

0 comments on commit 3afa0f2

Please sign in to comment.