diff --git a/CHANGELOG.md b/CHANGELOG.md index 98c860d1e..e4358d5e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Snapshots now cannot be created while SkipDisk is active - Autoplacer: Added very small default weight for the MinResourceCount-strategy for better tiebreaker-distribution - Added some more info logging and improved an error message +- BalanceResourceTask: Do not count skipDisk resources as diskful ### Fixed diff --git a/controller/src/main/java/com/linbit/linstor/core/apicallhandler/controller/CtrlRscAutoPlaceApiCallHandler.java b/controller/src/main/java/com/linbit/linstor/core/apicallhandler/controller/CtrlRscAutoPlaceApiCallHandler.java index 370ae9dbb..7c783afa1 100644 --- a/controller/src/main/java/com/linbit/linstor/core/apicallhandler/controller/CtrlRscAutoPlaceApiCallHandler.java +++ b/controller/src/main/java/com/linbit/linstor/core/apicallhandler/controller/CtrlRscAutoPlaceApiCallHandler.java @@ -40,6 +40,7 @@ import com.linbit.locks.LockGuardFactory.LockObj; import com.linbit.locks.LockGuardFactory.LockType; import com.linbit.utils.Pair; +import com.linbit.utils.StringUtils; import javax.annotation.Nullable; import javax.inject.Inject; @@ -185,7 +186,8 @@ Flux autoPlaceInTransaction( // we do not care about deleting / evicted resources. just make sure to not count them if ( !isSomeFlagSet(rsc, Resource.Flags.DELETE, Resource.Flags.EVICTED, Resource.Flags.EVACUATE) && - !isNodeFlagSet(rsc, Node.Flags.EVACUATE) + !isNodeFlagSet(rsc, Node.Flags.EVACUATE) && + !hasSkipDiskProp(rsc) ) { if (isFlagSet(rsc, Resource.Flags.DISKLESS)) @@ -601,6 +603,25 @@ private boolean isFlagSet(Resource rsc, Resource.Flags... flags) return flagSet; } + + private boolean hasSkipDiskProp(Resource rsc) + { + try + { + String skipDiskProp = rsc.getProps(peerAccCtx.get()).getProp( + ApiConsts.KEY_DRBD_SKIP_DISK, ApiConsts.NAMESPC_DRBD_OPTIONS); + return StringUtils.propTrueOrYes(skipDiskProp); + } + catch (AccessDeniedException accDeniedExc) + { + throw new ApiAccessDeniedException( + accDeniedExc, + "access " + CtrlRscApiCallHandler.getRscDescriptionInline(rsc), + ApiConsts.FAIL_ACC_DENIED_RSC + ); + } + } + private boolean isSomeFlagSet(Resource rsc, Resource.Flags... flags) { boolean flagSet = false; diff --git a/controller/src/main/java/com/linbit/linstor/core/apicallhandler/controller/autoplacer/BalanceResources.java b/controller/src/main/java/com/linbit/linstor/core/apicallhandler/controller/autoplacer/BalanceResources.java index 8a9babc42..c251aaaa4 100644 --- a/controller/src/main/java/com/linbit/linstor/core/apicallhandler/controller/autoplacer/BalanceResources.java +++ b/controller/src/main/java/com/linbit/linstor/core/apicallhandler/controller/autoplacer/BalanceResources.java @@ -32,6 +32,7 @@ import com.linbit.locks.LockGuard; import com.linbit.locks.LockGuardFactory; import com.linbit.utils.Pair; +import com.linbit.utils.StringUtils; import static com.linbit.locks.LockGuardFactory.LockObj.RSC_DFN_MAP; import static com.linbit.locks.LockGuardFactory.LockType.WRITE; @@ -292,7 +293,28 @@ private boolean isRscDfnDisabled(ResourceDefinition rscDfn) throws AccessDeniedE } /** - * Loops through all resource definitions and tries to fullfill the linked resource groups place counts. + * Filter resources that should really considered as UpToDate diskfull resources. + * + * @param resources + * @throws AccessDeniedException should not we use sysctx + */ + private void filterDiskfull(List resources) throws AccessDeniedException + { + List toRemove = new ArrayList<>(); + for(var res : resources) + { + String skipDiskProp = res.getProps(sysCtx).getProp( + ApiConsts.KEY_DRBD_SKIP_DISK, ApiConsts.NAMESPC_DRBD_OPTIONS); + if (StringUtils.propTrueOrYes(skipDiskProp)) + { + toRemove.add(res); + } + } + resources.removeAll(toRemove); + } + + /** + * Loops through all resource definitions and tries to fulfill the linked resource groups place counts. * @param timeoutSecs Timeout in seconds of the adjust and delete flux * @return a Pair with numberAdjusted, deletedResources */ @@ -325,6 +347,7 @@ public Pair balanceResources(long timeoutSecs) if (replicaCount != null) { List notDeletedDiskful = rscDfn.getNotDeletedDiskful(sysCtx); + filterDiskfull(notDeletedDiskful); int notDeletedDiskfulCount = notDeletedDiskful.size(); if (notDeletedDiskfulCount < replicaCount) {