auto_arch_refuse()
This commit is contained in:
parent
0823802908
commit
8894fcbca3
1 changed files with 49 additions and 0 deletions
|
|
@ -104,6 +104,55 @@ def set_refusal(hostID, taskID, soft=True, by_host=False, msg=''):
|
|||
log_both(f'Host refused task: {msg}', task_id=taskID, host_id=hostID)
|
||||
|
||||
|
||||
def auto_arch_refuse(task_id):
|
||||
"""Set refusals for hosts based on task parameters"""
|
||||
# HACK
|
||||
task = kojihub.Task(task_id)
|
||||
info = task.getInfo(request=True)
|
||||
if info['arch'] != 'noarch':
|
||||
return
|
||||
if info['method'] not in {'buildArch', 'buildMaven', 'wrapperRPM', 'rebuildSRPM',
|
||||
'buildSRPMFromSCM', 'rebuildSRPM'}:
|
||||
return
|
||||
|
||||
try:
|
||||
task_params = koji.tasks.parse_task_params(info['method'], info['request'])
|
||||
except Exception:
|
||||
logger.warning('Invalid params for task %i', task_id)
|
||||
return
|
||||
|
||||
try:
|
||||
# figure out build tag
|
||||
if info['method'] in {'buildMaven', 'buildSRPMFromSCM', 'rebuildSRPM'}:
|
||||
tag = task_params['build_tag']
|
||||
elif info['method'] == 'buildArch':
|
||||
tag = task_params['root']
|
||||
elif info['method'] == 'wrapperRPM':
|
||||
target = kojihub.get_build_target(task_params['build_target'])
|
||||
if not target:
|
||||
logger.warning('Invalid target for task %i', task_id)
|
||||
return
|
||||
tag = target['build_tag']
|
||||
taginfo = kojihub.get_tag(tag)
|
||||
if not taginfo:
|
||||
logger.warning('Invalid build tag for task %i', task_id)
|
||||
return
|
||||
|
||||
# from here, we're basically doing checkHostArch() for all hosts in the channel
|
||||
tag_arches = set([koji.canonArch(a) for a in taginfo['arches'].split()])
|
||||
|
||||
hosts = context.handlers.call('listHosts', channelID=info['channel_id'], enabled=True)
|
||||
for host in hosts:
|
||||
host_arches = host['arches'].split()
|
||||
logger.debug('%r vs %r', tag_arches, host_arches)
|
||||
if not tag_arches.intersection(host_arches):
|
||||
set_refusal(host['id'], task_id, soft=False, msg='automatic arch refusal')
|
||||
|
||||
except Exception:
|
||||
logger.exception('Error generating auto refusals for task %i', task_id)
|
||||
return
|
||||
|
||||
|
||||
class TaskRefusalsQuery(QueryView):
|
||||
|
||||
tables = ['scheduler_task_refusals']
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue