cmd/kubeadm: ignore EINVAL error during unmount

If /var/lib/kubelet is MS_SHARED mountpoint, all the mountpoints
under /var/lib/kubelet will have duplicate one. When `kubeadm reset -f`
is executed, it will try to umount one path twice. However, they are in
the peer group. Once we umount one path, the duplicate one will be
umounted as well. So, in this case, we should ignore EINVAL error.

Signed-off-by: Wei Fu <fuweid89@gmail.com>
(cherry picked from commit 2634261c17)
Signed-off-by: Wei Fu <fuweid89@gmail.com>
This commit is contained in:
Wei Fu
2026-03-06 11:08:42 -05:00
parent 3b27d54731
commit da50ffde17

View File

@@ -70,6 +70,12 @@ func unmountKubeletDirectory(kubeletRunDirectory string, flags []string) error {
}
klog.V(5).Infof("[reset] Unmounting %q", m[1])
if err := syscall.Unmount(m[1], flagsInt); err != nil {
// EINVAL is expected here if a duplicate mount entry
// was already unmounted via its shared peer.
if err == syscall.EINVAL {
klog.Warningf("[reset] Ignoring EINVAL error while unmounting %q", m[1])
continue
}
errList = append(errList, errors.WithMessagef(err, "failed to unmount %q", m[1]))
}
}