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.
This commit is contained in:
Crypto89
2025-03-25 18:36:46 +01:00
committed by GitHub
parent d67a74d0f4
commit 9c4e4afa79
2 changed files with 11 additions and 2 deletions

3
.changelog/25253.txt Normal file
View File

@@ -0,0 +1,3 @@
```release-note:bug
csi: Fixed a CSI ExpandVolume bug where the namespace was left out of the staging path
```

View File

@@ -293,7 +293,7 @@ func (v *volumeManager) unstageVolume(ctx context.Context, volNS, volID, remoteI
// plugin to perform unstaging // plugin to perform unstaging
stagingPath := v.stagingDirForVolume(v.containerMountPoint, volNS, volID, usage) 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 // the path is the right one to pass to the plugin container
hostStagingPath := v.stagingDirForVolume(v.mountRoot, volNS, volID, usage) hostStagingPath := v.stagingDirForVolume(v.mountRoot, volNS, volID, usage)
_, err := os.Stat(hostStagingPath) _, 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) "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) 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) { if err != nil && errors.Is(err, fs.ErrNotExist) {
// COMPAT: it's possible to get an unmount request that includes the // COMPAT: it's possible to get an unmount request that includes the
// namespace even for volumes that were mounted before the path included // namespace even for volumes that were mounted before the path included