From 47620a8cb4ad16c40fd435bd22d2fad1abe1cab7 Mon Sep 17 00:00:00 2001 From: Rene Peinthor Date: Mon, 6 May 2024 09:05:31 +0200 Subject: [PATCH] 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. --- .../hypervisor/kvm/storage/LinstorStorageAdaptor.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/plugins/storage/volume/linstor/src/main/java/com/cloud/hypervisor/kvm/storage/LinstorStorageAdaptor.java b/plugins/storage/volume/linstor/src/main/java/com/cloud/hypervisor/kvm/storage/LinstorStorageAdaptor.java index b38ab382a42d..632b92c80fd3 100644 --- a/plugins/storage/volume/linstor/src/main/java/com/cloud/hypervisor/kvm/storage/LinstorStorageAdaptor.java +++ b/plugins/storage/volume/linstor/src/main/java/com/cloud/hypervisor/kvm/storage/LinstorStorageAdaptor.java @@ -341,7 +341,7 @@ private boolean tryDisconnectLinstor(String volumePath, KVMStoragePool pool) null, null); - optRsc = getResourceByPath(resources, volumePath); + optRsc = getResourceByPathOrName(resources, volumePath); } catch (ApiException apiEx) { // couldn't query linstor controller s_logger.error(apiEx.getBestMessage()); @@ -401,9 +401,10 @@ public boolean disconnectPhysicalDisk(Map volumeToDisconnect) return false; } - private Optional getResourceByPath(final List resources, String path) { + private Optional getResourceByPathOrName( + final List resources, String path) { return resources.stream() - .filter(rsc -> rsc.getVolumes().stream() + .filter(rsc -> getLinstorRscName(path).equalsIgnoreCase(rsc.getName()) || rsc.getVolumes().stream() .anyMatch(v -> path.equals(v.getDevicePath()))) .findFirst(); }