Skip to content

Commit 1b6ee7a

Browse files
committed
Remove unused DisableDevice
1 parent 17e261e commit 1b6ee7a

File tree

3 files changed

+3
-19
lines changed

3 files changed

+3
-19
lines changed

pkg/deviceutils/device-utils.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,6 @@ type DeviceUtils interface {
8686
// exists on the machine, or an empty string if none exists
8787
VerifyDevicePath(devicePaths []string, deviceName string) (string, error)
8888

89-
// DisableDevice performs necessary disabling prior to a device being
90-
// detached from a node. The path is that from GetDiskByIdPaths.
91-
DisableDevice(devicePath string) error
92-
9389
// Resize returns whether or not a device needs resizing.
9490
Resize(resizer resizefs.Resizefs, devicePath string, deviceMountPath string) (bool, error)
9591

pkg/deviceutils/device-utils_linux.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,6 @@ import (
2424
"k8s.io/mount-utils"
2525
)
2626

27-
// DisableDevice asks the kernel to disable a device via /sys.
28-
// NB: this can be dangerous to use. Once a device is disabled, it's unusable, and can't be enabled
29-
// unless the serial number is known. But the serial number cannot be read from the device as it's
30-
// disabled. If a device is disabled in NodeUnstage, and then NodeStage is called without a
31-
// NodeUnpublish & publish sequence, the disabled state of the device will cause NodeStage to fail.
32-
// So this can only be used if we track the serial numbers of disabled devices in a persisent way
33-
// that survives driver restarts.
34-
func (_ *deviceUtils) DisableDevice(devicePath string) error {
35-
deviceName := filepath.Base(devicePath)
36-
return os.WriteFile(fmt.Sprintf("/sys/block/%s/device/state", deviceName), []byte("offline\n"), 0644)
37-
}
38-
3927
func (_ *deviceUtils) IsDeviceFilesystemInUse(mounter *mount.SafeFormatAndMount, devicePath, devFsPath string) (bool, error) {
4028
fstype, err := mounter.GetDiskFormat(devicePath)
4129
if err != nil {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -451,10 +451,10 @@ func (ns *GCENodeServer) NodeUnstageVolume(ctx context.Context, req *csi.NodeUns
451451
return nil, status.Error(codes.Internal, fmt.Sprintf("NodeUnstageVolume failed: %v\nUnmounting arguments: %s\n", err.Error(), stagingTargetPath))
452452
}
453453

454-
if err := ns.safelyDisableDevice(volumeID); err != nil {
454+
if err := ns.confirmDeviceUnused(volumeID); err != nil {
455455
var targetErr *ignoreableError
456456
if errors.As(err, &targetErr) {
457-
klog.Warningf("Device may not be detached cleanly for volume %s (ignored, unstaging continues): %v", volumeID, err)
457+
klog.Warningf("Unabled to check if device for %s is unused. Device has been unmounted successfully. Ignoring and continuing with unstaging. (%v)", volumeID, err)
458458
} else {
459459
return nil, status.Errorf(codes.Internal, "NodeUnstageVolume for volume %s failed: %v", volumeID, err)
460460
}
@@ -467,7 +467,7 @@ func (ns *GCENodeServer) NodeUnstageVolume(ctx context.Context, req *csi.NodeUns
467467
// A private error wrapper used to pass control flow decisions up to the caller
468468
type ignoreableError struct{ error }
469469

470-
func (ns *GCENodeServer) safelyDisableDevice(volumeID string) error {
470+
func (ns *GCENodeServer) confirmDeviceUnused(volumeID string) error {
471471
devicePath, err := getDevicePath(ns, volumeID, "" /* partition, which is unused */)
472472
if err != nil {
473473
return &ignoreableError{fmt.Errorf("failed to find device path for volume %s: %v", volumeID, err.Error())}

0 commit comments

Comments
 (0)