Fixed a couple of things on UDS

This commit is contained in:
Adolfo Gómez García 2020-07-08 18:48:46 +02:00
parent 675e335aa4
commit a31411fbf0
2 changed files with 10 additions and 2 deletions

View File

@ -59,7 +59,6 @@ class OGDeployment(UserDeployment):
provider of this elements.
The logic for managing ovirt deployments (user machines in this case) is here.
"""
# : Recheck every N seconds by default (for task methods)
@ -254,10 +253,19 @@ class OGDeployment(UserDeployment):
Deploys a machine from template for user/cache
"""
try:
r: typing.Any = None
r = self.service().reserve()
self.service().notifyEvents(r['id'], self._uuid)
except Exception as e:
# logger.exception('Creating machine')
if r: # Reservation was done, unreserve it!!!
logger.error('Error on notifyEvent (machine was reserved): %s', e)
try:
self.service().unreserve(self._machineId)
except Exception as ei:
# Error unreserving reserved machine on creation
logger.error('Error unreserving errored machine: %s', ei)
raise Exception('Error creating reservation: {}'.format(e))
self._machineId = r['id']

View File

@ -68,7 +68,7 @@ class OpenGnsysMaintainer(jobs.Job):
# Now mark for removal every CACHED service that is about to expire its reservation on OpenGnsys
userService: models.UserService
for userService in models.UserService.objects.filter(deployed_service__service=service, creation_date__lt=since, cache_level=1):
logger.debug('The cached user service %s is about to expire. Removing it so it can be recreated')
logger.info('The cached user service %s is about to expire. Removing it so it can be recreated', userService)
userService.remove()
logger.debug('OpenGnsys job finished')