Skip to content

Commit

Permalink
Minor changes
Browse files Browse the repository at this point in the history
Signed-off-by: Raul Sevilla <[email protected]>
  • Loading branch information
rsevilla87 committed Sep 21, 2021
1 parent 754e82c commit b8310fd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
4 changes: 2 additions & 2 deletions cmd/kube-burner/kube-burner.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func initCmd() *cobra.Command {
cmd.Flags().BoolVar(&skipTLSVerify, "skip-tls-verify", true, "Verify prometheus TLS certificate")
cmd.Flags().DurationVarP(&prometheusStep, "step", "s", 30*time.Second, "Prometheus step size")
cmd.Flags().StringVarP(&configFile, "config", "c", "", "Config file path or URL")
cmd.Flags().StringVarP(&configMap, "configmap", "", "", "Config map holding all the configuration: config.yml, metrics.yml and alerts.yml. metrics and alerts are optional")
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.Flags().SortFlags = false
return cmd
Expand Down Expand Up @@ -312,7 +312,7 @@ func steps(uuid string, p *prometheus.Prometheus, alertM *alerting.AlertManager)
}
_, restConfig, err := config.GetClientSet(0, 0)
if err != nil {
log.Fatalf("Error creating restConfig: %s", err)
log.Fatalf("Error creating k8s clientSet: %s", err)
}
measurements.NewMeasurementFactory(restConfig, uuid, indexer)
jobList := burner.NewExecutorList(uuid)
Expand Down
18 changes: 5 additions & 13 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,10 @@ func Parse(c string, jobsRequired bool) error {
return nil
}

// FetchConfigMap Fetchs the specified configmap and looks for config.yml, metrics.yml and alerts.yml files
func FetchConfigMap(configMap, namespace string) (string, string, error) {
log.Infof("Fetching configmap %s", configMap)
var kubeconfig string
var found bool
var metricProfile, alertProfile string
var kubeconfig, metricProfile, alertProfile string
if os.Getenv("KUBECONFIG") != "" {
kubeconfig = os.Getenv("KUBECONFIG")
} else if _, err := os.Stat(filepath.Join(os.Getenv("HOME"), ".kube", "config")); kubeconfig == "" && !os.IsNotExist(err) {
Expand All @@ -139,12 +138,9 @@ func FetchConfigMap(configMap, namespace string) (string, string, error) {
if err != nil {
return metricProfile, alertProfile, err
}
// We write the configMap data into the CWD

for name, data := range configMapData.Data {
if name == "config.yml" {
found = true
}
// We write the configMap data into the CWD
if err := os.WriteFile(name, []byte(data), 0644); err != nil {
return metricProfile, alertProfile, fmt.Errorf("Error writing configmap into disk: %v", err)
}
Expand All @@ -155,9 +151,6 @@ func FetchConfigMap(configMap, namespace string) (string, string, error) {
alertProfile = "alerts.yml"
}
}
if !found {
return metricProfile, alertProfile, fmt.Errorf("File config.yml not found in configMap %s", configMap)
}
return metricProfile, alertProfile, nil
}

Expand All @@ -168,7 +161,7 @@ func validateDNS1123() error {
}
if job.JobType == CreationJob {
if errs := validation.IsDNS1123Subdomain(job.Namespace); job.JobType == CreationJob && len(errs) > 0 {
return fmt.Errorf("Namespace %s name validation error: %s", job.Namespace, fmt.Sprint(errs))
return fmt.Errorf("Namespace %s name validation error: %s", job.Namespace, errs)
}
}
}
Expand All @@ -191,8 +184,7 @@ func GetClientSet(QPS float32, burst int) (*kubernetes.Clientset, *rest.Config,
if err != nil {
return &kubernetes.Clientset{}, restConfig, err
}
restConfig.QPS = QPS
restConfig.Burst = burst
restConfig.QPS, restConfig.Burst = QPS, burst
restConfig.Timeout = ConfigSpec.GlobalConfig.RequestTimeout
return kubernetes.NewForConfigOrDie(restConfig), restConfig, nil
}

0 comments on commit b8310fd

Please sign in to comment.