Skip to content

Commit 1b39ef6

Browse files
committed
linstor: Do not pretend handling disconnect paths that are non Linstor (apache#8897)
1 parent 1096574 commit 1b39ef6

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;
@@ -293,7 +294,7 @@ public boolean connectPhysicalDisk(String volumePath, KVMStoragePool pool, Map<S
293294
public boolean disconnectPhysicalDisk(String volumePath, KVMStoragePool pool)
294295
{
295296
s_logger.debug("Linstor: disconnectPhysicalDisk " + pool.getUuid() + ":" + volumePath);
296-
return true;
297+
return false;
297298
}
298299

299300
@Override
@@ -329,40 +330,44 @@ public boolean disconnectPhysicalDiskByPath(String localPath)
329330
s_logger.debug("Linstor: Using storpool: " + pool.getUuid());
330331
final DevelopersApi api = getLinstorAPI(pool);
331332

332-
try
333-
{
333+
Optional<ResourceWithVolumes> optRsc;
334+
try {
334335
List<ResourceWithVolumes> resources = api.viewResources(
335-
Collections.singletonList(localNodeName),
336-
null,
337-
null,
338-
null,
339-
null,
340-
null);
341-
342-
Optional<ResourceWithVolumes> rsc = getResourceByPath(resources, localPath);
336+
Collections.singletonList(localNodeName),
337+
null,
338+
null,
339+
null,
340+
null,
341+
null);
342+
343+
optRsc = getResourceByPath(resources, localPath);
344+
} catch (ApiException apiEx) {
345+
// couldn't query linstor controller
346+
s_logger.error(apiEx.getBestMessage());
347+
return false;
348+
}
343349

344-
if (rsc.isPresent())
345-
{
350+
if (optRsc.isPresent()) {
351+
try {
352+
Resource rsc = optRsc.get();
346353
ResourceDefinitionModify rdm = new ResourceDefinitionModify();
347354
rdm.deleteProps(Collections.singletonList("DrbdOptions/Net/allow-two-primaries"));
348-
ApiCallRcList answers = api.resourceDefinitionModify(rsc.get().getName(), rdm);
349-
if (answers.hasError())
350-
{
355+
ApiCallRcList answers = api.resourceDefinitionModify(rsc.getName(), rdm);
356+
if (answers.hasError()) {
351357
s_logger.error(
352358
String.format("Failed to remove 'allow-two-primaries' on %s: %s",
353-
rsc.get().getName(), LinstorUtil.getBestErrorMessage(answers)));
359+
rsc.getName(), LinstorUtil.getBestErrorMessage(answers)));
354360
// do not fail here as removing allow-two-primaries property isn't fatal
355361
}
356-
357-
return true;
362+
} catch(ApiException apiEx){
363+
s_logger.error(apiEx.getBestMessage());
364+
// do not fail here as removing allow-two-primaries property isn't fatal
358365
}
359-
s_logger.warn("Linstor: Couldn't find resource for this path: " + localPath);
360-
} catch (ApiException apiEx) {
361-
s_logger.error(apiEx.getBestMessage());
362-
// do not fail here as removing allow-two-primaries property isn't fatal
366+
return true;
363367
}
364368
}
365-
return true;
369+
s_logger.info("Linstor: Couldn't find resource for this path: " + localPath);
370+
return false;
366371
}
367372

368373
@Override

0 commit comments

Comments
 (0)