forked from shaba/openuds
Merge remote-tracking branch 'origin/v3.5'
This commit is contained in:
commit
de71785c76
@ -39,6 +39,7 @@ from django.utils.translation import gettext as _
|
||||
from django.db.models import Q
|
||||
from django.db import transaction
|
||||
from uds.core.services.exceptions import OperationException
|
||||
from uds.core.util.config import GlobalConfig
|
||||
from uds.core.util.state import State
|
||||
from uds.core.util import log
|
||||
from uds.core.services.exceptions import (
|
||||
@ -85,7 +86,11 @@ class UserServiceManager(metaclass=singleton.Singleton):
|
||||
|
||||
@staticmethod
|
||||
def getStateFilter() -> Q:
|
||||
return Q(state__in=[State.PREPARING, State.USABLE])
|
||||
if GlobalConfig.MAX_SERVICES_COUNT_NEW.getBool() == False:
|
||||
states = [State.PREPARING, State.USABLE]
|
||||
else:
|
||||
states = [State.PREPARING, State.USABLE, State.REMOVING, State.REMOVABLE]
|
||||
return Q(state__in=states)
|
||||
|
||||
def __checkMaxDeployedReached(self, servicePool: ServicePool) -> None:
|
||||
"""
|
||||
@ -523,13 +528,11 @@ class UserServiceManager(metaclass=singleton.Singleton):
|
||||
# Can't assign directly from L2 cache... so we check if we can create e new service in the limits requested
|
||||
serviceType = servicePool.service.getType()
|
||||
if serviceType.usesCache:
|
||||
# inCacheL1 = ds.cachedUserServices().filter(UserServiceManager.getCacheStateFilter(services.UserDeployment.L1_CACHE)).count()
|
||||
inAssigned = (
|
||||
servicePool.assignedUserServices()
|
||||
.filter(UserServiceManager.getStateFilter())
|
||||
.count()
|
||||
)
|
||||
# totalL1Assigned = inCacheL1 + inAssigned
|
||||
if (
|
||||
inAssigned >= servicePool.max_srvs
|
||||
): # cacheUpdater will drop unnecesary L1 machines, so it's not neccesary to check against inCacheL1
|
||||
|
@ -428,6 +428,11 @@ class GlobalConfig:
|
||||
'Notify on new publication', '0', type=Config.BOOLEAN_FIELD
|
||||
)
|
||||
|
||||
# How "max services" is computed
|
||||
MAX_SERVICES_COUNT_NEW: Config.Value = Config.section(GLOBAL_SECTION).value(
|
||||
'New Max restriction', '0', type=Config.BOOLEAN_FIELD
|
||||
)
|
||||
|
||||
# Allowed "trusted sources" for request
|
||||
TRUSTED_SOURCES: Config.Value = Config.section(SECURITY_SECTION).value(
|
||||
'Trusted Hosts', '*', type=Config.TEXT_FIELD
|
||||
|
Loading…
x
Reference in New Issue
Block a user