Skip to content

Commit

Permalink
linstor: disconnect-disk also search for resource name in Linstor (ap…
Browse files Browse the repository at this point in the history
…ache#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.
  • Loading branch information
rp- committed May 16, 2024
1 parent b35ceae commit 47620a8
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -401,9 +401,10 @@ public boolean disconnectPhysicalDisk(Map<String, String> volumeToDisconnect)
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()
.filter(rsc -> rsc.getVolumes().stream()
.filter(rsc -> getLinstorRscName(path).equalsIgnoreCase(rsc.getName()) || rsc.getVolumes().stream()
.anyMatch(v -> path.equals(v.getDevicePath())))
.findFirst();
}
Expand Down

0 comments on commit 47620a8

Please sign in to comment.