@@ -599,14 +599,12 @@ func mkdir(path string) (bool, error) {
599
599
// It determines this by checking to see if the volume is mounted anywhere else
600
600
// other than the private mount.
601
601
func unpublishVolume (
602
- req * csi. NodeUnpublishVolumeRequest ,
602
+ volumeID , targetPath string ,
603
603
privDir , device string , reqID string ,
604
604
) error {
605
605
ctx := context .Background ()
606
- id := req .GetVolumeId ()
607
606
608
- target := req .GetTargetPath ()
609
- if target == "" {
607
+ if targetPath == "" {
610
608
return status .Error (codes .InvalidArgument ,
611
609
"target path required" )
612
610
}
@@ -616,17 +614,17 @@ func unpublishVolume(
616
614
if err != nil {
617
615
return status .Errorf (codes .Internal ,
618
616
"error getting block device for volume: %s, err: %s" ,
619
- id , err .Error ())
617
+ volumeID , err .Error ())
620
618
}
621
619
622
620
// Path to mount device to
623
- privTgt := getPrivateMountPoint (privDir , id )
621
+ privTgt := getPrivateMountPoint (privDir , volumeID )
624
622
625
623
f := logrus.Fields {
626
624
"device" : sysDevice .RealDev ,
627
625
"privTgt" : privTgt ,
628
626
"CSIRequestID" : reqID ,
629
- "target" : target ,
627
+ "target" : targetPath ,
630
628
}
631
629
632
630
mnts , err := gofsutil .GetMounts (ctx )
@@ -644,10 +642,10 @@ func unpublishVolume(
644
642
if m .Path == privTgt {
645
643
privMntExist = true
646
644
Log .Printf ("Found private mount for device %#v, private mount path: %s ." , sysDevice , privTgt )
647
- } else if m .Path == target {
645
+ } else if m .Path == targetPath {
648
646
tgtMntExist = true
649
647
deviceMount = m
650
- Log .Printf ("Found target mount for device %#v, target mount path: %s ." , sysDevice , target )
648
+ Log .Printf ("Found target mount for device %#v, target mount path: %s ." , sysDevice , targetPath )
651
649
}
652
650
}
653
651
}
@@ -656,12 +654,12 @@ func unpublishVolume(
656
654
}
657
655
658
656
if tgtMntExist {
659
- Log .WithFields (f ).Debug (fmt .Sprintf ("Unmounting %s" , target ))
660
- if err := gofsutil .Unmount (ctx , target ); err != nil {
657
+ Log .WithFields (f ).Debug (fmt .Sprintf ("Unmounting %s" , targetPath ))
658
+ if err := gofsutil .Unmount (ctx , targetPath ); err != nil {
661
659
return status .Errorf (codes .Internal ,
662
660
"Error unmounting target: %s" , err .Error ())
663
661
}
664
- if err := removeWithRetry (target ); err != nil {
662
+ if err := removeWithRetry (targetPath ); err != nil {
665
663
return status .Errorf (codes .Internal ,
666
664
"Error remove target folder: %s" , err .Error ())
667
665
}
0 commit comments