Skip to content

context.Resource generates unavoidable log-spam on Windows #179

@TBBle

Description

@TBBle

Noted in containerd/containerd#4419 where this is generating 140k lines of log output for a passing test suite.

func (c *context) Resource(p string, fi os.FileInfo) (Resource, error) and its subordinate func (c *context) resolveXAttrs(fp string, fi os.FileInfo, base *resource) (map[string][]byte, error) contain log.Printf or log.Println in non-error paths, which lead to unavoidable log-spam when using them on a system like Windows, which will see two log outputs for every file touched, even though one of these code paths is not an error.

It would be better for most of those to use github.com/pkg/errors.Wrap or fmt.Errorf's %w verb to capture the desired error, and if ignoring it, ignore it silently. github.com/pkg/errors is already in go.mod, so this would not be a new dependency.

As a fallback, perhaps being able to determine earlier (by testing or parameter) that xattr support is not present, logging it once per context rather than once per Resource might help.

I note a similiar issue in func BuildManifest(ctx Context) (*Manifest, error). A few lines later is a fmt.Errorf using %v that could use %w, exposing the underlying error programmatically.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions