Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
rsevilla87 authored Jul 27, 2023
2 parents 8b56817 + 0000dcf commit dd3f89a
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 12 deletions.
4 changes: 4 additions & 0 deletions cmd/kube-burner/ocp-config/cluster-density-v2/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ apiVersion: build.openshift.io/v1
metadata:
name: {{.JobName}}-{{.Replica}}
spec:
resources:
requests:
cpu: 10m
memory: "10Mi"
nodeSelector:
node-role.kubernetes.io/worker: ""
serviceAccount: builder
Expand Down
2 changes: 1 addition & 1 deletion cmd/kube-burner/ocp.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func openShiftCmd() *cobra.Command {
metricsEndpoint := ocpCmd.PersistentFlags().String("metrics-endpoint", "", "YAML file with a list of metric endpoints")
alerting := ocpCmd.PersistentFlags().Bool("alerting", true, "Enable alerting")
uuid := ocpCmd.PersistentFlags().String("uuid", uid.NewV4().String(), "Benchmark UUID")
timeout := ocpCmd.PersistentFlags().Duration("timeout", 3*time.Hour, "Benchmark timeout")
timeout := ocpCmd.PersistentFlags().Duration("timeout", 4*time.Hour, "Benchmark timeout")
qps := ocpCmd.PersistentFlags().Int("qps", 20, "QPS")
burst := ocpCmd.PersistentFlags().Int("burst", 20, "Burst")
gc := ocpCmd.PersistentFlags().Bool("gc", true, "Garbage collect created namespaces")
Expand Down
2 changes: 1 addition & 1 deletion docs/ocp.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Flags:
--metrics-endpoint string YAML file with a list of metric endpoints
--qps int QPS (default 20)
--reporting Enable benchmark report indexing
--timeout duration Benchmark timeout (default 3h0m0s)
--timeout duration Benchmark timeout (default 4h0m0s)
--user-metadata string User provided metadata file, in YAML format
--uuid string Benchmark UUID (default "d18989c4-4f8a-4a14-b711-9afae69a9140")

Expand Down
8 changes: 6 additions & 2 deletions docs/reference/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ In this section is described global job configuration, it holds the following pa
| `bearerToken` | Bearer token to access the Prometheus endpoint | String | "" |
| `metricsProfile` | Path to the metrics profile configuration file | String | "" |
| `metricsEndpoint` | Path to the metrics endpoint configuration file containing a list of target endpoints, flag has precedence | String | "" |
| `GC` | Garbage collect created namespaces | Boolean | false |
| `gc` | Garbage collect created namespaces | Boolean | false |
| `gcTimeout` | Garbage collection timeout | Duration | 1h |

kube-burner connects k8s clusters using the following methods in this order:

Expand All @@ -49,7 +50,7 @@ This section contains the list of jobs `kube-burner` will execute. Each job can
| `cleanup` | Cleanup clean up old namespaces | Boolean | true |
| `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| 3h |
| `maxWaitTimeout` | Maximum wait timeout per namespace | Duration| 4h |
| `jobIterationDelay` | How long to wait between each job iteration | Duration| 0s |
| `jobPause` | How long to pause after finishing the job | Duration| 0s |
| `qps` | Limit object creation queries per second | Integer | 0 |
Expand All @@ -59,12 +60,15 @@ This section contains the list of jobs `kube-burner` will execute. Each job can
| `errorOnVerify` | Set RC to 1 when objects verification fails | Boolean | true |
| `preLoadImages` | Kube-burner will create a DS before triggering the job to pull all the images of the job | true |
| `preLoadPeriod` | How long to wait for the preload daemonset | Duration| 1m |
| `preloadNodeLabels` | Add node selector labels for the resources created in preload stage | Object | {} |
| `namespaceLabels` | Add custom labels to the namespaces created by kube-burner | Object | {} |
| `churn` | Churn the workload. Only supports namespace based workloads | Boolean | false |
| `churnPercent` | Percentage of the jobIterations to churn each period | Integer | 10 |
| `churnDuration` | Length of time that the job is churned for | Duration| 1h |
| `churnDelay` | Length of time to wait between each churn period | Duration| 5m |

Our configuration files strictly follow YAML syntax. To clarify on List and Object types usage, they are nothing but the `Lists and Dictionaries` in YAML syntax like mentioned [here](https://gettaurus.org/docs/YAMLTutorial/#Lists-and-Dictionaries). Please feel free to refer YAML syntax more for details on a specific `Type` usage.

Examples of valid configuration files can be found at the [examples folder](https://github.com/cloud-bulldozer/kube-burner/tree/master/examples).

## Objects
Expand Down
9 changes: 5 additions & 4 deletions pkg/burner/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func Run(configSpec config.Spec, prometheusClients []*prometheus.Prometheus, ale
go func() {
var innerRC int
measurements.NewMeasurementFactory(configSpec, indexer, metadata)
jobList := newExecutorList(configSpec, uuid)
jobList := newExecutorList(configSpec, uuid, timeout)
// Iterate job list
for jobPosition, job := range jobList {
if job.QPS == 0 || job.Burst == 0 {
Expand All @@ -111,7 +111,7 @@ func Run(configSpec config.Spec, prometheusClients []*prometheus.Prometheus, ale
switch job.JobType {
case config.CreationJob:
if job.Cleanup {
ctx, cancel := context.WithTimeout(context.Background(), timeout)
ctx, cancel := context.WithTimeout(context.Background(), globalConfig.GCTimeout)
defer cancel()
CleanupNamespaces(ctx, v1.ListOptions{LabelSelector: fmt.Sprintf("kube-burner-job=%s", job.Name)}, true)
CleanupNonNamespacedResources(ctx, v1.ListOptions{LabelSelector: fmt.Sprintf("kube-burner-job=%s", job.Name)}, true)
Expand Down Expand Up @@ -202,7 +202,7 @@ func Run(configSpec config.Spec, prometheusClients []*prometheus.Prometheus, ale
}
if globalConfig.GC {
// Use timeout/4 to garbage collect namespaces
ctx, cancel := context.WithTimeout(context.Background(), timeout/4)
ctx, cancel := context.WithTimeout(context.Background(), globalConfig.GCTimeout)
defer cancel()
log.Info("Garbage collecting remaining namespaces")
CleanupNamespaces(ctx, v1.ListOptions{LabelSelector: fmt.Sprintf("kube-burner-uuid=%v", uuid)}, true)
Expand All @@ -212,7 +212,7 @@ func Run(configSpec config.Spec, prometheusClients []*prometheus.Prometheus, ale
}

// newExecutorList Returns a list of executors
func newExecutorList(configSpec config.Spec, uuid string) []Executor {
func newExecutorList(configSpec config.Spec, uuid string, timeout time.Duration) []Executor {
var ex Executor
var executorList []Executor
_, restConfig, err := config.GetClientSet(100, 100) // Hardcoded QPS/Burst
Expand All @@ -235,6 +235,7 @@ func newExecutorList(configSpec config.Spec, uuid string) []Executor {
log.Fatalf("Job names must be unique: %s", job.Name)
}
}
job.MaxWaitTimeout = timeout
// Limits the number of workers to QPS and Burst
ex.limiter = rate.NewLimiter(rate.Limit(job.QPS), job.Burst)
ex.Job = job
Expand Down
7 changes: 4 additions & 3 deletions pkg/burner/pre_load.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func preLoadImages(job Executor) error {
if err != nil {
return fmt.Errorf("pre-load: %v", err)
}
err = createDSs(imageList, job.NamespaceLabels)
err = createDSs(imageList, job.NamespaceLabels, job.PreLoadNodeLabels)
if err != nil {
return fmt.Errorf("pre-load: %v", err)
}
Expand Down Expand Up @@ -90,7 +90,7 @@ func getJobImages(job Executor) ([]string, error) {
return imageList, nil
}

func createDSs(imageList []string, namespaceLabels map[string]string) error {
func createDSs(imageList []string, namespaceLabels map[string]string, nodeSelectorLabels map[string]string) error {
nsLabels := map[string]string{
"kube-burner-preload": "true",
}
Expand Down Expand Up @@ -128,6 +128,7 @@ func createDSs(imageList []string, namespaceLabels map[string]string) error {
ImagePullPolicy: corev1.PullAlways,
},
},
NodeSelector: nodeSelectorLabels,
},
},
},
Expand All @@ -150,4 +151,4 @@ func createDSs(imageList []string, namespaceLabels map[string]string) error {
return err
}
return nil
}
}
3 changes: 2 additions & 1 deletion pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import (
var configSpec = Spec{
GlobalConfig: GlobalConfig{
GC: false,
GCTimeout: 1 * time.Hour,
RequestTimeout: 15 * time.Second,
Measurements: []mtypes.Measurement{},
IndexerConfig: indexers.IndexerConfig{
Expand Down Expand Up @@ -77,7 +78,7 @@ func (j *Job) UnmarshalYAML(unmarshal func(interface{}) error) error {
ErrorOnVerify: true,
JobType: CreationJob,
WaitForDeletion: true,
MaxWaitTimeout: 3 * time.Hour,
MaxWaitTimeout: 4 * time.Hour,
PreLoadImages: true,
PreLoadPeriod: 1 * time.Minute,
Churn: false,
Expand Down
4 changes: 4 additions & 0 deletions pkg/config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ type GlobalConfig struct {
AlertProfile string `yaml:"alertProfile"`
// GC garbage collect created namespaces
GC bool `yaml:"gc" json:"gc"`
// GCTimeout garbage collection timeout
GCTimeout time.Duration `yaml:"gcTimeout"`
}

// Object defines an object that kube-burner will create
Expand Down Expand Up @@ -133,6 +135,8 @@ type Job struct {
PreLoadImages bool `yaml:"preLoadImages" json:"preLoadImages,omitempty"`
// PreLoadPeriod determines the duration of the preload stage
PreLoadPeriod time.Duration `yaml:"preLoadPeriod" json:"preLoadPeriod,omitempty"`
// PreLoadNodeLabels add node selector labels to resources in preload stage
PreLoadNodeLabels map[string]string `yaml:"preLoadNodeLabels" json:"-"`
// NamespaceLabels add custom labels to namespaces created by kube-burner
NamespaceLabels map[string]string `yaml:"namespaceLabels" json:"-"`
// Churn workload
Expand Down

0 comments on commit dd3f89a

Please sign in to comment.