mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-15 22:20:51 +00:00
e2e: use error wrapping with %w
The recently introduced failure handling in ExpectNoError depends on error wrapping: if an error prefix gets added with `fmt.Errorf("foo: %v", err)`, then ExpectNoError cannot detect that the root cause is an assertion failure and then will add another useless "unexpected error" prefix and will not dump the additional failure information (currently the backtrace inside the E2E framework). Instead of manually deciding on a case-by-case basis where %w is needed, all error wrapping was updated automatically with sed -i "s/fmt.Errorf\(.*\): '*\(%s\|%v\)'*\",\(.* err)\)/fmt.Errorf\1: %w\",\3/" $(git grep -l 'fmt.Errorf' test/e2e*) This may be unnecessary in some cases, but it's not wrong.
This commit is contained in:
@@ -506,7 +506,7 @@ func listPodDirectory(ctx context.Context, h storageutils.HostExec, path string,
|
||||
cmd := fmt.Sprintf("find %s -mindepth 2 -maxdepth 2", path)
|
||||
out, err := h.IssueCommandWithResult(ctx, cmd, node)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error checking directory %s on node %s: %s", path, node.Name, err)
|
||||
return nil, fmt.Errorf("error checking directory %s on node %s: %w", path, node.Name, err)
|
||||
}
|
||||
return strings.Split(out, "\n"), nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user