Skip to content

Commit a55ba96

Browse files
committed
Merge remote-tracking branch 'origin/4.18' into 4.19
2 parents 0a26f33 + 6cd5c6a commit a55ba96

1 file changed

Lines changed: 29 additions & 24 deletions

File tree

plugins/storage/volume/linstor/src/main/java/com/cloud/hypervisor/kvm/storage/LinstorStorageAdaptor.java

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import com.linbit.linstor.api.model.ApiCallRcList;
4242
import com.linbit.linstor.api.model.Properties;
4343
import com.linbit.linstor.api.model.ProviderKind;
44+
import com.linbit.linstor.api.model.Resource;
4445
import com.linbit.linstor.api.model.ResourceDefinition;
4546
import com.linbit.linstor.api.model.ResourceDefinitionModify;
4647
import com.linbit.linstor.api.model.ResourceGroupSpawn;
@@ -281,7 +282,7 @@ public boolean connectPhysicalDisk(String volumePath, KVMStoragePool pool, Map<S
281282
public boolean disconnectPhysicalDisk(String volumePath, KVMStoragePool pool)
282283
{
283284
s_logger.debug("Linstor: disconnectPhysicalDisk " + pool.getUuid() + ":" + volumePath);
284-
return true;
285+
return false;
285286
}
286287

287288
@Override
@@ -317,40 +318,44 @@ public boolean disconnectPhysicalDiskByPath(String localPath)
317318
s_logger.debug("Linstor: Using storpool: " + pool.getUuid());
318319
final DevelopersApi api = getLinstorAPI(pool);
319320

320-
try
321-
{
321+
Optional<ResourceWithVolumes> optRsc;
322+
try {
322323
List<ResourceWithVolumes> resources = api.viewResources(
323-
Collections.singletonList(localNodeName),
324-
null,
325-
null,
326-
null,
327-
null,
328-
null);
329-
330-
Optional<ResourceWithVolumes> rsc = getResourceByPath(resources, localPath);
324+
Collections.singletonList(localNodeName),
325+
null,
326+
null,
327+
null,
328+
null,
329+
null);
330+
331+
optRsc = getResourceByPath(resources, localPath);
332+
} catch (ApiException apiEx) {
333+
// couldn't query linstor controller
334+
s_logger.error(apiEx.getBestMessage());
335+
return false;
336+
}
331337

332-
if (rsc.isPresent())
333-
{
338+
if (optRsc.isPresent()) {
339+
try {
340+
Resource rsc = optRsc.get();
334341
ResourceDefinitionModify rdm = new ResourceDefinitionModify();
335342
rdm.deleteProps(Collections.singletonList("DrbdOptions/Net/allow-two-primaries"));
336-
ApiCallRcList answers = api.resourceDefinitionModify(rsc.get().getName(), rdm);
337-
if (answers.hasError())
338-
{
343+
ApiCallRcList answers = api.resourceDefinitionModify(rsc.getName(), rdm);
344+
if (answers.hasError()) {
339345
s_logger.error(
340346
String.format("Failed to remove 'allow-two-primaries' on %s: %s",
341-
rsc.get().getName(), LinstorUtil.getBestErrorMessage(answers)));
347+
rsc.getName(), LinstorUtil.getBestErrorMessage(answers)));
342348
// do not fail here as removing allow-two-primaries property isn't fatal
343349
}
344-
345-
return true;
350+
} catch(ApiException apiEx){
351+
s_logger.error(apiEx.getBestMessage());
352+
// do not fail here as removing allow-two-primaries property isn't fatal
346353
}
347-
s_logger.warn("Linstor: Couldn't find resource for this path: " + localPath);
348-
} catch (ApiException apiEx) {
349-
s_logger.error(apiEx.getBestMessage());
350-
// do not fail here as removing allow-two-primaries property isn't fatal
354+
return true;
351355
}
352356
}
353-
return true;
357+
s_logger.info("Linstor: Couldn't find resource for this path: " + localPath);
358+
return false;
354359
}
355360

356361
@Override

0 commit comments

Comments
 (0)