PR#1699: allow setting multiple schedule task names for product pages

Merges #1699
https://pagure.io/fm-orchestrator/pull-request/1699
This commit is contained in:
Mike McLean
2021-04-23 11:52:08 -04:00
2 changed files with 29 additions and 16 deletions

View File

@@ -671,8 +671,15 @@ class Config(object):
"product_pages_schedule_task_name": {
"type": str,
"default": "",
"desc": "A schedule task name. This is used to check Product schedules for cases where "
"the stream should be used before release."
"desc": "The name of the governing schedule task. The finish date from the matching"
"task is used to determine if a stream suffix should be added ahead of the GA"
"date. The comparison is case insensitive."
},
"product_pages_schedule_task_names": {
"type": list,
"default": [],
"desc": "Like product_pages_schedule_task_name, but accepts a list. The list is"
"treated as order of preference."
},
"num_threads_for_build_submissions": {
"type": int,

View File

@@ -410,9 +410,14 @@ def _process_support_streams(db_session, mmd, params):
"""
Check if the specified scheduled task date has been reached. Returns True if it has.
"""
if not conf.product_pages_schedule_task_name:
log.debug(config_msg, "product_pages_schedule_task_name")
return False
names = conf.product_pages_schedule_task_names
if not names:
# also allow for the older, single-valued option
if conf.product_pages_schedule_task_name:
names = [conf.product_pages_schedule_task_name]
else:
log.debug(config_msg, "product_pages_schedule_task_names")
return False
schedule_url = "{}/api/v7/releases/{}/schedule-tasks/?fields=name,date_finish".format(
conf.product_pages_url.rstrip("/"), pp_release)
@@ -430,17 +435,18 @@ def _process_support_streams(db_session, mmd, params):
)
return False
name = conf.product_pages_schedule_task_name.lower().strip()
for task in pp_json:
if task['name'].lower().strip() == name:
task_date = task['date_finish']
if datetime.strptime(task_date, "%Y-%m-%d").date() >= datetime.utcnow().date():
log.debug(
"The task date %s hasn't been reached yet. Not adding a stream suffix.",
task_date
)
return False
return True
for name in names:
name = name.lower().strip()
for task in pp_json:
if task['name'].lower().strip() == name:
task_date = task['date_finish']
if datetime.strptime(task_date, "%Y-%m-%d").date() >= datetime.utcnow().date():
log.debug(
"The task date %s hasn't been reached yet. Not adding a stream suffix.",
task_date
)
return False
return True
# Schedule task not available; rely on GA date
return False