From 6cd5c6a1d01966e6da2750db8e23093d1408b910 Mon Sep 17 00:00:00 2001 From: Rene Peinthor Date: Fri, 12 Apr 2024 13:23:15 +0200 Subject: [PATCH] linstor: Do not pretend handling disconnect paths that are non Linstor (#8897) --- .../kvm/storage/LinstorStorageAdaptor.java | 51 ++++++++++--------- 1 file changed, 28 insertions(+), 23 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 87746447188..9ad8332d0e1 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 @@ -45,6 +45,7 @@ import com.linbit.linstor.api.model.ApiCallRc; import com.linbit.linstor.api.model.ApiCallRcList; import com.linbit.linstor.api.model.Properties; import com.linbit.linstor.api.model.ProviderKind; +import com.linbit.linstor.api.model.Resource; import com.linbit.linstor.api.model.ResourceDefinition; import com.linbit.linstor.api.model.ResourceDefinitionModify; import com.linbit.linstor.api.model.ResourceGroup; @@ -306,7 +307,7 @@ public class LinstorStorageAdaptor implements StorageAdaptor { public boolean disconnectPhysicalDisk(String volumePath, KVMStoragePool pool) { s_logger.debug("Linstor: disconnectPhysicalDisk " + pool.getUuid() + ":" + volumePath); - return true; + return false; } @Override @@ -342,40 +343,44 @@ public class LinstorStorageAdaptor implements StorageAdaptor { s_logger.debug("Linstor: Using storpool: " + pool.getUuid()); final DevelopersApi api = getLinstorAPI(pool); - try - { + Optional optRsc; + try { List resources = api.viewResources( - Collections.singletonList(localNodeName), - null, - null, - null, - null, - null); + Collections.singletonList(localNodeName), + null, + null, + null, + null, + null); - Optional rsc = getResourceByPath(resources, localPath); + optRsc = getResourceByPath(resources, localPath); + } catch (ApiException apiEx) { + // couldn't query linstor controller + s_logger.error(apiEx.getBestMessage()); + return false; + } - if (rsc.isPresent()) - { + if (optRsc.isPresent()) { + try { + Resource rsc = optRsc.get(); ResourceDefinitionModify rdm = new ResourceDefinitionModify(); rdm.deleteProps(Collections.singletonList("DrbdOptions/Net/allow-two-primaries")); - ApiCallRcList answers = api.resourceDefinitionModify(rsc.get().getName(), rdm); - if (answers.hasError()) - { + ApiCallRcList answers = api.resourceDefinitionModify(rsc.getName(), rdm); + if (answers.hasError()) { s_logger.error( String.format("Failed to remove 'allow-two-primaries' on %s: %s", - rsc.get().getName(), LinstorUtil.getBestErrorMessage(answers))); + rsc.getName(), LinstorUtil.getBestErrorMessage(answers))); // do not fail here as removing allow-two-primaries property isn't fatal } - - return true; + } catch(ApiException apiEx){ + s_logger.error(apiEx.getBestMessage()); + // do not fail here as removing allow-two-primaries property isn't fatal } - s_logger.warn("Linstor: Couldn't find resource for this path: " + localPath); - } catch (ApiException apiEx) { - s_logger.error(apiEx.getBestMessage()); - // do not fail here as removing allow-two-primaries property isn't fatal + return true; } } - return true; + s_logger.info("Linstor: Couldn't find resource for this path: " + localPath); + return false; } @Override