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 917b7c0ed0c..3124d61f5f1 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 @@ -271,27 +271,35 @@ public class LinstorStorageAdaptor implements StorageAdaptor { } final DevelopersApi api = getLinstorAPI(pool); + String rscName; try { - final String rscName = getLinstorRscName(volumePath); + rscName = getLinstorRscName(volumePath); ResourceMakeAvailable rma = new ResourceMakeAvailable(); ApiCallRcList answers = api.resourceMakeAvailableOnNode(rscName, localNodeName, rma); checkLinstorAnswersThrow(answers); + } catch (ApiException apiEx) { + s_logger.error(apiEx); + throw new CloudRuntimeException(apiEx.getBestMessage(), apiEx); + } + + try + { // allow 2 primaries for live migration, should be removed by disconnect on the other end ResourceDefinitionModify rdm = new ResourceDefinitionModify(); Properties props = new Properties(); props.put("DrbdOptions/Net/allow-two-primaries", "yes"); rdm.setOverrideProps(props); - answers = api.resourceDefinitionModify(rscName, rdm); + ApiCallRcList answers = api.resourceDefinitionModify(rscName, rdm); if (answers.hasError()) { s_logger.error("Unable to set 'allow-two-primaries' on " + rscName); - throw new CloudRuntimeException(answers.get(0).getMessage()); + // do not fail here as adding allow-two-primaries property is only a problem while live migrating } } catch (ApiException apiEx) { s_logger.error(apiEx); - throw new CloudRuntimeException(apiEx.getBestMessage(), apiEx); + // do not fail here as adding allow-two-primaries property is only a problem while live migrating } return true; } @@ -355,19 +363,21 @@ public class LinstorStorageAdaptor implements StorageAdaptor { ApiCallRcList answers = api.resourceDefinitionModify(rsc.get().getName(), rdm); if (answers.hasError()) { - s_logger.error("Failed to remove 'allow-two-primaries' on " + rsc.get().getName()); - throw new CloudRuntimeException(answers.get(0).getMessage()); + s_logger.error( + String.format("Failed to remove 'allow-two-primaries' on %s: %s", + rsc.get().getName(), LinstorUtil.getBestErrorMessage(answers))); + // do not fail here as removing allow-two-primaries property isn't fatal } return true; } s_logger.warn("Linstor: Couldn't find resource for this path: " + localPath); } catch (ApiException apiEx) { - s_logger.error(apiEx); - throw new CloudRuntimeException(apiEx.getBestMessage(), apiEx); + s_logger.error(apiEx.getBestMessage()); + // do not fail here as removing allow-two-primaries property isn't fatal } } - return false; + return true; } @Override