1
0
mirror of https://github.com/dkmstr/openuds.git synced 2025-01-06 13:17:54 +03:00

Fixed background "cleaners"

This commit is contained in:
Adolfo Gómez García 2020-07-02 15:39:14 +02:00
parent 19edf417ba
commit 31ee1d2858
5 changed files with 6 additions and 5 deletions

View File

@ -66,7 +66,7 @@ class AssignedService(DetailHandler):
'id_deployed_service': item.deployed_service.uuid, 'id_deployed_service': item.deployed_service.uuid,
'unique_id': item.unique_id, 'unique_id': item.unique_id,
'friendly_name': item.friendly_name, 'friendly_name': item.friendly_name,
'state': item.state if not props.get('destroy_after') else State.CANCELING, 'state': item.state if not (props.get('destroy_after') and item.state == State.PREPARING) else State.CANCELING,
'os_state': item.os_state, 'os_state': item.os_state,
'state_date': item.state_date, 'state_date': item.state_date,
'creation_date': item.creation_date, 'creation_date': item.creation_date,

View File

@ -60,7 +60,7 @@ class HangedCleaner(Job):
hanged = Count( hanged = Count(
'userServices', 'userServices',
filter=Q(userServices__state_date__lt=since_state, userServices__state=State.PREPARING) | filter=Q(userServices__state_date__lt=since_state, userServices__state=State.PREPARING) |
Q(userServices__state_date__lt=since_state, state=State.USABLE, userServices__os_state=State.PREPARING) Q(userServices__state_date__lt=since_state, userServices__state=State.USABLE, userServices__os_state=State.PREPARING)
) )
).exclude(hanged=0).exclude(osmanager=None).exclude(service__provider__maintenance_mode=True).filter(state=State.ACTIVE) ).exclude(hanged=0).exclude(osmanager=None).exclude(service__provider__maintenance_mode=True).filter(state=State.ACTIVE)

View File

@ -43,15 +43,14 @@ from uds.core.util import log
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
MAX_STUCK_TIME = 3600 * 24 * 2 # At most 2 days "Stuck", not configurable (there is no need to) MAX_STUCK_TIME = 3600 * 24 # At most 1 days "Stuck", not configurable (there is no need to)
class StuckCleaner(Job): class StuckCleaner(Job):
""" """
Kaputen Cleaner is very similar to Hanged Cleaner Kaputen Cleaner is very similar to Hanged Cleaner
We keep it in a new place to "control" more specific thins We keep it in a new place to "control" more specific thins
""" """
frecuency = 3600 * 24 # Executes Once a day frecuency = 3601 * 8 # Executes Once a day
friendly_name = 'Stuck States cleaner' friendly_name = 'Stuck States cleaner'
def run(self): def run(self):

View File

@ -231,6 +231,7 @@ class LinuxOsManager(osmanagers.OSManager):
This function can update userService values. Normal operation will be remove machines if this state is not valid This function can update userService values. Normal operation will be remove machines if this state is not valid
""" """
if self.isRemovableOnLogout(userService): if self.isRemovableOnLogout(userService):
log.doLog(userService, log.INFO, 'Unused user service for too long. Removing due to OS Manager parameters.', log.OSMANAGER)
userService.remove() userService.remove()
def isPersistent(self): def isPersistent(self):

View File

@ -264,6 +264,7 @@ class WindowsOsManager(osmanagers.OSManager):
This function can update userService values. Normal operation will be remove machines if this state is not valid This function can update userService values. Normal operation will be remove machines if this state is not valid
""" """
if self.isRemovableOnLogout(userService): if self.isRemovableOnLogout(userService):
log.doLog(userService, log.INFO, 'Unused user service for too long. Removing due to OS Manager parameters.', log.OSMANAGER)
userService.remove() userService.remove()
def isPersistent(self): def isPersistent(self):