mirror of
https://github.com/dkmstr/openuds.git
synced 2025-01-05 09:17:54 +03:00
* Added new global config var for time elapsed before services in use for old publications are removed
* Added support for removal of services from old publications in use once a configured time is elapsed
This commit is contained in:
parent
b2b747a099
commit
8d9b825237
@ -88,7 +88,7 @@ class PublicationFinishChecker(DelayedTask):
|
|||||||
if State.isPreparing(prevState):
|
if State.isPreparing(prevState):
|
||||||
dsp.deployed_service.publications.filter(state=State.USABLE).update(state=State.REMOVABLE)
|
dsp.deployed_service.publications.filter(state=State.USABLE).update(state=State.REMOVABLE)
|
||||||
dsp.setState(State.USABLE)
|
dsp.setState(State.USABLE)
|
||||||
dsp.deployed_service.markOldDeployedServicesAsRemovables(dsp)
|
dsp.deployed_service.markOldUserServicesAsRemovables(dsp)
|
||||||
elif State.isRemoving(prevState):
|
elif State.isRemoving(prevState):
|
||||||
dsp.setState(State.REMOVED)
|
dsp.setState(State.REMOVED)
|
||||||
else: # State is canceling
|
else: # State is canceling
|
||||||
|
@ -238,6 +238,10 @@ class GlobalConfig(object):
|
|||||||
# Allowed "trusted sources" for request
|
# Allowed "trusted sources" for request
|
||||||
TRUSTED_SOURCES = Config.section(SECURITY_SECTION).value('Trusted Hosts', '*')
|
TRUSTED_SOURCES = Config.section(SECURITY_SECTION).value('Trusted Hosts', '*')
|
||||||
|
|
||||||
|
# How long will a service "in use" be allowed to exists once a new publication is launched, defaults to 3 days
|
||||||
|
# This is expressed in hours
|
||||||
|
KEEP_IN_USE_HOURS = Config.section(GLOBAL_SECTION).value('Keep In Use Hours', '72')
|
||||||
|
|
||||||
initDone = False
|
initDone = False
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -52,7 +52,7 @@ class PublicationInfoItemsCleaner(Job):
|
|||||||
super(PublicationInfoItemsCleaner,self).__init__(environment)
|
super(PublicationInfoItemsCleaner,self).__init__(environment)
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
removeFrom = getSqlDatetime() - timedelta(seconds = GlobalConfig.KEEP_INFO_TIME.getInt())
|
removeFrom = getSqlDatetime() - timedelta(seconds = GlobalConfig.KEEP_INFO_TIME.getInt(True))
|
||||||
DeployedServicePublication.objects.filter(state__in=State.INFO_STATES, state_date__lt=removeFrom).delete()
|
DeployedServicePublication.objects.filter(state__in=State.INFO_STATES, state_date__lt=removeFrom).delete()
|
||||||
|
|
||||||
class PublicationCleaner(Job):
|
class PublicationCleaner(Job):
|
||||||
@ -63,13 +63,17 @@ class PublicationCleaner(Job):
|
|||||||
super(PublicationCleaner,self).__init__(environment)
|
super(PublicationCleaner,self).__init__(environment)
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
removables = DeployedServicePublication.objects.filter(state=State.REMOVABLE)[0:3]
|
removables = DeployedServicePublication.objects.filter(state=State.REMOVABLE)
|
||||||
for removable in removables:
|
for removable in removables:
|
||||||
try:
|
try:
|
||||||
PublicationManager.manager().unpublish(removable)
|
PublicationManager.manager().unpublish(removable)
|
||||||
except PublishException: # Can say that it cant be removed right now
|
except PublishException: # Can say that it cant be removed right now
|
||||||
logger.debug('Delaying removal')
|
logger.debug('Delaying removal')
|
||||||
pass
|
pass
|
||||||
|
# Now check too long "in use" services for all publications
|
||||||
|
now = getSqlDatetime()
|
||||||
|
removeFrom = now - timedelta(hours = GlobalConfig.KEEP_IN_USE_HOURS.getInt(True))
|
||||||
|
for dsp in removables.filter(state_date__lt=removeFrom):
|
||||||
|
dsp.deployed_service.filter(in_use=True).update(in_use=False, state_date=now)
|
||||||
|
dsp.deployed_service.markOldUserServicesAsRemovables(dsp)
|
||||||
|
|
@ -1006,7 +1006,7 @@ class DeployedService(models.Model):
|
|||||||
self.setState(State.REMOVED)
|
self.setState(State.REMOVED)
|
||||||
|
|
||||||
|
|
||||||
def markOldDeployedServicesAsRemovables(self, activePub):
|
def markOldUserServicesAsRemovables(self, activePub):
|
||||||
'''
|
'''
|
||||||
Used when a new publication is finished.
|
Used when a new publication is finished.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user