Skip to content

Commit

Permalink
Fix volume not expanded when using authorization's volumePrefix (#412)
Browse files Browse the repository at this point in the history
* Fix volume not expanded when using authorization's volumePrefix

* add log print statements

* account for tenant vol prefix in volName

---------

Co-authored-by: root <[email protected]>
  • Loading branch information
AkshaySainiDell and shaynafinocchiaro authored Jan 14, 2025
1 parent eab2ec6 commit 7d21235
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions service/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -2660,10 +2660,25 @@ func (s *service) NodeExpandVolume(

// Get the pmax volume name so that it can be searched in the system
// to find mount information
replace := CSIPrefix + "-" + s.getClusterPrefix() + "-"
volName := strings.Replace(vol.VolumeIdentifier, replace, "", 1)
// remove the namespace from the volName as the mount paths will not have it
volName = strings.Join(strings.Split(volName, "-")[:2], "-")
// Examples of possible volumeIdentifiers: tn1-csi-ABC-csm-3f7da6bf8d-test, csi-ABC-csm-3f7da6bf8d-test
parts := strings.Split(vol.VolumeIdentifier, "-")

var volName string
clusterPrefix := s.getClusterPrefix()
// remove the tenant volume prefix (csm-authorization) and namespace from the volName as the mount paths will not have it
for i, p := range parts {
if p == CSIPrefix {
if i+3 < len(parts) {
if parts[i+1] == clusterPrefix {
volName = parts[i+2] + "-" + parts[i+3]
log.Infof("Found volume name: %s", volName)
}
} else {
log.Errorf("expected volume identifier format *-%s-%s-[volumeName]-*, got malformed identifier: %s", CSIPrefix, clusterPrefix, vol.VolumeIdentifier)
return nil, status.Error(codes.Internal, "Invalid volume identifer: "+vol.VolumeIdentifier)
}
}
}

// Locate and fetch all (multipath/regular) mounted paths using this volume
devMnt, err := gofsutil.GetMountInfoFromDevice(ctx, volName)
Expand Down

0 comments on commit 7d21235

Please sign in to comment.