kubernetes/kops · warning
error listing %q: %v
Error message
error listing %q: %v
What it means
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.
Source
Thrown at pkg/dump/dumper.go:529
rel := strings.TrimPrefix(f, "/etc/containerd/")
dest := filepath.Join(n.dir, "containerd", rel)
cmd := "sudo cat '" + strings.ReplaceAll(f, "'", `'\''`) + "'"
if err := n.shellToFile(ctx, cmd, dest); err != nil {
errors = append(errors, err)
}
}
return errors
}
// findFiles lists files under the specified directory (recursively)
func (n *logDumperNode) findFiles(ctx context.Context, dir string) ([]string, error) {
var stdout bytes.Buffer
var stderr bytes.Buffer
err := n.client.ExecPiped(ctx, "sudo find "+dir+" -type f -print0", &stdout, &stderr)
if err != nil {
return nil, fmt.Errorf("error listing %q: %v", dir, err)
}
paths := []string{}
for _, b := range bytes.Split(stdout.Bytes(), []byte{0}) {
if len(b) == 0 {
// Likely the last value
continue
}
paths = append(paths, string(b))
}
return paths, nil
}
// listSystemdUnits returns the list of systemd units on the node
func (n *logDumperNode) listSystemdUnits(ctx context.Context) ([]string, error) {
var stdout bytes.Buffer
var stderr bytes.Buffer
View on GitHub (pinned to 4c8573c808)
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).
Example fix
// before
err := n.client.ExecPiped(ctx, "sudo find "+dir+" -type f -print0", &stdout, &stderr)
if err != nil {
return nil, fmt.Errorf("error listing %q: %v", dir, err)
}
// after
cmd := "if [ -d " + quoteShell(dir) + " ]; then sudo find " + dir + " -type f -print0; fi"
err := n.client.ExecPiped(ctx, cmd, &stdout, &stderr)
if err != nil {
return nil, fmt.Errorf("error listing %q: %w", dir, err)
} Defensive patterns
Strategy: validation
Validate before calling
// guard the remote find with an existence test so missing dirs don't error
cmd := fmt.Sprintf("test -d %q && sudo find %q -type f -print0 || true", dir, dir)
err := n.client.ExecPiped(ctx, cmd, &stdout, &stderr) Try / catch
paths, err := n.findFiles(ctx, dir)
if err != nil {
if errors.Is(err, context.DeadlineExceeded) {
return nil, fmt.Errorf("find on %q timed out; increase node timeout", dir)
}
return nil, err
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- error reading /var/log: %v
- error listing systemd services: %v
- error listing /etc/containerd: %v
- error listing systemd units: %v
- error creating file %q: %v
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/634527059ca0d9bc.
Report an issue: GitHub.