Skip to content

Commit 401990f

Browse files
authored
Fix CSI unstage for Solidfire volumes
1 parent 60981e5 commit 401990f

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

frontend/csi/node_server.go

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1956,19 +1956,26 @@ func (p *Plugin) updateChapInfoFromController(
19561956
func (p *Plugin) nodeUnstageISCSIVolume(
19571957
ctx context.Context, req *csi.NodeUnstageVolumeRequest, publishInfo *models.VolumePublishInfo, force bool,
19581958
) error {
1959-
// Derive the device path using the LunSerial. The publishInfo.DevicePath may be incorrect due to Kernel actions.
1960-
// Fallback to using the publishInfo.DevicePath if the multipath device cannot be derived.
1961-
multipathDevice, err := p.devices.GetMultipathDeviceBySerial(ctx, hex.EncodeToString([]byte(publishInfo.IscsiLunSerial)))
1962-
if err != nil {
1963-
Logc(ctx).WithError(err).WithField("LunSerial", publishInfo.IscsiLunSerial).Debug(
1964-
"Error finding multipath device by serial.")
1965-
} else {
1966-
Logc(ctx).WithFields(LogFields{
1967-
"multipathDevice": multipathDevice,
1968-
"LunSerial": publishInfo.IscsiLunSerial,
1969-
}).Debug("Found multipath device by serial.")
1970-
publishInfo.DevicePath = iscsi.DevPrefix + multipathDevice
1959+
// Default the device path to the value in the tracking file.
1960+
devicePath := publishInfo.DevicePath
1961+
1962+
// For some iSCSI backends, Trident cannot rely on the LUN serial.
1963+
if publishInfo.IscsiLunSerial != "" {
1964+
// Derive the device path using the LunSerial. The publishInfo.DevicePath may be incorrect due to Kernel actions.
1965+
// Fallback to using the publishInfo.DevicePath if the multipath device cannot be derived.
1966+
multipathDevice, err := p.devices.GetMultipathDeviceBySerial(ctx, hex.EncodeToString([]byte(publishInfo.IscsiLunSerial)))
1967+
if err != nil {
1968+
Logc(ctx).WithError(err).WithField("LunSerial", publishInfo.IscsiLunSerial).Debug(
1969+
"Error finding multipath device by serial.")
1970+
} else {
1971+
Logc(ctx).WithFields(LogFields{
1972+
"multipathDevice": multipathDevice,
1973+
"LunSerial": publishInfo.IscsiLunSerial,
1974+
}).Debug("Found multipath device by serial.")
1975+
devicePath = iscsi.DevPrefix + multipathDevice
1976+
}
19711977
}
1978+
publishInfo.DevicePath = devicePath
19721979

19731980
hostSessionMap := iscsiUtils.GetISCSIHostSessionMapForTarget(ctx, publishInfo.IscsiTargetIQN)
19741981
// TODO: (jharrod) This is a temporary fix to handle the case where the hostSessionMap is empty. We need to

0 commit comments

Comments
 (0)