kubernetes/kops · error
error creating pod log dumper: %w
Error message
error creating pod log dumper: %w
What it means
RunToolboxDump (`kops toolbox dump`) collects cluster state and, when dumping a running cluster, creates a PodLogDumper to fetch pod logs via the cluster kubeconfig. This error wraps any failure from dump.NewPodLogDumper — typically an invalid or unreadable kubeconfig path, or failure to build a Kubernetes client from it. The dump command aborts because logs are considered part of the requested dump.
Source
Thrown at cmd/kops/toolbox_dump.go:288
})
}
if err := dumper.DumpAllNodes(ctx, nodes, options.MaxNodes, cloudResources); err != nil {
klog.Warningf("error dumping nodes: %v", err)
}
if kubeConfig != nil && options.K8sResources {
dumper, err := dump.NewResourceDumper(kubeConfig, options.Output, options.Dir)
if err != nil {
return fmt.Errorf("error creating resource dumper: %w", err)
}
if err := dumper.DumpResources(ctx); err != nil {
klog.Warningf("error dumping resources: %v", err)
}
logDumper, err := dump.NewPodLogDumper(kubeConfig, options.Dir)
if err != nil {
return fmt.Errorf("error creating pod log dumper: %w", err)
}
if err := logDumper.DumpLogs(ctx); err != nil {
klog.Warningf("error dumping pod logs: %v", err)
}
}
}
if cloudResources != nil {
switch options.Output {
case OutputYaml:
b, err := kops.ToRawYaml(cloudResources)
if err != nil {
return fmt.Errorf("error marshaling yaml: %v", err)
}
_, err = out.Write(b)
if err != nil {
return fmt.Errorf("error writing to stdout: %v", err)
}View on GitHub (pinned to 4c8573c808)
Solutions
- Verify the kubeconfig exists and is valid: kubectl --kubeconfig <path> get nodes
- Re-export the cluster admin kubeconfig (kops export kubecfg <cluster>) and retry
- Confirm the cluster API server is reachable from your machine
- Check the --dir target is writable/valid
Example fix
// before
logDumper, err := dump.NewPodLogDumper(kubeConfig, options.Dir)
if err != nil {
return fmt.Errorf("error creating pod log dumper: %w", err)
}
// after — fail fast with a clear hint before dumping
if _, err := os.Stat(kubeConfig); err != nil {
return fmt.Errorf("kubeconfig %q not found; run 'kops export kubecfg': %w", kubeConfig, err)
}
logDumper, err := dump.NewPodLogDumper(kubeConfig, options.Dir)
if err != nil {
return fmt.Errorf("error creating pod log dumper: %w", err)
} Defensive patterns
Strategy: try-catch
Validate before calling
if _, err := os.Stat(kubeconfigPath); err != nil {
return fmt.Errorf("kubeconfig %q unreadable: %w", kubeconfigPath, err)
}
if err := clientcmd.LoadFromFile(kubeconfigPath); err != nil {
return fmt.Errorf("kubeconfig %q invalid: %w", kubeconfigPath, err)
} Try / catch
if _, err := dump.NewPodLogDumper(kubeConfig, dir); err != nil {
var pe *fs.PathError
if errors.As(err, &pe) {
// kubeconfig path problem: hint at 'kops export kubecfg'
}
return fmt.Errorf("error creating pod log dumper: %w", err)
} Prevention
- Always run `kops export kubecfg <cluster>` before toolbox dump
- Validate kubeconfig with kubectl before running kops toolbox commands
- Pass --kubeconfig explicitly in scripts instead of relying on KUBECONFIG env
- Check cluster is running before dumping
When it happens
Trigger: Running `kops toolbox dump` against a cluster when the resolved kubeconfig (options.KubeConfig / --kubeconfig) is missing, malformed, points to an unreachable API server during client construction, or the dump directory option is invalid.
Common situations: KUBECONFIG env var points at a stale file; cluster was deleted so the admin kubeconfig no longer authenticates; user passed --kubeconfig with a typo; running outside the cluster context where the admin.conf exists.
Related errors
- cannot load kubecfg settings for %q: %w
- building kubernetes client for node labeler: %w
- building kube client: %w
- building dynamic client: %w
- getting rest config: %w
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/c38cdce69c0ed21d.
Report an issue: GitHub.