Skip to content

Remove device disable call #1689

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion pkg/deviceutils/device-utils_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,16 @@ import (
"k8s.io/mount-utils"
)

// DisableDevice asks the kernel to disable a device via /sys.
// NB: this can be dangerous to use. Once a device is disabled, it's unusable, and can't be enabled
// unless the serial number is known. But the serial number cannot be read from the device as it's
// disabled. If a device is disabled in NodeUnstage, and then NodeStage is called without a
// NodeUnpublish & publish sequence, the disabled state of the device will cause NodeStage to fail.
// So this can only be used if we track the serial numbers of disabled devices in a persisent way
// that survives driver restarts.
func (_ *deviceUtils) DisableDevice(devicePath string) error {
deviceName := filepath.Base(devicePath)
return os.WriteFile(fmt.Sprintf("/sys/block/%s/device/state", deviceName), []byte("offline"), 0644)
return os.WriteFile(fmt.Sprintf("/sys/block/%s/device/state", deviceName), []byte("offline\n"), 0644)
}

func (_ *deviceUtils) IsDeviceFilesystemInUse(mounter *mount.SafeFormatAndMount, devicePath, devFsPath string) (bool, error) {
Expand Down
4 changes: 0 additions & 4 deletions pkg/gce-pd-csi-driver/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -484,10 +484,6 @@ func (ns *GCENodeServer) safelyDisableDevice(volumeID string) error {
return fmt.Errorf("device %s (aka %s) is still in use", devicePath, devFsPath)
}

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

return nil
}

Expand Down