{"record":{"id":"634527059ca0d9bc","repo":"kubernetes/kops","slug":"error-listing-q-v","errorCode":null,"errorMessage":"error listing %q: %v","messagePattern":"error listing %q: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"pkg/dump/dumper.go","lineNumber":529,"sourceCode":"\t\trel := strings.TrimPrefix(f, \"/etc/containerd/\")\n\t\tdest := filepath.Join(n.dir, \"containerd\", rel)\n\t\tcmd := \"sudo cat '\" + strings.ReplaceAll(f, \"'\", `'\\''`) + \"'\"\n\t\tif err := n.shellToFile(ctx, cmd, dest); err != nil {\n\t\t\terrors = append(errors, err)\n\t\t}\n\t}\n\n\treturn errors\n}\n\n// findFiles lists files under the specified directory (recursively)\nfunc (n *logDumperNode) findFiles(ctx context.Context, dir string) ([]string, error) {\n\tvar stdout bytes.Buffer\n\tvar stderr bytes.Buffer\n\n\terr := n.client.ExecPiped(ctx, \"sudo find \"+dir+\" -type f -print0\", &stdout, &stderr)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error listing %q: %v\", dir, err)\n\t}\n\n\tpaths := []string{}\n\tfor _, b := range bytes.Split(stdout.Bytes(), []byte{0}) {\n\t\tif len(b) == 0 {\n\t\t\t// Likely the last value\n\t\t\tcontinue\n\t\t}\n\t\tpaths = append(paths, string(b))\n\t}\n\treturn paths, nil\n}\n\n// listSystemdUnits returns the list of systemd units on the node\nfunc (n *logDumperNode) listSystemdUnits(ctx context.Context) ([]string, error) {\n\tvar stdout bytes.Buffer\n\tvar stderr bytes.Buffer\n","sourceCodeStart":511,"sourceCodeEnd":547,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/dump/dumper.go#L511-L547","documentation":"Returned by logDumperNode.findFiles (pkg/dump/dumper.go:529) when ExecPiped of `sudo find <dir> -type f -print0` over the SSH client returns an error. The message names the directory that could not be listed. Callers (dump) translate this into the 'error reading /var/log' or 'error listing /etc/containerd' variants, and it is the root cause behind most per-collection listing failures.","triggerScenarios":"n.client.ExecPiped(ctx, \"sudo find \"+dir+\" -type f -print0\", &stdout, &stderr) fails: non-zero exit of find (missing directory, permission denied under sudo), dead SSH session, or ctx.Err() (nodeDumpTimeout expired) checked at ExecPiped entry.","commonSituations":"find run on a directory that doesn't exist on that node image (e.g. /etc/containerd on docker nodes); sudo requiring a password; node overloaded so the 1-minute dump timeout expires; SSH connection reset during long find on huge directory trees.","solutions":["Reproduce locally: `ssh <node> sudo find <dir> -type f -print0`; the remote exit status/stderr shows the true cause.","Check the named directory exists on the node image; skip the listing when the runtime (docker vs containerd) doesn't use it.","Verify passwordless sudo (NOPASSWD) for the SSH user on the node.","Raise --node-dump-timeout if the wrapped error is context deadline exceeded.","Retry on transient SSH errors; check node stability (no concurrent replacement/reboot)."],"exampleFix":"// before\nerr := n.client.ExecPiped(ctx, \"sudo find \"+dir+\" -type f -print0\", &stdout, &stderr)\nif err != nil {\n    return nil, fmt.Errorf(\"error listing %q: %v\", dir, err)\n}\n// after\ncmd := \"if [ -d \" + quoteShell(dir) + \" ]; then sudo find \" + dir + \" -type f -print0; fi\"\nerr := n.client.ExecPiped(ctx, cmd, &stdout, &stderr)\nif err != nil {\n    return nil, fmt.Errorf(\"error listing %q: %w\", dir, err)\n}","handlingStrategy":"validation","validationCode":"// guard the remote find with an existence test so missing dirs don't error\ncmd := fmt.Sprintf(\"test -d %q && sudo find %q -type f -print0 || true\", dir, dir)\nerr := n.client.ExecPiped(ctx, cmd, &stdout, &stderr)","typeGuard":null,"tryCatchPattern":"paths, err := n.findFiles(ctx, dir)\nif err != nil {\n    if errors.Is(err, context.DeadlineExceeded) {\n        return nil, fmt.Errorf(\"find on %q timed out; increase node timeout\", dir)\n    }\n    return nil, err\n}","preventionTips":["Check the directory exists on the node image before listing it.","Ensure passwordless sudo for the dump user.","Budget the per-node timeout for large directory trees."],"tags":["ssh","filesystem","node-dump","go"],"backgroundTag":"remote-command-failed","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}