1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-31 15:21:13 +03:00

Extend cache timeout to schedule runner also, block running a schedule

of an inventory update or a project update if its schedule places
it within that time also
This commit is contained in:
Matthew Jones 2014-11-13 13:47:23 -05:00
parent 04ec19023f
commit 300396c7ce
4 changed files with 23 additions and 0 deletions

View File

@ -995,6 +995,14 @@ class InventorySource(UnifiedJobTemplate, InventorySourceOptions):
def create_inventory_update(self, **kwargs):
return self.create_unified_job(**kwargs)
@property
def cache_timeout_blocked(self):
if not self.last_job_run:
return False
if (self.last_job_run + datetime.timedelta(seconds=self.update_cache_timeout)) > now():
return True
return False
@property
def needs_update_on_launch(self):
if self.active and self.source and self.update_on_launch:

View File

@ -370,6 +370,10 @@ class Job(UnifiedJob, JobOptions):
return False
return False
@property
def cache_timeout_blocked(self):
return False
@property
def task_impact(self):
# NOTE: We sorta have to assume the host count matches and that forks default to 5

View File

@ -298,6 +298,14 @@ class Project(UnifiedJobTemplate, ProjectOptions):
def create_project_update(self, **kwargs):
return self.create_unified_job(**kwargs)
@property
def cache_timeout_blocked(self):
if not self.last_job_run:
return False
if (self.last_job_run + datetime.timedelta(seconds=self.update_cache_timeout)) > now():
return True
return False
@property
def needs_update_on_launch(self):
if self.active and self.scm_type and self.scm_update_on_launch:

View File

@ -93,6 +93,9 @@ def tower_periodic_scheduler(self):
for schedule in schedules:
template = schedule.unified_job_template
schedule.save() # To update next_run timestamp.
if template.cache_timeout_blocked:
logger.warn("Cache timeout is in the future, bypassing schedule for template %s" % str(template.id))
continue
new_unified_job = template.create_unified_job(launch_type='scheduled', schedule=schedule)
can_start = new_unified_job.signal_start(**schedule.extra_data)
if not can_start: