{"record":{"id":"eb18770c7463caac","repo":"kubernetes/kops","slug":"reading-s-w","errorCode":null,"errorMessage":"reading %s: %w","messagePattern":"reading (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nodeup/pkg/model/networking/eni_networking.go","lineNumber":215,"sourceCode":"\t}\n\tdefer resp.Content.Close()\n\tmac, err := io.ReadAll(resp.Content)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"reading primary MAC address from ec2 metadata: %w\", err)\n\t}\n\n\treturn findPhysicalInterfaceByMAC(\"/sys/class/net\", strings.TrimSpace(string(mac)))\n}\n\n// findPhysicalInterfaceByMAC gives the name of the physical network interface that has the\n// specified MAC address. The function ignores the virtual interfaces (veths, bridges, VLANs),\n// because a virtual interface can have the same MAC address as a physical interface. The\n// function gives an error if it does not find exactly one physical interface with this MAC\n// address.\nfunc findPhysicalInterfaceByMAC(sysClassNet string, mac string) (string, error) {\n\tentries, err := os.ReadDir(sysClassNet)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"reading %s: %w\", sysClassNet, err)\n\t}\n\n\tvar matches []string\n\tfor _, entry := range entries {\n\t\tname := entry.Name()\n\t\t// The scan uses the \"device\" symlink in sysfs to know if an interface is physical.\n\t\tif _, err := os.Stat(filepath.Join(sysClassNet, name, \"device\")); err != nil {\n\t\t\tcontinue\n\t\t}\n\t\taddress, err := os.ReadFile(filepath.Join(sysClassNet, name, \"address\"))\n\t\tif err != nil {\n\t\t\tcontinue\n\t\t}\n\t\tif strings.EqualFold(strings.TrimSpace(string(address)), mac) {\n\t\t\tmatches = append(matches, name)\n\t\t}\n\t}\n","sourceCodeStart":197,"sourceCodeEnd":233,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/nodeup/pkg/model/networking/eni_networking.go#L197-L233","documentation":"findPhysicalInterfaceByMAC lists /sys/class/net via os.ReadDir to map the primary ENI's MAC to an interface name; this error means the directory itself could not be read, so no interface scan is possible. It is only reachable on a system whose /sys/class/net is missing or unreadable, which should not happen on a healthy Linux node.","triggerScenarios":"os.ReadDir(\"/sys/class/net\") fails — sysfs not mounted, running in a restricted container/namespace where /sys is not available, or filesystem corruption.","commonSituations":"nodeup run inside a container lacking /sys mount (not on a real EC2 host); chroot/provisioning environments without sysfs; unit tests passing an invalid sysClassNet path.","solutions":["Ensure nodeup runs on the host (or with /sys mounted) — check the sysfs mount: mount | grep sysfs","If in a container, run privileged or bind-mount /sys","Fix underlying filesystem issues if /sys is corrupted (usually requires reboot)","In tests, pass a valid fixture directory as sysClassNet"],"exampleFix":"// before: container without sysfs\ndocker run nodeup...\n// after\ndocker run -v /sys:/sys:ro --privileged nodeup...","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Mount /sys in any container running nodeup","Preflight-check /sys/class/net before provisioning"],"tags":["linux","sysfs","network"],"backgroundTag":"sysfs-not-mounted","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"}