kubernetes/kops · error
reading %s: %w
Error message
reading %s: %w
What it means
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.
Source
Thrown at nodeup/pkg/model/networking/eni_networking.go:215
}
defer resp.Content.Close()
mac, err := io.ReadAll(resp.Content)
if err != nil {
return "", fmt.Errorf("reading primary MAC address from ec2 metadata: %w", err)
}
return findPhysicalInterfaceByMAC("/sys/class/net", strings.TrimSpace(string(mac)))
}
// findPhysicalInterfaceByMAC gives the name of the physical network interface that has the
// specified MAC address. The function ignores the virtual interfaces (veths, bridges, VLANs),
// because a virtual interface can have the same MAC address as a physical interface. The
// function gives an error if it does not find exactly one physical interface with this MAC
// address.
func findPhysicalInterfaceByMAC(sysClassNet string, mac string) (string, error) {
entries, err := os.ReadDir(sysClassNet)
if err != nil {
return "", fmt.Errorf("reading %s: %w", sysClassNet, err)
}
var matches []string
for _, entry := range entries {
name := entry.Name()
// The scan uses the "device" symlink in sysfs to know if an interface is physical.
if _, err := os.Stat(filepath.Join(sysClassNet, name, "device")); err != nil {
continue
}
address, err := os.ReadFile(filepath.Join(sysClassNet, name, "address"))
if err != nil {
continue
}
if strings.EqualFold(strings.TrimSpace(string(address)), mac) {
matches = append(matches, name)
}
}
View on GitHub (pinned to 4c8573c808)
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
Example fix
// before: container without sysfs docker run nodeup... // after docker run -v /sys:/sys:ro --privileged nodeup...
Defensive patterns
Strategy: validation
Prevention
- Mount /sys in any container running nodeup
- Preflight-check /sys/class/net before provisioning
When it happens
Trigger: os.ReadDir("/sys/class/net") fails — sysfs not mounted, running in a restricted container/namespace where /sys is not available, or filesystem corruption.
Common situations: 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.
Related errors
- no physical network interface found with MAC address %q
- error querying kubernetes version: %v
- error loading channel %q: %v
- error querying ec2 metadata service (for region): %v
- listing nodes in cluster: %v
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/eb18770c7463caac.
Report an issue: GitHub.