handle noarch filtration with $handler.checkHost()
This commit is contained in:
parent
9fcce89b6c
commit
f1682ab7b7
2 changed files with 58 additions and 33 deletions
|
|
@ -909,7 +909,27 @@ class BuildTask(BaseTaskHandler):
|
|||
arch='noarch')
|
||||
self.wait(task_id)
|
||||
|
||||
class BuildArchTask(BaseTaskHandler):
|
||||
|
||||
class BaseBuildTask(BaseTaskHandler):
|
||||
"""Base class for tasks the create a build root"""
|
||||
|
||||
def checkHostArch(self, tag, hostdata):
|
||||
if not isinstance(tag, dict):
|
||||
tag = self.session.getTag(tag)
|
||||
if tag and tag['arches']:
|
||||
tag_arches = [koji.canonArch(a) for a in tag['arches'].split()]
|
||||
host_arches = hostdata['arches'].split()
|
||||
if not set(tag_arches).intersection(host_arches):
|
||||
self.logger.info('Task %s (%s): tag arches (%s) and ' \
|
||||
'host arches (%s) are disjoint' % \
|
||||
(self.id, self.method,
|
||||
', '.join(tag_arches), ', '.join(host_arches)))
|
||||
return False
|
||||
#otherwise...
|
||||
return True
|
||||
|
||||
|
||||
class BuildArchTask(BaseBuildTask):
|
||||
|
||||
Methods = ['buildArch']
|
||||
|
||||
|
|
@ -934,6 +954,10 @@ class BuildArchTask(BaseTaskHandler):
|
|||
weight = self.weight() + min(4.5, adj)
|
||||
self.session.host.setTaskWeight(self.id, weight)
|
||||
|
||||
def checkHost(self, hostdata):
|
||||
tag = self.params[1]
|
||||
return self.checkHostArch(tag, hostdata)
|
||||
|
||||
def srpm_sanity_checks(self, filename):
|
||||
header = koji.get_rpm_header(filename)
|
||||
|
||||
|
|
@ -1140,7 +1164,7 @@ class MavenTask(MultiPlatformTask):
|
|||
arch='noarch')
|
||||
self.wait(tag_task_id)
|
||||
|
||||
class BuildMavenTask(BaseTaskHandler):
|
||||
class BuildMavenTask(BaseBuildTask):
|
||||
|
||||
Methods = ['buildMaven']
|
||||
|
||||
|
|
@ -1156,6 +1180,10 @@ class BuildMavenTask(BaseTaskHandler):
|
|||
zfo.write(filepath, filepath[roottrim:])
|
||||
zfo.close()
|
||||
|
||||
def checkHost(self, hostdata):
|
||||
tag = self.params[1]
|
||||
return self.checkHostArch(tag, hostdata)
|
||||
|
||||
def handler(self, url, build_tag, opts=None):
|
||||
if opts is None:
|
||||
opts = {}
|
||||
|
|
@ -1323,7 +1351,7 @@ class BuildMavenTask(BaseTaskHandler):
|
|||
'logs': logs,
|
||||
'files': output_files}
|
||||
|
||||
class WrapperRPMTask(BaseTaskHandler):
|
||||
class WrapperRPMTask(BaseBuildTask):
|
||||
"""Build a wrapper rpm around jars output from a Maven build.
|
||||
Can either be called as a subtask of a maven task or as a separate
|
||||
top-level task. In the latter case it will permanently delete any
|
||||
|
|
@ -1347,6 +1375,10 @@ class WrapperRPMTask(BaseTaskHandler):
|
|||
if re.match("%%define\s+%s\s+" % tag, spec, re.M):
|
||||
raise koji.BuildError, "%s is not allowed to be defined in spec file" % tag
|
||||
|
||||
def checkHost(self, hostdata):
|
||||
tag = self.params[1]
|
||||
return self.checkHostArch(tag, hostdata)
|
||||
|
||||
def handler(self, spec_url, build_tag, build, task, opts=None):
|
||||
if not opts:
|
||||
opts = {}
|
||||
|
|
@ -2095,7 +2127,7 @@ class LiveCDTask(ImageTask):
|
|||
os.path.join(koji.pathinfo.imageFinalPath(),
|
||||
koji.pathinfo.livecdRelPath(image_id), isofile)
|
||||
|
||||
class BuildSRPMFromSCMTask(BaseTaskHandler):
|
||||
class BuildSRPMFromSCMTask(BaseBuildTask):
|
||||
|
||||
Methods = ['buildSRPMFromSCM']
|
||||
_taskWeight = 1.0
|
||||
|
|
@ -2113,6 +2145,10 @@ class BuildSRPMFromSCMTask(BaseTaskHandler):
|
|||
# override if desired
|
||||
pass
|
||||
|
||||
def checkHost(self, hostdata):
|
||||
tag = self.params[1]
|
||||
return self.checkHostArch(tag, hostdata)
|
||||
|
||||
def handler(self, url, build_tag, opts=None):
|
||||
# will throw a BuildError if the url is invalid
|
||||
scm = SCM(url)
|
||||
|
|
|
|||
|
|
@ -1040,39 +1040,28 @@ class TaskManager(object):
|
|||
Returns True if successful, False otherwise
|
||||
"""
|
||||
self.logger.info("Attempting to take task %s" % task['id'])
|
||||
if task['method'] in ('buildArch', 'buildSRPMFromSCM', 'buildMaven', 'wrapperRPM') and \
|
||||
task['arch'] == 'noarch':
|
||||
task_info = self.session.getTaskInfo(task['id'], request=True)
|
||||
if task['method'] in ('buildMaven', 'wrapperRPM'):
|
||||
tag = task_info['request'][1]
|
||||
else:
|
||||
tag_id = task_info['request'][1]
|
||||
tag = self.session.getTag(tag_id)
|
||||
if tag and tag['arches']:
|
||||
tag_arches = [koji.canonArch(a) for a in tag['arches'].split()]
|
||||
host_arches = self.hostdata['arches'].split()
|
||||
if not set(tag_arches).intersection(host_arches):
|
||||
self.logger.info('Skipping task %s (%s) because tag arches (%s) and ' \
|
||||
'host arches (%s) are disjoint' % \
|
||||
(task['id'], task['method'],
|
||||
', '.join(tag_arches), ', '.join(host_arches)))
|
||||
return False
|
||||
data = self.session.host.openTask(task['id'])
|
||||
if data is None:
|
||||
self.logger.warn("Could not open")
|
||||
return False
|
||||
if not data.has_key('request') or data['request'] is None:
|
||||
self.logger.warn("Task '%s' has no request" % task['id'])
|
||||
return False
|
||||
id = data['id']
|
||||
request = data['request']
|
||||
self.tasks[id] = data
|
||||
params, method = xmlrpclib.loads(request)
|
||||
method = task['method']
|
||||
if self.handlers.has_key(method):
|
||||
handlerClass = self.handlers[method]
|
||||
else:
|
||||
raise koji.GenericError, "No handler found for method '%s'" % method
|
||||
handler = handlerClass(id,method,params,self.session,self.options)
|
||||
task_info = self.session.getTaskInfo(task['id'], request=True)
|
||||
if task_info.get('request') is None:
|
||||
self.logger.warn("Task '%s' has no request" % task['id'])
|
||||
return False
|
||||
params = task_info['request']
|
||||
handler = handlerClass(task_info['id'], method, params, self.session, self.options)
|
||||
if hasattr(handler, 'checkHost'):
|
||||
if not handler.checkHost(self.hostdata):
|
||||
self.logger.info('Skipping task %s (%s) due to host check', task['id'], task['method'])
|
||||
return False
|
||||
data = self.session.host.openTask(task['id'])
|
||||
if data is None:
|
||||
self.logger.warn("Could not open")
|
||||
return False
|
||||
id = data['id']
|
||||
request = data['request']
|
||||
self.tasks[id] = data
|
||||
# set weight
|
||||
self.session.host.setTaskWeight(id,handler.weight())
|
||||
if handler.Foreground:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue