Skip to content

Commit

Permalink
linstor: do not use hosts in maintenance for copy operations
Browse files Browse the repository at this point in the history
  • Loading branch information
rp- committed Feb 14, 2024
1 parent 83a00ff commit 1c04d46
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,7 @@ private Optional<RemoteHostEndPoint> getLinstorEP(DevelopersApi api, String rscN
Host host = null;
for (String nodeName : linstorNodeNames) {
host = _hostDao.findByName(nodeName);
if (host != null) {
if (host != null && !host.isInMaintenanceStates()) {
s_logger.info(String.format("Linstor: Make resource %s available on node %s ...", rscName, nodeName));
ApiCallRcList answers = api.resourceMakeAvailableOnNode(rscName, nodeName, new ResourceMakeAvailable());
if (!answers.hasError()) {
Expand All @@ -892,21 +892,16 @@ private Optional<RemoteHostEndPoint> getLinstorEP(DevelopersApi api, String rscN
}

private Optional<RemoteHostEndPoint> getDiskfullEP(DevelopersApi api, String rscName) throws ApiException {
com.linbit.linstor.api.model.StoragePool linSP =
LinstorUtil.getDiskfulStoragePool(api, rscName);
if (linSP != null)
{
Host host = _hostDao.findByName(linSP.getNodeName());
if (host == null)
{
s_logger.error("Linstor: Host '" + linSP.getNodeName() + "' not found.");
return Optional.empty();
}
else
{
return Optional.of(RemoteHostEndPoint.getHypervisorHostEndPoint(host));
List<com.linbit.linstor.api.model.StoragePool> linSPs = LinstorUtil.getDiskfulStoragePools(api, rscName);
if (linSPs != null) {
for (com.linbit.linstor.api.model.StoragePool sp : linSPs) {
Host host = _hostDao.findByName(sp.getNodeName());
if (host != null && !host.isInMaintenanceStates()) {
return Optional.of(RemoteHostEndPoint.getHypervisorHostEndPoint(host));
}
}
}
s_logger.error("Linstor: No diskfull host found.");
return Optional.empty();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,16 @@ public static List<String> getLinstorNodeNames(@Nonnull DevelopersApi api) throw
return nodes.stream().map(Node::getName).collect(Collectors.toList());
}

public static com.linbit.linstor.api.model.StoragePool
getDiskfulStoragePool(@Nonnull DevelopersApi api, @Nonnull String rscName) throws ApiException
public static List<com.linbit.linstor.api.model.StoragePool>
getDiskfulStoragePools(@Nonnull DevelopersApi api, @Nonnull String rscName) throws ApiException
{
List<ResourceWithVolumes> resources = api.viewResources(
Collections.emptyList(),
Collections.singletonList(rscName),
Collections.emptyList(),
Collections.emptyList(),
null,
null);
Collections.emptyList(),
Collections.singletonList(rscName),
Collections.emptyList(),
Collections.emptyList(),
null,
null);

String nodeName = null;
String storagePoolName = null;
Expand All @@ -107,13 +107,23 @@ public static List<String> getLinstorNodeNames(@Nonnull DevelopersApi api) throw
}

List<com.linbit.linstor.api.model.StoragePool> sps = api.viewStoragePools(
Collections.singletonList(nodeName),
Collections.singletonList(storagePoolName),
Collections.emptyList(),
null,
null
Collections.singletonList(nodeName),
Collections.singletonList(storagePoolName),
Collections.emptyList(),
null,
null
);
return !sps.isEmpty() ? sps.get(0) : null;
return sps != null ? sps : Collections.emptyList();
}

public static com.linbit.linstor.api.model.StoragePool
getDiskfulStoragePool(@Nonnull DevelopersApi api, @Nonnull String rscName) throws ApiException
{
List<com.linbit.linstor.api.model.StoragePool> sps = getDiskfulStoragePools(api, rscName);
if (sps != null) {
return !sps.isEmpty() ? sps.get(0) : null;
}
return null;
}

public static String getSnapshotPath(com.linbit.linstor.api.model.StoragePool sp, String rscName, String snapshotName) {
Expand Down

0 comments on commit 1c04d46

Please sign in to comment.