{"record":{"id":"98ae7096f50a15b7","repo":"kubernetes/kops","slug":"getting-pod-logs-for-the-current-instance-of-v-v","errorCode":null,"errorMessage":"getting pod logs for the current instance of %v/%v: %w","messagePattern":"getting pod logs for the current instance of (.+?)/(.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/dump/podlogs.go","lineNumber":123,"sourceCode":"\t\t\t\tvar statusErr *k8sErrors.StatusError\n\t\t\t\tif errors.As(err, &statusErr) {\n\t\t\t\t\tif statusErr.ErrStatus.Code != 400 {\n\t\t\t\t\t\tpodErr = errors.Join(podErr, fmt.Errorf(\"getting pod logs for the previous instance of %v/%v: %w\", pod.Namespace, pod.Name, err))\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\terr := writeContainerLogs(resPath+\".previous.log\", resp)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tpodErr = errors.Join(podErr, err)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t{\n\t\t\t\tresp, err := d.k8sClient.CoreV1().Pods(pod.Namespace).GetLogs(pod.Name, &v1.PodLogOptions{Container: container.Name}).Do(ctx).Raw()\n\t\t\t\tvar statusErr *k8sErrors.StatusError\n\t\t\t\tif errors.As(err, &statusErr) {\n\t\t\t\t\tif statusErr.ErrStatus.Code != 400 {\n\t\t\t\t\t\tpodErr = errors.Join(podErr, fmt.Errorf(\"getting pod logs for the current instance of %v/%v: %w\", pod.Namespace, pod.Name, err))\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\terr := writeContainerLogs(resPath+\".log\", resp)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tpodErr = errors.Join(podErr, err)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tresults <- podLogDumpResult{err: podErr}\n\t}\n}\n\nfunc writeContainerLogs(filePath string, contents []byte) error {\n\tresFile, err := os.Create(filePath)\n\tdefer func(resFile *os.File) {","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/dump/podlogs.go#L105-L141","documentation":"Fetching the current container logs failed with a non-400 status error; the log request to the API server failed, e.g. the pod was deleted mid-dump or kubelet could not retrieve the logs.","triggerScenarios":"Thrown at pkg/dump/podlogs.go:123 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the wrapped API error; NotFound usually means the pod was removed during the dump","Re-run the dump","Verify kubelet is healthy on the pod's node"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}