Skip to content

Commit

Permalink
Merge branch 'rsevilla87-logging-improvements'
Browse files Browse the repository at this point in the history
  • Loading branch information
rsevilla87 committed Sep 8, 2021
2 parents f182ed4 + 27253ff commit 6a315f7
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
5 changes: 2 additions & 3 deletions pkg/burner/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ func (ex *Executor) RunCreateJob() {
log.Infof("Burst: %v", RestConfig.Burst)
}
dynamicClient = dynamic.NewForConfigOrDie(RestConfig)
log.Infof("Running job %s", ex.Config.Name)
if !ex.Config.NamespacedIterations {
ns = ex.Config.Namespace
nsLabels["name"] = ns
Expand Down Expand Up @@ -220,10 +221,8 @@ func createRequest(gvr schema.GroupVersionResource, ns string, obj *unstructured
} else if errors.IsAlreadyExists(err) {
log.Errorf("%s/%s in namespace %s already exists", obj.GetKind(), obj.GetName(), ns)
return true, nil
} else if errors.IsTimeout(err) {
log.Errorf("Timeout creating object %s/%s in namespace %s: %s", obj.GetKind(), obj.GetName(), ns, err)
} else if err != nil {
log.Errorf("Error creating object: %s", err)
log.Errorf("Error creating object %s/%s in namespace %s: %s", obj.GetKind(), obj.GetName(), ns, err)
}
log.Error("Retrying object creation")
return false, nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/burner/namespaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ func createNamespace(clientset *kubernetes.Clientset, namespaceName string, nsLa

// CleanupNamespaces deletes namespaces with the given selector
func CleanupNamespaces(clientset *kubernetes.Clientset, s *util.Selector) {
log.Infof("Deleting namespaces with label %s", s.LabelSelector)
ns, _ := clientset.CoreV1().Namespaces().List(context.TODO(), s.ListOptions)
if len(ns.Items) > 0 {
log.Infof("Deleting namespaces with label %s", s.LabelSelector)
for _, ns := range ns.Items {
err := clientset.CoreV1().Namespaces().Delete(context.TODO(), ns.Name, metav1.DeleteOptions{})
if errors.IsNotFound(err) {
Expand Down
4 changes: 2 additions & 2 deletions pkg/util/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ func RenderTemplate(original []byte, inputData interface{}, options templateOpti
}
t, err := template.New("").Option(string(options)).Funcs(funcMap).Parse(string(original))
if err != nil {
return nil, fmt.Errorf("Parsing error: %s", err)
return nil, fmt.Errorf("parsing error: %s", err)
}
err = t.Execute(&rendered, inputData)
if err != nil {
return nil, fmt.Errorf("Rendering error: %s", err)
return nil, fmt.Errorf("rendering error: %s", err)
}
return rendered.Bytes(), nil
}
4 changes: 2 additions & 2 deletions pkg/util/url_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func ReadConfig(configFile string) (io.Reader, error) {
f, err := os.Open(configFile)
// If the template file does not exist we try to read it from an URL
if os.IsNotExist(err) {
log.Infof("File %s not found, falling back to read from URL", configFile)
log.Debugf("File %s not found, falling back to read from URL", configFile)
f, err = readURL(configFile, f)
}
return f, err
Expand All @@ -50,7 +50,7 @@ func readURL(stringURL string, body io.Reader) (io.Reader, error) {
return body, err
}
if r.StatusCode != http.StatusOK {
return body, fmt.Errorf("Error requesting %s: %d", u, r.StatusCode)
return body, fmt.Errorf("error requesting %s: %d", u, r.StatusCode)
}
return r.Body, nil
}

0 comments on commit 6a315f7

Please sign in to comment.