Skip to content

Commit

Permalink
balance-rsc: Do not count skipDisk resources as diskful
Browse files Browse the repository at this point in the history
Also don't count skipDisk disks for auto-placer
  • Loading branch information
rp- committed Jul 11, 2024
1 parent e879185 commit b50b0b6
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -185,7 +186,8 @@ Flux<ApiCallRc> 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))
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<Resource> resources) throws AccessDeniedException
{
List<Resource> 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
*/
Expand Down Expand Up @@ -325,6 +347,7 @@ public Pair<Integer, Integer> balanceResources(long timeoutSecs)
if (replicaCount != null)
{
List<Resource> notDeletedDiskful = rscDfn.getNotDeletedDiskful(sysCtx);
filterDiskfull(notDeletedDiskful);
int notDeletedDiskfulCount = notDeletedDiskful.size();
if (notDeletedDiskfulCount < replicaCount)
{
Expand Down

0 comments on commit b50b0b6

Please sign in to comment.