Skip to content

Commit 6cd5c6a

Browse files
authored
linstor: Do not pretend handling disconnect paths that are non Linstor (#8897)
1 parent a5508ac commit 6cd5c6a

File tree

1 file changed

+29
-24
lines changed

1 file changed

+29
-24
lines changed

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

+29-24
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import com.linbit.linstor.api.model.ApiCallRcList;
4646
import com.linbit.linstor.api.model.Properties;
4747
import com.linbit.linstor.api.model.ProviderKind;
48+
import com.linbit.linstor.api.model.Resource;
4849
import com.linbit.linstor.api.model.ResourceDefinition;
4950
import com.linbit.linstor.api.model.ResourceDefinitionModify;
5051
import com.linbit.linstor.api.model.ResourceGroup;
@@ -306,7 +307,7 @@ public boolean connectPhysicalDisk(String volumePath, KVMStoragePool pool, Map<S
306307
public boolean disconnectPhysicalDisk(String volumePath, KVMStoragePool pool)
307308
{
308309
s_logger.debug("Linstor: disconnectPhysicalDisk " + pool.getUuid() + ":" + volumePath);
309-
return true;
310+
return false;
310311
}
311312

312313
@Override
@@ -342,40 +343,44 @@ public boolean disconnectPhysicalDiskByPath(String localPath)
342343
s_logger.debug("Linstor: Using storpool: " + pool.getUuid());
343344
final DevelopersApi api = getLinstorAPI(pool);
344345

345-
try
346-
{
346+
Optional<ResourceWithVolumes> optRsc;
347+
try {
347348
List<ResourceWithVolumes> resources = api.viewResources(
348-
Collections.singletonList(localNodeName),
349-
null,
350-
null,
351-
null,
352-
null,
353-
null);
354-
355-
Optional<ResourceWithVolumes> rsc = getResourceByPath(resources, localPath);
349+
Collections.singletonList(localNodeName),
350+
null,
351+
null,
352+
null,
353+
null,
354+
null);
355+
356+
optRsc = getResourceByPath(resources, localPath);
357+
} catch (ApiException apiEx) {
358+
// couldn't query linstor controller
359+
s_logger.error(apiEx.getBestMessage());
360+
return false;
361+
}
356362

357-
if (rsc.isPresent())
358-
{
363+
if (optRsc.isPresent()) {
364+
try {
365+
Resource rsc = optRsc.get();
359366
ResourceDefinitionModify rdm = new ResourceDefinitionModify();
360367
rdm.deleteProps(Collections.singletonList("DrbdOptions/Net/allow-two-primaries"));
361-
ApiCallRcList answers = api.resourceDefinitionModify(rsc.get().getName(), rdm);
362-
if (answers.hasError())
363-
{
368+
ApiCallRcList answers = api.resourceDefinitionModify(rsc.getName(), rdm);
369+
if (answers.hasError()) {
364370
s_logger.error(
365371
String.format("Failed to remove 'allow-two-primaries' on %s: %s",
366-
rsc.get().getName(), LinstorUtil.getBestErrorMessage(answers)));
372+
rsc.getName(), LinstorUtil.getBestErrorMessage(answers)));
367373
// do not fail here as removing allow-two-primaries property isn't fatal
368374
}
369-
370-
return true;
375+
} catch(ApiException apiEx){
376+
s_logger.error(apiEx.getBestMessage());
377+
// do not fail here as removing allow-two-primaries property isn't fatal
371378
}
372-
s_logger.warn("Linstor: Couldn't find resource for this path: " + localPath);
373-
} catch (ApiException apiEx) {
374-
s_logger.error(apiEx.getBestMessage());
375-
// do not fail here as removing allow-two-primaries property isn't fatal
379+
return true;
376380
}
377381
}
378-
return true;
382+
s_logger.info("Linstor: Couldn't find resource for this path: " + localPath);
383+
return false;
379384
}
380385

381386
@Override

0 commit comments

Comments
 (0)