{"record":{"id":"3faed36323667598","repo":"kubernetes/kops","slug":"error-determining-os-distribution-v-3faed3","errorCode":null,"errorMessage":"error determining OS distribution: %v","messagePattern":"error determining OS distribution: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/nodeup/command.go","lineNumber":179,"sourceCode":"\tif bootConfig.NodeupConfigHash != \"\" {\n\t\tif want, got := bootConfig.NodeupConfigHash, base64.StdEncoding.EncodeToString(nodeupConfigHash[:]); got != want {\n\t\t\treturn fmt.Errorf(\"nodeup config hash mismatch (was %q, expected %q)\", got, want)\n\t\t}\n\t}\n\n\terr = evaluateSpec(&nodeupConfig, bootConfig.CloudProvider, region)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tarchitecture, err := architectures.FindArchitecture()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error determining OS architecture: %v\", err)\n\t}\n\n\tdistribution, err := distributions.FindDistribution(\"/\")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error determining OS distribution: %v\", err)\n\t}\n\n\tconfigAssets := nodeupConfig.Assets[architecture]\n\tassetStore := fi.NewAssetStore(c.CacheDir)\n\tfor _, asset := range configAssets {\n\t\terr := assetStore.Add(ctx, asset)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error adding asset %q: %v\", asset, err)\n\t\t}\n\t}\n\n\t// cloud holds the AWS clients, on AWS only.\n\tvar cloud *awsup.Cloud\n\n\tif bootConfig.CloudProvider == api.CloudProviderAWS {\n\t\tcloud, err = awsup.NewCloud(ctx, region)\n\t\tif err != nil {\n\t\t\treturn err","sourceCodeStart":161,"sourceCodeEnd":197,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/nodeup/command.go#L161-L197","documentation":"nodeup identifies the node's OS distribution (e.g. Ubuntu, Debian, Flatcar, RockyLinux) by inspecting / via distributions.FindDistribution(\"/\"), which reads /etc/os-release and similar files. This error means detection failed, so nodeup cannot pick distribution-specific packages, systemd units, or file layouts. Run aborts before building the model.","triggerScenarios":"Calling NodeUpCommand.Run() on a host whose root filesystem lacks the files FindDistribution relies on — missing or empty /etc/os-release, an unsupported distribution string, or an unreadable root — during the detection step at command.go:177.","commonSituations":"Custom/minimal base images (distroless, custom AMIs) without /etc/os-release; very new or very old distro versions unsupported by the kOps release; containers with an incomplete root filesystem; heavily stripped OS images.","solutions":["Ensure /etc/os-release exists and is populated on the node image (restore it from the distro's base-files/os-release package).","Use a kOps-supported OS image (Ubuntu, Debian, RockyLinux/RHEL, Flatcar, AmazonLinux) for the instance group via 'kops create instancegroup' / image setting.","Upgrade kOps if the distro version is newer than the release supports (e.g. brand-new Ubuntu LTS).","Verify the root filesystem is mounted and readable (FindDistribution is called with \"/\") — check mount namespace issues in containerized invocations."],"exampleFix":"// before: Dockerfile-based node image stripped of os-release\nRUN rm -f /etc/os-release\n// after: keep distro identification files intact\n# do not remove /etc/os-release; nodeup requires it","handlingStrategy":"validation","validationCode":"// Confirm /etc/os-release exists and is parseable before running nodeup\nb, err := os.ReadFile(\"/etc/os-release\")\nif err != nil {\n    return fmt.Errorf(\"node image missing /etc/os-release: %w\", err)\n}\nif !strings.Contains(string(b), \"ID=\") {\n    return fmt.Errorf(\"/etc/os-release is malformed\")\n}","typeGuard":null,"tryCatchPattern":"err := cmd.Run(out)\nif err != nil && strings.Contains(err.Error(), \"error determining OS distribution\") {\n    // switch to a kOps-supported OS image for the instance group\n}","preventionTips":["Build node images from kOps-supported base images (Ubuntu, Debian, RockyLinux, Flatcar, AmazonLinux)","Never strip /etc/os-release or lsb files from custom node images","Check the kOps supported-matrix for your distro version before upgrading the OS"],"tags":["nodeup","distribution","os-detection","bootstrap"],"backgroundTag":"os-distribution-detection-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"}