From 9c4e4afa79024b3123cc1dd4476efd237a18f80f Mon Sep 17 00:00:00 2001 From: Crypto89 Date: Tue, 25 Mar 2025 18:36:46 +0100 Subject: [PATCH] csi: fix CSI ExpandVolume stagingPath (#25253) Fix the checking of the staging path against the mountRoot on the host rather then checking against the containerMountPoint which (probably) never exists on the host causing it to default back the the legacy behaviour. --- .changelog/25253.txt | 3 +++ client/pluginmanager/csimanager/volume.go | 10 ++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 .changelog/25253.txt diff --git a/.changelog/25253.txt b/.changelog/25253.txt new file mode 100644 index 000000000..4ecd5fadb --- /dev/null +++ b/.changelog/25253.txt @@ -0,0 +1,3 @@ +```release-note:bug +csi: Fixed a CSI ExpandVolume bug where the namespace was left out of the staging path +``` diff --git a/client/pluginmanager/csimanager/volume.go b/client/pluginmanager/csimanager/volume.go index 18251afcb..f59f3c939 100644 --- a/client/pluginmanager/csimanager/volume.go +++ b/client/pluginmanager/csimanager/volume.go @@ -293,7 +293,7 @@ func (v *volumeManager) unstageVolume(ctx context.Context, volNS, volID, remoteI // plugin to perform unstaging stagingPath := v.stagingDirForVolume(v.containerMountPoint, volNS, volID, usage) - // This it the path from the host, which we need to use to verify whether + // This is the path from the host, which we need to use to verify whether // the path is the right one to pass to the plugin container hostStagingPath := v.stagingDirForVolume(v.mountRoot, volNS, volID, usage) _, err := os.Stat(hostStagingPath) @@ -416,8 +416,14 @@ func (v *volumeManager) ExpandVolume(ctx context.Context, volNS, volID, remoteID "volume_id", volID, "alloc_id", allocID, "error", err) } + // This is the staging path inside the container, which we pass to the + // plugin to perform expansion stagingPath := v.stagingDirForVolume(v.containerMountPoint, volNS, volID, usage) - _, err = os.Stat(stagingPath) + + // This is the path from the host, which we need to use to verify whether + // the path is the right one to pass to the plugin container + hostStagingPath := v.stagingDirForVolume(v.mountRoot, volNS, volID, usage) + _, err = os.Stat(hostStagingPath) if err != nil && errors.Is(err, fs.ErrNotExist) { // COMPAT: it's possible to get an unmount request that includes the // namespace even for volumes that were mounted before the path included