Skip to content

Commit

Permalink
Update cobra
Browse files Browse the repository at this point in the history
Signed-off-by: Raul Sevilla <[email protected]>
  • Loading branch information
rsevilla87 committed Nov 7, 2022
1 parent 7fa30cd commit 5b7bedb
Show file tree
Hide file tree
Showing 44 changed files with 3,051 additions and 1,494 deletions.
8 changes: 2 additions & 6 deletions cmd/kube-burner/kube-burner.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,6 @@ func initCmd() *cobra.Command {
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, args []string) {
log.Infof("🔥 Starting kube-burner (%s@%s) with UUID %s", version.Version, version.GitCommit, uuid)
if configMap != "" {
if configFile != "" {
log.Fatal("The flags --config and --configmap can't be specified together")
}
}
if configMap == "" && configFile == "" {
log.Fatal("Either --configmap or --config flags are required")
}
Expand Down Expand Up @@ -143,6 +138,7 @@ func initCmd() *cobra.Command {
cmd.Flags().StringVarP(&configFile, "config", "c", "", "Config file path or URL")
cmd.Flags().StringVarP(&configMap, "configmap", "", "", "Configmap holding all the configuration: config.yml, metrics.yml and alerts.yml. metrics and alerts are optional")
cmd.Flags().StringVarP(&namespace, "namespace", "", "default", "Namespace where the configmap is")
cmd.MarkFlagsMutuallyExclusive("config", "configmap")
cmd.Flags().SortFlags = false
return cmd
}
Expand Down Expand Up @@ -256,7 +252,7 @@ func importCmd() *cobra.Command {
}
cmd.Flags().StringVarP(&configFile, "config", "c", "", "Config file path or URL")
cmd.Flags().StringVar(&tarball, "tarball", "", "Metrics tarball file")
cmd.MarkFlagRequired("config")
cmd.MarkFlagsRequiredTogether("config", "tarball")
return cmd
}

Expand Down
22 changes: 10 additions & 12 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ In this section is described global job configuration, it holds the following pa
| Option | Description | Type | Example | Default |
|------------------|----------------------------------------------------------------------------------------------------------|----------------|----------------|-------------|
| writeToFile | Whether to dump collected metrics to files | Boolean | true | true |
| writeToFile | Whether to dump collected metrics to files | Boolean | true | false |
| createTarball | Create metrics tarball, it has no effect if `writeToFile` is not enabled | Boolean | true | false |
| metricsDirectory | Directory where collected metrics will be dumped into. It will be created if it doesn't exist previously | String | ./metrics | ./collected-metrics |
| measurements | List of measurements. Detailed in the [measurements section] | List | - | [] |
Expand All @@ -43,8 +43,8 @@ This section contains the list of jobs `kube-burner` will execute. Each job can
| namespace | Namespace base name to use | String | firstjob | "" |
| namespacedIterations | Whether to create a namespace per job iteration | Boolean | true | true |
| 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 |
| podWait | Wait for all pods to be running before moving forward to the next job iteration | Boolean | true | false |
| waitWhenFinished | Wait for all pods to be running when all iterations are completed | Boolean | true | true |
| maxWaitTimeout | Maximum wait timeout in seconds. (If podWait is enabled this timeout will be reseted with each iteration) | Integer | 1h | 12h |
| waitFor | List containing the objects Kind wait for. Wait for all if empty | List | ["Deployment", "Build", "DaemonSet"]| [] |
| jobIterationDelay | How long to wait between each job iteration | Duration| 2s | 0s |
Expand All @@ -53,16 +53,15 @@ This section contains the list of jobs `kube-burner` will execute. Each job can
| burst | Maximum burst for throttle | Integer | 50 | 0 |
| objects | List of objects the job will create. Detailed on the [objects section](#objects) | List | - | [] |
| verifyObjects | Verify object count after running each job | Boolean | true | true |
| errorOnVerify | Set RC to 1 when objects verification fails | Boolean | true | false |
| preLoadImages | Kube-burner will create a DS before triggering the job to pull all the images of the job | Boolean | true | false |
| errorOnVerify | Set RC to 1 when objects verification fails | Boolean | true | true |
| preLoadImages | Kube-burner will create a DS before triggering the job to pull all the images of the job | Boolean | true | true |
| preLoadPeriod | How long to wait for the preload daemonset | Duration| 2m | 1m |
| namespaceLabels | Add custom labels to the namespaces created by kube-burner | Object | {"foo": "bar"} | - |
| churn | Churn the workload. Only supports namespace based workloads | Boolean | true | false |
| churnPercent | Percentage of the jobIterations to churn each period | Integer | 10 | 10 |
| churnDuration | Length of time that the job is churned for | Duration| 10m | 1h |
| churnDelay | Length of time to wait between each churn period | Duration| 10m | 5m |


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

## Objects
Expand All @@ -72,7 +71,7 @@ Each object element supports the following parameters:

| Option | Description | Type | Example | Default |
|----------------------|-------------------------------------------------------------------|---------|-----------------------------------------------------|---------|
| objectTemplate | Object template file or URL | String | deployment.yml or https://domain.com/deployment.yml | "" |
| objectTemplate | Object template file or URL | String | deployment.yml or <https://domain.com/deployment.yml> | "" |
| replicas | How replicas of this object to create per job iteration | Integer | 10 | - |
| inputVars | Map of arbitrary input variables to inject to the object template | Object | - | - |
| namespaced | Whether to create a namespaced object or not | Boolean | false | true |
Expand Down Expand Up @@ -103,7 +102,6 @@ Where:
- labelSelector: Map with the labelSelector.
- apiVersion: API version from the k8s object.


The third type is __patch__, which can patch objects described in the objects list with the template described in the object list. The objects list would have the following structure:

```yaml
Expand All @@ -112,8 +110,7 @@ objects:
labelSelector: {kube-burner-job: cluster-density}
objectTemplate: templates/deployment_patch_add_label.json
patchType: "application/strategic-merge-patch+json"
apiVersion: apps/v1
apiVersion: apps/v1s
```

Where:
Expand All @@ -125,6 +122,7 @@ Where:
- patchType: The kubernetes request patch type (see below).

Valid patch types:

- application/json-patch+json
- application/merge-patch+json
- application/strategic-merge-patch+json
Expand Down Expand Up @@ -157,7 +155,7 @@ jobs:

This job type supports the some of the same parameters as the create job type:

- **waitForDeletion**: Wait for objects to be deleted before finishing the job. Defaults to true
- __waitForDeletion__: Wait for objects to be deleted before finishing the job. Defaults to true
- name
- qps
- burst
Expand Down Expand Up @@ -199,7 +197,7 @@ All object templates are injected a series of variables by default:
- JobName: Job name.
- UUID: Benchmark UUID.

In addition, you can also inject arbitrary variables with the option **inputVars** from the objectTemplate object:
In addition, you can also inject arbitrary variables with the option __inputVars__ from the objectTemplate object:

```yaml
- objectTemplate: service.yml
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ require (
github.com/satori/go.uuid v1.2.0
github.com/sirupsen/logrus v1.6.0
github.com/spf13/cast v1.3.1
github.com/spf13/cobra v1.1.3
github.com/spf13/cobra v1.6.1
golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776
gopkg.in/yaml.v3 v3.0.1
k8s.io/api v0.21.1
k8s.io/apimachinery v0.21.1
k8s.io/client-go v0.21.1
Expand Down
12 changes: 8 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfc
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
Expand Down Expand Up @@ -353,8 +354,9 @@ github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJ
github.com/imdario/mergo v0.3.10/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
github.com/imdario/mergo v0.3.11 h1:3tnifQM4i+fbajXKBHXWEH+KvNHqojZ778UH75j3bGA=
github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/inconshreveable/mousetrap v1.0.1 h1:U3uMjPSQEBMNp1lFxmllqCPM6P5u/Xq7Pgzkat/bFNc=
github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo=
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
Expand Down Expand Up @@ -539,6 +541,7 @@ github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6So
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E=
github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww=
Expand Down Expand Up @@ -566,8 +569,8 @@ github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkU
github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE=
github.com/spf13/cobra v1.1.1/go.mod h1:WnodtKOvamDL/PwE2M4iKs8aMDBZ5Q5klgD3qfVJQMI=
github.com/spf13/cobra v1.1.3 h1:xghbfqPkxzxP3C/f3n5DdpAbdKLj4ZE4BWQI362l53M=
github.com/spf13/cobra v1.1.3/go.mod h1:pGADOWyqRD/YMrPZigI/zbliZ2wVD/23d+is3pSWzOo=
github.com/spf13/cobra v1.6.1 h1:o94oiPyS4KD1mPy2fmcYYHHfCxLqYjJOhGsCHFZtEzA=
github.com/spf13/cobra v1.6.1/go.mod h1:IOw/AERYS7UzyrGinqmz6HLUo219MORXGxhbaJUqzrY=
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
github.com/spf13/pflag v0.0.0-20170130214245-9ff6c6923cff/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
Expand Down Expand Up @@ -951,8 +954,9 @@ gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 h1:tQIYjPdBoyREyB9XMu+nnTclpTYkz2zFM+lzLJFO4gQ=
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
gotest.tools/v3 v3.0.2/go.mod h1:3SzNCllyD9/Y+b5r9JIKQ474KzkZyqLqEfYqMsX94Bk=
gotest.tools/v3 v3.0.3/go.mod h1:Z7Lb0S5l+klDB31fvDQX8ss/FlKDxtlFlw3Oa8Ymbl8=
Expand Down
3 changes: 1 addition & 2 deletions pkg/burner/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"math"
"math/rand"
"strconv"
Expand Down Expand Up @@ -58,7 +57,7 @@ func setupCreateJob(jobConfig config.Job) Executor {
if err != nil {
log.Fatalf("Error reading template %s: %s", o.ObjectTemplate, err)
}
t, err := ioutil.ReadAll(f)
t, err := io.ReadAll(f)
if err != nil {
log.Fatalf("Error reading template %s: %s", o.ObjectTemplate, err)
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/burner/patch.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package burner
import (
"context"
"io"
"io/ioutil"
"strings"
"sync"
"time"
Expand Down Expand Up @@ -49,7 +48,7 @@ func setupPatchJob(jobConfig config.Job) Executor {
if err != nil {
log.Fatalf("Error reading template %s: %s", o.ObjectTemplate, err)
}
t, err := ioutil.ReadAll(f)
t, err := io.ReadAll(f)
if err != nil {
log.Fatalf("Error reading template %s: %s", o.ObjectTemplate, err)
}
Expand Down
14 changes: 7 additions & 7 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"bytes"
"context"
"fmt"
"io/ioutil"
"io"
"os"
"path/filepath"
"strings"
Expand All @@ -42,7 +42,7 @@ var ConfigSpec Spec = Spec{
GlobalConfig: GlobalConfig{
MetricsDirectory: "collected-metrics",
RequestTimeout: 15 * time.Second,
WriteToFile: true,
WriteToFile: false,
Measurements: []mtypes.Measurement{},
IndexerConfig: IndexerConfig{
Enabled: false,
Expand Down Expand Up @@ -87,14 +87,14 @@ func (j *Job) UnmarshalYAML(unmarshal func(interface{}) error) error {
raw := rawJob{
Cleanup: true,
NamespacedIterations: true,
PodWait: true,
WaitWhenFinished: false,
PodWait: false,
WaitWhenFinished: true,
VerifyObjects: true,
ErrorOnVerify: false,
ErrorOnVerify: true,
JobType: CreationJob,
WaitForDeletion: true,
MaxWaitTimeout: 3 * time.Hour,
PreLoadImages: false,
PreLoadImages: true,
PreLoadPeriod: 1 * time.Minute,
Churn: false,
ChurnPercent: 10,
Expand All @@ -118,7 +118,7 @@ func Parse(c string, jobsRequired bool) error {
if err != nil {
return fmt.Errorf("Error reading configuration file %s: %s", c, err)
}
cfg, err := ioutil.ReadAll(f)
cfg, err := io.ReadAll(f)
if err != nil {
return fmt.Errorf("Error reading configuration file %s: %s", c, err)
}
Expand Down
Loading

0 comments on commit 5b7bedb

Please sign in to comment.