{"record":{"id":"a11b77ddddf6babf","repo":"cilium/cilium","slug":"failed-to-parse-kernel-version-w","errorCode":null,"errorMessage":"failed to parse kernel version: %w","messagePattern":"failed to parse kernel version: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cilium-cli/connectivity/check/features.go","lineNumber":225,"sourceCode":"\t}\n\tresult[features.EncryptionPod] = features.Status{\n\t\tEnabled: mode != \"disabled\",\n\t\tMode:    mode,\n\t}\n\n\treturn nil\n}\n\nfunc (ct *ConnectivityTest) extractFeaturesFromUname(ctx context.Context, ciliumPod Pod, result features.Set) error {\n\tstdout, err := ciliumPod.K8sClient.ExecInPod(ctx, ciliumPod.Pod.Namespace, ciliumPod.Pod.Name,\n\t\tdefaults.AgentContainerName, []string{\"uname\", \"-r\"})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to fetch uname -r: %w\", err)\n\t}\n\n\tkernelVersion, err := version.ParseKernelVersion(stdout.String())\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to parse kernel version: %w\", err)\n\t}\n\n\tresult[features.RHEL] = features.Status{\n\t\tEnabled: versioncheck.MustCompile(\"<=4.18.0\")(kernelVersion),\n\t}\n\n\treturn nil\n}\n\nfunc (ct *ConnectivityTest) extractFeaturesFromK8sCluster(ctx context.Context, result features.Set) {\n\tflavor := ct.client.AutodetectFlavor(ctx)\n\n\tresult[features.Flavor] = features.Status{\n\t\tEnabled: flavor.Kind.String() != \"invalid\",\n\t\tMode:    strings.ToLower(flavor.Kind.String()),\n\t}\n}\n","sourceCodeStart":207,"sourceCodeEnd":243,"githubUrl":"https://github.com/cilium/cilium/blob/ac7b90affa4baf0642e6685319d56907b3a73a6d/cilium-cli/connectivity/check/features.go#L207-L243","documentation":"After fetching `uname -r` from the agent pod, cilium-cli parses the kernel version with version.ParseKernelVersion. This error means the string returned by uname could not be parsed into a kernel version.","triggerScenarios":"version.ParseKernelVersion(stdout.String()) fails on unexpected uname output, e.g. empty output, 'uname: command not found', kernel strings with unusual suffixes/characters the parser doesn't handle.","commonSituations":"Exec returned an error message on stdout instead of the release string; exotic/custom kernels (e.g. '-coreos', aarch64 with odd formatting, CONTAINER-optimized kernels) with non-standard release strings; minimal agent images lacking uname.","solutions":["Run `kubectl exec ... -- uname -r` and inspect the exact string","Compare with version.ParseKernelVersion's accepted format; account for suffixes","Ensure the agent container actually contains uname and PATH resolves it","Retry — transient exec errors can yield empty stdout","If the kernel string is truly exotic, file/report upstream to extend the parser"],"exampleFix":"// before: parse whatever came back\nkernelVersion, err := version.ParseKernelVersion(stdout.String())\nif err != nil { return fmt.Errorf(\"failed to parse kernel version: %w\", err) }\n// after: trim and sanity-check before parsing\nrelease := strings.TrimSpace(stdout.String())\nif release == \"\" {\n\treturn fmt.Errorf(\"empty uname -r output\")\n}\nkernelVersion, err := version.ParseKernelVersion(release)\nif err != nil { return fmt.Errorf(\"failed to parse kernel version %q: %w\", release, err) }","handlingStrategy":"try-catch","validationCode":"out, err := k8sClient.ExecInPod(ctx, ns, pod, \"cilium-agent\", []string{\"uname\", \"-r\"})\nif err == nil {\n\trelease := strings.TrimSpace(out.String())\n\tif release == \"\" || strings.Contains(release, \" \") {\n\t\tlog.Warnf(\"suspicious uname -r output: %q\", release)\n\t}\n}","typeGuard":"func looksLikeKernelRelease(s string) bool {\n\tparts := strings.Split(strings.TrimSpace(s), \".\")\n\treturn len(parts) >= 2 && isNumeric(parts[0]) && isNumeric(strings.SplitN(parts[1], \"-\", 2)[0])\n}","tryCatchPattern":"if err := ct.extractFeaturesFromUname(ctx, ciliumPod, result); err != nil {\n\tif strings.Contains(err.Error(), \"failed to parse kernel version\") {\n\t\tlog.Warnf(\"kernel version unparsable; skipping RHEL detection: %v\", err)\n\t\treturn nil\n\t}\n\treturn err\n}","preventionTips":["Sanity-check `uname -r` output on your target OS images before testing","Trim whitespace/newlines before parsing","If using custom kernels, verify version.ParseKernelVersion handles the release string","Fall back to node status nodeInfo.kubeletVersion where uname is unavailable"],"tags":["cilium","kernel","parsing","version"],"backgroundTag":"kernel-version-parse-failed","analyzedSha":"ac7b90affa4baf0642e6685319d56907b3a73a6d","analyzedAt":"2026-08-31T18:27:15.868Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}