Skip to content

Commit c374714

Browse files
authored
Merge pull request #1280 from k8s-infra-cherrypick-robot/cherry-pick-1235-to-release-1.9
[release-1.9] Eval symlinks for disable device call
2 parents ae33d10 + a6300ea commit c374714

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

pkg/gce-pd-csi-driver/node.go

+8-4
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ limitations under the License.
1515
package gceGCEDriver
1616

1717
import (
18+
"context"
1819
"fmt"
1920
"os"
21+
"path/filepath"
2022
"runtime"
2123

22-
"context"
23-
2424
"google.golang.org/grpc/codes"
2525
"google.golang.org/grpc/status"
2626

@@ -375,8 +375,12 @@ func (ns *GCENodeServer) NodeUnstageVolume(ctx context.Context, req *csi.NodeUns
375375
devicePath, err := getDevicePath(ns, volumeID, "" /* partition, which is unused */)
376376
if err != nil {
377377
klog.Errorf("Failed to find device path for volume %s. Device may not be detached cleanly (error is ignored and unstaging is continuing): %v", volumeID, err.Error())
378-
} else if err := ns.DeviceUtils.DisableDevice(devicePath); err != nil {
379-
klog.Errorf("Failed to disabled device %s for volume %s. Device may not be detached cleanly (error is ignored and unstaging is continuing): %v", devicePath, volumeID, err.Error())
378+
} else {
379+
if devFsPath, err := filepath.EvalSymlinks(devicePath); err != nil {
380+
klog.Errorf("filepath.EvalSymlinks(%q) failed when trying to disable device: %w (ignored, unstaging continues)", devicePath, err)
381+
} else if err := ns.DeviceUtils.DisableDevice(devFsPath); err != nil {
382+
klog.Errorf("Failed to disabled device %s (aka %s) for volume %s. Device may not be detached cleanly (error is ignored and unstaging is continuing): %w", devicePath, devFsPath, volumeID, err)
383+
}
380384
}
381385

382386
klog.V(4).Infof("NodeUnstageVolume succeeded on %v from %s", volumeID, stagingTargetPath)

0 commit comments

Comments
 (0)