Skip to content

Commit 17e261e

Browse files
authored
Merge pull request #1689 from mattcary/disable
Remove device disable call
2 parents 9cb6caf + 52d3ebb commit 17e261e

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

pkg/deviceutils/device-utils_linux.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,16 @@ 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.
2734
func (_ *deviceUtils) DisableDevice(devicePath string) error {
2835
deviceName := filepath.Base(devicePath)
29-
return os.WriteFile(fmt.Sprintf("/sys/block/%s/device/state", deviceName), []byte("offline"), 0644)
36+
return os.WriteFile(fmt.Sprintf("/sys/block/%s/device/state", deviceName), []byte("offline\n"), 0644)
3037
}
3138

3239
func (_ *deviceUtils) IsDeviceFilesystemInUse(mounter *mount.SafeFormatAndMount, devicePath, devFsPath string) (bool, error) {

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

-4
Original file line numberDiff line numberDiff line change
@@ -484,10 +484,6 @@ func (ns *GCENodeServer) safelyDisableDevice(volumeID string) error {
484484
return fmt.Errorf("device %s (aka %s) is still in use", devicePath, devFsPath)
485485
}
486486

487-
if err := ns.DeviceUtils.DisableDevice(devFsPath); err != nil {
488-
return &ignoreableError{fmt.Errorf("failed to disable device %s (aka %s): %v", devicePath, devFsPath, err)}
489-
}
490-
491487
return nil
492488
}
493489

0 commit comments

Comments
 (0)