Run pod bind mounts in the host mount namespace via nsenter.

Kubelet checks volume mounts from the host namespace, so NodePublishVolume
must mkdir and bind-mount the pod target path on the host, not only inside
the CSI plugin container.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-06 08:57:30 +03:30
co-authored by Cursor
parent 62c26f6fda
commit 802c9b91f7
3 changed files with 45 additions and 39 deletions
+7 -1
View File
@@ -72,6 +72,9 @@ func (s *NodeServer) NodeUnstageVolume(ctx context.Context, req *csi.NodeUnstage
}
mounter := newMounter()
if err := unmountHost(req.GetStagingTargetPath()); err != nil {
return nil, internalError(err)
}
if err := cleanupMountPoint(req.GetStagingTargetPath(), mounter); err != nil {
return nil, internalError(err)
}
@@ -90,7 +93,7 @@ func (s *NodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublish
return nil, invalidArgument("staging target path is required")
}
if !isMounted(req.GetStagingTargetPath()) {
if !isMounted(req.GetStagingTargetPath()) && !isHostMounted(req.GetStagingTargetPath()) {
return nil, internalError(fmt.Errorf("staging path %s is not mounted", req.GetStagingTargetPath()))
}
@@ -111,6 +114,9 @@ func (s *NodeServer) NodeUnpublishVolume(ctx context.Context, req *csi.NodeUnpub
}
mounter := newMounter()
if err := unmountHost(req.GetTargetPath()); err != nil {
return nil, internalError(err)
}
if err := cleanupMountPoint(req.GetTargetPath(), mounter); err != nil {
return nil, internalError(err)
}