Skip to content

controller/blockdevice: should update DevPath once it changed (backport #195) #196

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 8, 2025
Merged
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
19 changes: 10 additions & 9 deletions pkg/controller/blockdevice/scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,17 +127,18 @@ func (s *Scanner) collectAllDevices() []*deviceWithAutoProvision {

func (s *Scanner) handleExistingDev(oldBd *diskv1.BlockDevice, newBd *diskv1.BlockDevice, autoProvisioned bool) {
if isDevPathChanged(oldBd, newBd) {
// the Dev Path changed only when the device is temporarily gone and back.
if oldBd.Status.State != diskv1.BlockDeviceInactive {
logrus.Warnf("Device Path should not change with the active device %s, new device path: %s", newBd.Name, newBd.Status.DeviceStatus.DevPath)
} else {
// Dev Path will change when device is temporarily gone and back.
// Node reboot might also cause the device path change (depends on device interrupt).
// According to the above, we should update the device path once it changes.
if oldBd.Status.State == diskv1.BlockDeviceInactive {
logrus.Infof("The inactive block device %s with wwn %s is coming back", newBd.Name, newBd.Status.DeviceStatus.Details.WWN)
oldBd.Status.State = diskv1.BlockDeviceActive
oldBd.Status.DeviceStatus.DevPath = newBd.Status.DeviceStatus.DevPath
if _, err := s.Blockdevices.Update(oldBd); err != nil {
logrus.Errorf("Update device %s status error", oldBd.Name)
s.Blockdevices.Enqueue(s.Namespace, newBd.Name)
}
}
logrus.Infof("Try to update the device path of %s, which is changed from %s to %s.", oldBd.Name, oldBd.Status.DeviceStatus.DevPath, newBd.Status.DeviceStatus.DevPath)
oldBd.Status.DeviceStatus.DevPath = newBd.Status.DeviceStatus.DevPath
if _, err := s.Blockdevices.Update(oldBd); err != nil {
logrus.Errorf("Update device %s status error, wake up scanner again: %v", oldBd.Name, err)
s.Cond.Signal()
}
} else if isDevAlreadyProvisioned(newBd) {
logrus.Debugf("Skip the provisioned device: %s", newBd.Name)
Expand Down