Skip to content

Commit a7c3e07

Browse files
committed
libct: Improve error msg when idmap is not supported
This gives a more clear error message when idmap mounts are not supported on the source filesystem. For example, a k8s user will see this now in kubectl describe pod: Warning Failed 2s (x2 over 4s) kubelet, 127.0.0.1 Error: failed to create containerd task: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: failed to fulfil mount request: failed to set MOUNT_ATTR_IDMAP on /var/lib/kubelet/pods/f037a704-742c-40fe-8dbf-17ed9225c4df/volumes/kubernetes.io~empty-dir/hugepage: invalid argument (maybe the source filesystem doesn't support idmap mounts on this kernel?): unknown This gives a hint on where to look at. Signed-off-by: Rodrigo Campos <[email protected]>
1 parent c48c428 commit a7c3e07

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

libcontainer/mount_linux.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,12 @@ func mountFd(nsHandles *userns.Handles, m *configs.Mount) (*mountSource, error)
258258
Attr_set: unix.MOUNT_ATTR_IDMAP,
259259
Userns_fd: uint64(usernsFile.Fd()),
260260
}); err != nil {
261-
return nil, fmt.Errorf("failed to set MOUNT_ATTR_IDMAP on %s: %w", m.Source, err)
261+
extraMsg := ""
262+
if err == unix.EINVAL {
263+
extraMsg = " (maybe the filesystem used doesn't support idmap mounts on this kernel?)"
264+
}
265+
266+
return nil, fmt.Errorf("failed to set MOUNT_ATTR_IDMAP on %s: %w%s", m.Source, err, extraMsg)
262267
}
263268
} else {
264269
var err error

0 commit comments

Comments
 (0)