{"record":{"id":"48565be4c963d58f","repo":"kubernetes/kops","slug":"error-creating-resource-dumper-w","errorCode":null,"errorMessage":"error creating resource dumper: %w","messagePattern":"error creating resource dumper: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops/toolbox_dump.go","lineNumber":280,"sourceCode":"\t\t\tsshUser := options.SSHUser\n\t\t\tdumper.SetSSHAccessGranter(func(ctx context.Context, instanceID string) error {\n\t\t\t\t_, err := eicClient.SendSSHPublicKey(ctx, &ec2instanceconnect.SendSSHPublicKeyInput{\n\t\t\t\t\tInstanceId:     aws.String(instanceID),\n\t\t\t\t\tInstanceOSUser: aws.String(sshUser),\n\t\t\t\t\tSSHPublicKey:   aws.String(publicKey),\n\t\t\t\t})\n\t\t\t\treturn err\n\t\t\t})\n\t\t}\n\n\t\tif err := dumper.DumpAllNodes(ctx, nodes, options.MaxNodes, cloudResources); err != nil {\n\t\t\tklog.Warningf(\"error dumping nodes: %v\", err)\n\t\t}\n\n\t\tif kubeConfig != nil && options.K8sResources {\n\t\t\tdumper, err := dump.NewResourceDumper(kubeConfig, options.Output, options.Dir)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"error creating resource dumper: %w\", err)\n\t\t\t}\n\t\t\tif err := dumper.DumpResources(ctx); err != nil {\n\t\t\t\tklog.Warningf(\"error dumping resources: %v\", err)\n\t\t\t}\n\n\t\t\tlogDumper, err := dump.NewPodLogDumper(kubeConfig, options.Dir)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"error creating pod log dumper: %w\", err)\n\t\t\t}\n\t\t\tif err := logDumper.DumpLogs(ctx); err != nil {\n\t\t\t\tklog.Warningf(\"error dumping pod logs: %v\", err)\n\t\t\t}\n\t\t}\n\t}\n\n\tif cloudResources != nil {\n\t\tswitch options.Output {\n\t\tcase OutputYaml:","sourceCodeStart":262,"sourceCodeEnd":298,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/toolbox_dump.go#L262-L298","documentation":"When --k8s-resources is enabled, toolbox dump creates a dump.ResourceDumper from the gathered kubeconfig to export Kubernetes API resources. This error wraps construction failure — usually the kubeconfig/context is unusable (missing server, bad credentials, unreachable API). The dump continues for other resources but k8s resource dumping is skipped.","triggerScenarios":"dump.NewResourceDumper(kubeConfig, options.Output, options.Dir) returns an error while building the Kubernetes clientset or validating output/dir options during `kops toolbox dump` with k8s resources enabled.","commonSituations":"Cluster's API server unreachable or deleted but kubeconfig present; stale/invalid admin kubeconfig credentials (expired certificate); output directory not writable; kops toolbox dump run before the cluster is actually up.","solutions":["Check cluster is running: kubectl --kubeconfig <dumped kubeconfig> get nodes.","Regenerate admin credentials: kops export kubeconfig --admin <cluster>.","Ensure --dir output path exists and is writable.","If the cluster was deleted, drop --k8s-resources and dump only cloud state."],"exampleFix":"// before\nkops toolbox dump --name c.k8s.local --k8s-resources  # expired admin creds\n// after\nkops export kubeconfig --admin c.k8s.local\nkops toolbox dump --name c.k8s.local --k8s-resources","handlingStrategy":"try-catch","validationCode":"kops export kubeconfig \"$CLUSTER_NAME\" && kubectl cluster-info --kubeconfig ~/.kube/config >/dev/null || { echo \"k8s API unreachable; skipping --k8s-resources\"; }","typeGuard":null,"tryCatchPattern":"dumper, err := dump.NewResourceDumper(kubeConfig, options.Output, options.Dir)\nif err != nil {\n    klog.Warningf(\"skipping k8s resource dump (kubeconfig or client init failed): %v\", err)\n    // fall back to cloud-only dump\n}","preventionTips":["Ensure the cluster is fully up before dumping k8s resources","Refresh admin credentials with kops export kubeconfig --admin periodically","Verify output --dir exists and is writable","Omit --k8s-resources when only cloud state is needed or API is known-down"],"tags":["kops","toolbox-dump","kubernetes-api"],"backgroundTag":"kubeconfig-client-init-failed","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}