-
Notifications
You must be signed in to change notification settings - Fork 5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: improve error logs #10944
chore: improve error logs #10944
Changes from 18 commits
2e5ea75
e1b4757
911dabe
c5a2c51
dcdb82a
67e76ec
83fa5f8
5ac117b
753289b
e84919b
419c5b3
f95aae8
542d58d
a703ec4
da7c0ae
73d6a60
a03de9a
3db5908
49d7d74
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -292,11 +292,11 @@ func saveToFile(err error, outputFormat string, result reconcileResults, outputP | |||||
switch outputFormat { | ||||||
case "yaml": | ||||||
if data, err = yaml.Marshal(result); err != nil { | ||||||
return err | ||||||
return fmt.Errorf("error marshalling yaml file %w", err) | ||||||
} | ||||||
case "json": | ||||||
if data, err = json.Marshal(result); err != nil { | ||||||
return err | ||||||
return fmt.Errorf("error marshalling json file %w", err) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} | ||||||
default: | ||||||
return fmt.Errorf("format %s is not supported", outputFormat) | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -43,7 +43,7 @@ func PrintResources(output string, out io.Writer, resources ...interface{}) erro | |||||
} | ||||||
filteredResource, err := omitFields(resource) | ||||||
if err != nil { | ||||||
return err | ||||||
return fmt.Errorf("error printing the resource %w", err) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} | ||||||
resources[i] = filteredResource | ||||||
} | ||||||
|
@@ -56,14 +56,14 @@ func PrintResources(output string, out io.Writer, resources ...interface{}) erro | |||||
case "json": | ||||||
jsonBytes, err := json.MarshalIndent(obj, "", " ") | ||||||
if err != nil { | ||||||
return err | ||||||
return fmt.Errorf("error printing the json file %w", err) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} | ||||||
|
||||||
_, _ = fmt.Fprintln(out, string(jsonBytes)) | ||||||
case "yaml": | ||||||
yamlBytes, err := yaml.Marshal(obj) | ||||||
if err != nil { | ||||||
return err | ||||||
return fmt.Errorf("error printing the yaml file %w", err) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} | ||||||
// marshaled YAML already ends with the new line character | ||||||
_, _ = fmt.Fprint(out, string(yamlBytes)) | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -106,13 +106,13 @@ func saveProject(ctx context.Context, updated v1alpha1.AppProject, orig v1alpha1 | |||||
errors.CheckError(err) | ||||||
live, err := kube.ToUnstructured(&orig) | ||||||
if err != nil { | ||||||
return err | ||||||
return fmt.Errorf("error saving the project %w", err) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} | ||||||
_ = cli.PrintDiff(updated.Name, target, live) | ||||||
if !dryRun { | ||||||
_, err = projectsIf.Update(ctx, &updated, v1.UpdateOptions{}) | ||||||
if err != nil { | ||||||
return err | ||||||
return fmt.Errorf("error while updating %w", err) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} | ||||||
} | ||||||
return nil | ||||||
|
@@ -188,7 +188,7 @@ func NewUpdatePolicyRuleCommand() *cobra.Command { | |||||
func updateProjects(ctx context.Context, projIf appclient.AppProjectInterface, projectGlob string, rolePattern string, action string, modification func(string, string) string, dryRun bool) error { | ||||||
projects, err := projIf.List(ctx, v1.ListOptions{}) | ||||||
if err != nil { | ||||||
return err | ||||||
return fmt.Errorf("error listing the projects %w", err) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} | ||||||
for _, proj := range projects.Items { | ||||||
if !globMatch(projectGlob, proj.Name) { | ||||||
|
@@ -225,7 +225,7 @@ func updateProjects(ctx context.Context, projIf appclient.AppProjectInterface, p | |||||
if updated { | ||||||
err = saveProject(ctx, proj, *origProj, projIf, dryRun) | ||||||
if err != nil { | ||||||
return err | ||||||
return fmt.Errorf("error saving the project %w", err) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} | ||||||
} | ||||||
} | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -40,7 +40,7 @@ func readAppsetFromURI(fileURL string, appset *[]*argoprojiov1alpha1.Application | |||||
|
||||||
yml, err := readFilePayload() | ||||||
if err != nil { | ||||||
return err | ||||||
return fmt.Errorf("error reading file payload %w", err) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} | ||||||
|
||||||
return readAppset(yml, appset) | ||||||
|
@@ -49,18 +49,18 @@ func readAppsetFromURI(fileURL string, appset *[]*argoprojiov1alpha1.Application | |||||
func readAppset(yml []byte, appsets *[]*argoprojiov1alpha1.ApplicationSet) error { | ||||||
yamls, err := kube.SplitYAMLToString(yml) | ||||||
if err != nil { | ||||||
return err | ||||||
return fmt.Errorf("error splitting YAML to string %w", err) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} | ||||||
|
||||||
for _, yml := range yamls { | ||||||
var appset argoprojiov1alpha1.ApplicationSet | ||||||
err = config.Unmarshal([]byte(yml), &appset) | ||||||
if err != nil { | ||||||
return err | ||||||
return fmt.Errorf("error unmarshalling appset %w", err) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} | ||||||
*appsets = append(*appsets, &appset) | ||||||
|
||||||
} | ||||||
|
||||||
return err | ||||||
return fmt.Errorf("error reading app set %w", err) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -3,7 +3,7 @@ package controller | |||||
import ( | ||||||
"context" | ||||||
"time" | ||||||
|
||||||
"fmt" | ||||||
"github.com/argoproj/gitops-engine/pkg/cache" | ||||||
"github.com/argoproj/gitops-engine/pkg/utils/kube" | ||||||
log "github.com/sirupsen/logrus" | ||||||
|
@@ -93,7 +93,7 @@ func (c *clusterInfoUpdater) updateClusters() { | |||||
func (c *clusterInfoUpdater) updateClusterInfo(cluster appv1.Cluster, info *cache.ClusterInfo) error { | ||||||
apps, err := c.appLister.List(labels.Everything()) | ||||||
if err != nil { | ||||||
return err | ||||||
return fmt.Errorf("error while fetching the apps list %w", err) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} | ||||||
var appCount int64 | ||||||
for _, a := range apps { | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.