From 9e128826bdde6393b7301d4fe8d495fce2849e9f Mon Sep 17 00:00:00 2001 From: Sirish Bathina Date: Thu, 29 Oct 2020 07:49:29 -1000 Subject: [PATCH] minor fixes (#29) * minor fixes * push to latest --- docs/run_kubestr.sh | 2 +- pkg/fio/fio.go | 20 +++++++++----------- pkg/fio/fio_jobs.go | 2 +- pkg/kubestr/fio.go | 5 +++-- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/docs/run_kubestr.sh b/docs/run_kubestr.sh index fb2828d..d05c9d3 100755 --- a/docs/run_kubestr.sh +++ b/docs/run_kubestr.sh @@ -10,7 +10,7 @@ readonly -a REQUIRED_TOOLS=( kubectl ) -DEFAULT_IMAGE_TAG="0.2.0" +DEFAULT_IMAGE_TAG="latest" DEFAULT_JOB_NAME="kubestr" helpFunction() diff --git a/pkg/fio/fio.go b/pkg/fio/fio.go index a73fdfe..cfc1186 100644 --- a/pkg/fio/fio.go +++ b/pkg/fio/fio.go @@ -23,8 +23,7 @@ const ( // ConfigMapSCKey describes the storage class key in a config map ConfigMapSCKey = "storageclass" // ConfigMapSizeKey describes the size key in a config map - ConfigMapSizeKey = "pvcsize" - ConfigMapPredefinedTestKey = "fiotest.fio" + ConfigMapSizeKey = "pvcsize" // DefaultPVCSize is the default PVC size DefaultPVCSize = "100Gi" // PVCGenerateName is the name to generate for the PVC @@ -154,11 +153,11 @@ func (s *fioStepper) storageClassExists(ctx context.Context, storageClass string return nil } -func getConfigMapJob(jobName string) *v1.ConfigMap { - if jobName == "" { - jobName = DefaultFIOJob +func getConfigMapJob(jobNamePtr *string) *v1.ConfigMap { + if *jobNamePtr == "" { + *jobNamePtr = DefaultFIOJob } - cm, ok := fioJobs[jobName] + cm, ok := fioJobs[*jobNamePtr] if !ok { return nil } @@ -167,7 +166,7 @@ func getConfigMapJob(jobName string) *v1.ConfigMap { func (s *fioStepper) loadConfigMap(ctx context.Context, args *RunFIOArgs) (*v1.ConfigMap, error) { if args.ConfigMapName == "" { - cm := getConfigMapJob(args.JobName) + cm := getConfigMapJob(&args.JobName) if cm == nil { return nil, fmt.Errorf("Predefined job (%s) not found", args.JobName) } @@ -191,19 +190,18 @@ func (s *fioStepper) loadConfigMap(ctx context.Context, args *RunFIOArgs) (*v1.C if val, ok := configMap.Data[ConfigMapSizeKey]; !ok || val == "" { configMap.Data[ConfigMapSizeKey] = DefaultPVCSize } - // if entry fio entry exists use it. for key := range configMap.Data { if key != ConfigMapSizeKey && key != ConfigMapSCKey { - return configMap, nil + return s.cli.CoreV1().ConfigMaps(GetPodNamespace()).Update(ctx, configMap, metav1.UpdateOptions{}) } } // otherwise load one - cm := getConfigMapJob(args.JobName) + cm := getConfigMapJob(&args.JobName) if cm == nil { return nil, fmt.Errorf("Predefined job (%s) not found in configmap", args.JobName) } - configMap.Data[ConfigMapPredefinedTestKey] = cm.Data[ConfigMapPredefinedTestKey] + configMap.Data[args.JobName] = cm.Data[args.JobName] return s.cli.CoreV1().ConfigMaps(GetPodNamespace()).Update(ctx, configMap, metav1.UpdateOptions{}) } diff --git a/pkg/fio/fio_jobs.go b/pkg/fio/fio_jobs.go index faa9d76..951a577 100644 --- a/pkg/fio/fio_jobs.go +++ b/pkg/fio/fio_jobs.go @@ -11,7 +11,7 @@ var fioJobs = map[string]*v1.ConfigMap{ GenerateName: DefaultFIOJob, }, Data: map[string]string{ - ConfigMapPredefinedTestKey: testJob1, + DefaultFIOJob: testJob1, }, }, } diff --git a/pkg/kubestr/fio.go b/pkg/kubestr/fio.go index 48a041c..aabf29b 100644 --- a/pkg/kubestr/fio.go +++ b/pkg/kubestr/fio.go @@ -2,12 +2,13 @@ package kubestr import ( "context" + "fmt" "github.com/kastenhq/kubestr/pkg/fio" ) func (p *Kubestr) FIO(ctx context.Context, storageClass, configMap, jobName string) *TestOutput { - testName := "FIO test results-" + testName := "FIO test results" fioResult, err := p.fio.RunFio(ctx, &fio.RunFIOArgs{ StorageClass: storageClass, ConfigMapName: configMap, @@ -16,5 +17,5 @@ func (p *Kubestr) FIO(ctx context.Context, storageClass, configMap, jobName stri if err != nil { return makeTestOutput(testName, StatusError, err.Error(), nil) } - return makeTestOutput(testName, StatusOK, fioResult, fioResult) + return makeTestOutput(testName, StatusOK, fmt.Sprintf("\n%s\n", fioResult), fioResult) }