kubernetes/kops · error
error checking for /run/cilium/cgroupv2: %v
Error message
error checking for /run/cilium/cgroupv2: %v
What it means
buildCgroup2Mount calls unix.Statfs on /run/cilium/cgroupv2; if the error is anything other than os.ErrNotExist (which is tolerated because systemd creates the path), the error is wrapped and the build fails. This guards against unexpected filesystem errors on the cgroup path.
Source
Thrown at nodeup/pkg/model/networking/cilium.go:124
Name: "sys-fs-bpf.mount",
Definition: new(unit),
}
service.InitDefaults()
c.AddTask(service)
}
return nil
}
func (b *CiliumBuilder) buildCgroup2Mount(c *fi.NodeupModelBuilderContext) error {
cgroupPath := "/run/cilium/cgroupv2"
var fsdata unix.Statfs_t
err := unix.Statfs(cgroupPath, &fsdata)
// If the path does not exist, systemd will create it
if err != nil && !errors.Is(err, os.ErrNotExist) {
return fmt.Errorf("error checking for /run/cilium/cgroupv2: %v", err)
}
CGROUP_FS_MAGIC := uint32(0x63677270)
alreadyMounted := uint32(fsdata.Type) == CGROUP_FS_MAGIC
if !alreadyMounted {
unit := `
[Unit]
Description=Cilium Cgroup2 mounts
Documentation=http://docs.cilium.io/
DefaultDependencies=no
Before=local-fs.target umount.target kubelet.service
[Mount]
What=cgroup2
Where=/run/cilium/cgroupv2
Type=cgroup2View on GitHub (pinned to 4c8573c808)
Solutions
- Check permissions and type of /run/cilium/cgroupv2 (remove a stray non-directory file: rm and let systemd recreate it)
- Ensure /run is a writable tmpfs mount when nodeup runs
- Read the wrapped errno in the message and fix the underlying filesystem condition
- Reboot/clean stale state in /run/cilium and re-run nodeup
Example fix
// before $ ls -ld /run/cilium/cgroupv2 -rw-r--r-- 1 root root 0 ... # stray file, not a directory // after $ rm /run/cilium/cgroupv2 # systemd will create the cgroup dir
Defensive patterns
Strategy: type-guard
Validate before calling
var fsdata unix.Statfs_t
err := unix.Statfs("/run/cilium/cgroupv2", &fsdata)
if err != nil && !errors.Is(err, os.ErrNotExist) {
// inspect errno
klog.Errorf("unexpected cgroupv2 stat error: %v", err)
}
if fi, statErr := os.Stat("/run/cilium/cgroupv2"); statErr == nil && !fi.IsDir() {
klog.Warning("/run/cilium/cgroupv2 is not a directory; remove it")
} Try / catch
err := unix.Statfs(cgroupPath, &fsdata)
if err != nil && !errors.Is(err, os.ErrNotExist) {
return fmt.Errorf("error checking for /run/cilium/cgroupv2: %v", err)
} Prevention
- Check /run/cilium state after failed prior runs
- Ensure /run is a writable tmpfs on all node images
- Use errors.Is(err, os.ErrNotExist) semantics when tolerating missing paths
When it happens
Trigger: unix.Statfs(cgroupPath) fails with e.g. EACCES, ENOTDIR, ELOOP, or an I/O error — anything besides ENOENT — during nodeup Build with Cilium enabled.
Common situations: /run not mounted or read-only; a non-directory file occupying /run/cilium/cgroupv2; permission/hardening policies blocking stat on /run paths; symlink loops from earlier failed runs.
Related errors
- failed to create cgroupv2 mount unit: %w
- error checking for /sys/fs/bpf: %v
- path: %s already exists but is not a directory
- failed to read %s: %w
- failed to create bpf mount unit: %w
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/57006d2ffec0237d.
Report an issue: GitHub.