Skip to content

Commit 1bc36a4

Browse files
Copilotandyzhangx
andcommitted
Fix metadata replacement in NodeStageVolume
- Add subDirReplaceMap to handle pv/pvc metadata in subDir during staging - Ensure consistent behavior between staging and legacy mount paths Co-authored-by: andyzhangx <[email protected]>
1 parent e7b9160 commit 1bc36a4

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

pkg/nfs/nodeserver.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,8 @@ func (ns *NodeServer) NodeStageVolume(_ context.Context, req *csi.NodeStageVolum
384384
mountOptions := volCap.GetMount().GetMountFlags()
385385

386386
var server, baseDir, subDir string
387+
subDirReplaceMap := map[string]string{}
388+
387389
for k, v := range req.GetVolumeContext() {
388390
switch strings.ToLower(k) {
389391
case paramServer:
@@ -392,6 +394,12 @@ func (ns *NodeServer) NodeStageVolume(_ context.Context, req *csi.NodeStageVolum
392394
baseDir = v
393395
case paramSubDir:
394396
subDir = v
397+
case pvcNamespaceKey:
398+
subDirReplaceMap[pvcNamespaceMetadata] = v
399+
case pvcNameKey:
400+
subDirReplaceMap[pvcNameMetadata] = v
401+
case pvNameKey:
402+
subDirReplaceMap[pvNameMetadata] = v
395403
case mountOptionsField:
396404
if v != "" {
397405
mountOptions = append(mountOptions, v)
@@ -408,6 +416,9 @@ func (ns *NodeServer) NodeStageVolume(_ context.Context, req *csi.NodeStageVolum
408416
server = getServerFromSource(server)
409417
source := fmt.Sprintf("%s:%s", server, baseDir)
410418
if subDir != "" {
419+
// replace pv/pvc name namespace metadata in subDir
420+
subDir = replaceWithMap(subDir, subDirReplaceMap)
421+
411422
source = strings.TrimRight(source, "/")
412423
source = fmt.Sprintf("%s/%s", source, subDir)
413424
}

0 commit comments

Comments
 (0)