Fixed oVirt jobs & aasigned an unused worker

This commit is contained in:
Adolfo Gómez García 2019-12-26 11:54:55 +01:00
parent 8cded2bca7
commit ddc2699774
2 changed files with 10 additions and 8 deletions

View File

@ -45,8 +45,8 @@ class AssignedAndUnused(Job):
# frecuency_cfg = GlobalConfig.CHECK_UNUSED_TIME
friendly_name = 'Unused services checker'
def run(self):
since_state = getSqlDatetime() - timedelta(seconds=GlobalConfig.CHECK_UNUSED_TIME)
def run(self) -> None:
since_state = getSqlDatetime() - timedelta(seconds=GlobalConfig.CHECK_UNUSED_TIME.getInt())
for ds in ServicePool.objects.all():
# Skips checking deployed services in maintenance mode or ignores assigned and unused
if ds.isInMaintenance() is True or ds.ignores_unused:

View File

@ -34,6 +34,8 @@ import typing
from uds.core import jobs
from uds.models import Provider
# Not imported at runtime, just for type checking
if typing.TYPE_CHECKING:
from .provider import OVirtProvider
@ -75,21 +77,21 @@ class OVirtDeferredRemoval(jobs.Job):
except Exception as e:
logger.warning('Exception got queuing for Removal: %s', e)
def run(self):
def run(self) -> None:
from .provider import OVirtProvider
logger.debug('Looking for deferred vm removals')
provider: OVirtProvider
provider: Provider
# Look for Providers of type VCServiceProvider
for provider in OVirtProvider.objects.filter(maintenance_mode=False, data_type=OVirtProvider.typeType):
for provider in Provider.objects.filter(maintenance_mode=False, data_type=OVirtProvider.typeType):
logger.debug('Provider %s if os type ovirt', provider)
storage = provider.getEnvironment().storage
instance = provider.getInstance()
instance: OVirtProvider = typing.cast(OVirtProvider, provider.getInstance())
for i in storage.filter('tRm'):
vmId = i[1]
vmId = i[1].decode()
try:
logger.debug('Found %s for removal %s', vmId, i)
# If machine is powered on, tries to stop it
@ -105,7 +107,7 @@ class OVirtDeferredRemoval(jobs.Job):
# It this is reached, remove check
storage.remove('tr' + vmId)
except Exception as e: # Any other exception wil be threated again
instance.doLog('Delayed removal of %s has failed: %s. Will retry later', vmId, e)
# instance.doLog('Delayed removal of %s has failed: %s. Will retry later', vmId, e)
logger.error('Delayed removal of %s failed: %s', i, e)
logger.debug('Deferred removal finished')