@@ -517,13 +517,14 @@ func (driver *Driver) stageVolume(
517517 // Store mount info in the staging device
518518 stagingDevice .MountInfo = mountInfo
519519
520- // CON-3010
521- // Get the PVC details to identify the datasource of PVC
522- if volumeContext [ pvcNameAttribute ] != "" && volumeContext [ pvcNamespaceAttribute ] != "" {
523- pvc , err := driver . flavor . GetPVCByName ( volumeContext [ pvcNameAttribute ], volumeContext [ pvcNamespaceAttribute ])
520+ // Retrieve PVC spec for dataSource inspection for regular PVCs
521+ if isEphemeral ( volumeContext ) == false {
522+ pvc , err := driver . flavor . GetPVCByVolumeID ( volumeID )
523+
524524 if err != nil {
525- return nil , status .Error (codes .Internal , fmt .Sprintf ("Error getting pvc data source for volume %v, %v" , volumeID , err ))
525+ return nil , status .Error (codes .Internal , fmt .Sprintf ("Error getting PVC from volumeID %v, %v" , volumeID , err ))
526526 }
527+
527528 if pvc .Spec .DataSource != nil {
528529
529530 // If the DataSource is a VolumeSnapshot
@@ -533,31 +534,30 @@ func (driver *Driver) stageVolume(
533534 IsVolumeClone = true
534535 }
535536 }
536- }
537537
538- // Check whether volume is created from snapshot then only we need resize
539- if IsVolumeClone {
540- // Initialize resizeFs
541- r := mountutil .NewResizeFs (exec .New ())
538+ // Check whether volume is created from snapshot then only we need resize
539+ if IsVolumeClone {
540+ // Initialize resizeFs
541+ r := mountutil .NewResizeFs (exec .New ())
542542
543- log .Infof ("Verify whether resize required for device path %v " , device .AltFullPathName )
543+ log .Infof ("Verify whether resize required for device path %v " , device .AltFullPathName )
544544
545- // check whether we need resize for file system
546- needResize , err := r .NeedResize (device .AltFullPathName , stagingMountPoint )
547- if err != nil {
548- return nil , status .Errorf (codes .Internal , "Could not determine if volume %q need to be resized, error: %v" , volumeID , err )
549- }
550- log .Infof ("Need resize for filesystem: %v" , needResize )
545+ // check whether we need resize for file system
546+ needResize , err := r .NeedResize (device .AltFullPathName , stagingMountPoint )
547+ if err != nil {
548+ return nil , status .Errorf (codes .Internal , "Could not determine if volume %q need to be resized, error: %v" , volumeID , err )
549+ }
550+ log .Infof ("Need resize for filesystem: %v" , needResize )
551551
552- if needResize {
553- log .Infof ("Resize of target path %s is required " , device .AltFullPathName )
554- if _ , err := r .Resize (device .AltFullPathName , stagingMountPoint ); err != nil {
555- return nil , status .Errorf (codes .Internal , "Could not resize volume %q, error : %v" , volumeID , err )
552+ if needResize {
553+ log .Infof ("Resize of target path %s is required " , device .AltFullPathName )
554+ if _ , err := r .Resize (device .AltFullPathName , stagingMountPoint ); err != nil {
555+ return nil , status .Errorf (codes .Internal , "Could not resize volume %q, error : %v" , volumeID , err )
556+ }
557+ log .Infof ("Resize of target path %s is successful" , device .AltFullPathName )
556558 }
557- log .Infof ("Resize of target path %s is successful" , device .AltFullPathName )
558559 }
559560 }
560- // CON-3010
561561
562562 return stagingDevice , nil
563563}
0 commit comments