linstor: disconnect-disk also search for resource name in Linstor (#9035)

disconnectPhysicalDisk(String, KVMStoragePool) seems to calls the plugin
with the resource name instead of the device path, so we also have
to search for resource names, while cleaning up.
This commit is contained in:
Rene Peinthor 2024-05-06 09:05:31 +02:00 committed by GitHub
parent 5c9d79e3fb
commit ea11128cb3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -341,7 +341,7 @@ public class LinstorStorageAdaptor implements StorageAdaptor {
null, null,
null); null);
optRsc = getResourceByPath(resources, volumePath); optRsc = getResourceByPathOrName(resources, volumePath);
} catch (ApiException apiEx) { } catch (ApiException apiEx) {
// couldn't query linstor controller // couldn't query linstor controller
s_logger.error(apiEx.getBestMessage()); s_logger.error(apiEx.getBestMessage());
@ -401,9 +401,10 @@ public class LinstorStorageAdaptor implements StorageAdaptor {
return false; return false;
} }
private Optional<ResourceWithVolumes> getResourceByPath(final List<ResourceWithVolumes> resources, String path) { private Optional<ResourceWithVolumes> getResourceByPathOrName(
final List<ResourceWithVolumes> resources, String path) {
return resources.stream() return resources.stream()
.filter(rsc -> rsc.getVolumes().stream() .filter(rsc -> getLinstorRscName(path).equalsIgnoreCase(rsc.getName()) || rsc.getVolumes().stream()
.anyMatch(v -> path.equals(v.getDevicePath()))) .anyMatch(v -> path.equals(v.getDevicePath())))
.findFirst(); .findFirst();
} }