| |
@@ -605,7 +605,8 @@
|
| |
parent: the id of the parent task (creates a subtask)
|
| |
label: (subtasks only) the label of the subtask
|
| |
owner: the user_id that should own the task
|
| |
- channel: the channel to place the task in
|
| |
+ channel: requested channel override
|
| |
+ default_channel: default channel
|
| |
arch: the arch for the task
|
| |
priority: the priority of the task
|
| |
assign: a host_id to assign the task to
|
| |
@@ -659,6 +660,12 @@
|
| |
for key in 'arch', 'parent', 'label', 'owner':
|
| |
policy_data[key] = opts[key]
|
| |
policy_data['user_id'] = opts['owner']
|
| |
+ default_channel = 'default'
|
| |
+ if 'default_channel' in opts:
|
| |
+ default_channel = opts['default_channel']
|
| |
+ if 'channel' not in opts and context.opts.get('DefaultChannelCompat'):
|
| |
+ # in the compat case, treat explicit default as an override
|
| |
+ opts['channel'] = default_channel
|
| |
if 'channel' in opts:
|
| |
policy_data['req_channel'] = opts['channel']
|
| |
channel_info = get_channel(opts['channel'])
|
| |
@@ -673,8 +680,8 @@
|
| |
ruleset = context.policy.get('channel')
|
| |
result = ruleset.apply(policy_data)
|
| |
if result is None:
|
| |
- logger.warning('Channel policy returned no result, using default')
|
| |
- opts['channel_id'] = get_channel_id('default', strict=True)
|
| |
+ logger.debug('Channel policy returned no result, using default')
|
| |
+ opts['channel_id'] = get_channel_id(default_channel, strict=True)
|
| |
else:
|
| |
try:
|
| |
parts = result.split()
|
| |
@@ -696,6 +703,9 @@
|
| |
ruleset.last_rule())
|
| |
raise koji.GenericError("invalid channel policy")
|
| |
opts['channel_id'] = req_channel_id
|
| |
+ elif parts[0] == "default":
|
| |
+ # note this is different from "use default" if default_channel is passed
|
| |
+ opts['channel_id'] = get_channel_id(default_channel, strict=True)
|
| |
else:
|
| |
logger.error("Invalid result from channel policy: %s", ruleset.last_rule())
|
| |
raise koji.GenericError("invalid channel policy")
|
| |
@@ -10859,7 +10869,7 @@
|
| |
|
| |
return make_task('chainbuild', [srcs, target, opts], **taskOpts)
|
| |
|
| |
- def mavenBuild(self, url, target, opts=None, priority=None, channel='maven'):
|
| |
+ def mavenBuild(self, url, target, opts=None, priority=None, channel=None):
|
| |
"""Create a Maven build task
|
| |
|
| |
url: The url to checkout the source from. May be a CVS, SVN, or GIT repository.
|
| |
@@ -10867,7 +10877,7 @@
|
| |
priority: the amount to increase (or decrease) the task priority, relative
|
| |
to the default priority; higher values mean lower priority; only
|
| |
admins have the right to specify a negative priority here
|
| |
- channel: the channel to allocate the task to (defaults to the "maven" channel)
|
| |
+ channel: override the channel to allocate the task to
|
| |
|
| |
Returns the task ID
|
| |
"""
|
| |
@@ -10877,7 +10887,7 @@
|
| |
convert_value(url, cast=str, check_only=True)
|
| |
if not opts:
|
| |
opts = {}
|
| |
- taskOpts = {}
|
| |
+ taskOpts = {'default_channel': 'maven'}
|
| |
if priority:
|
| |
if priority < 0:
|
| |
if not context.session.hasPerm('admin'):
|
| |
@@ -10888,7 +10898,7 @@
|
| |
|
| |
return make_task('maven', [url, target, opts], **taskOpts)
|
| |
|
| |
- def wrapperRPM(self, build, url, target, priority=None, channel='maven', opts=None):
|
| |
+ def wrapperRPM(self, build, url, target, priority=None, channel=None, opts=None):
|
| |
"""Create a top-level wrapperRPM task
|
| |
|
| |
build: The build to generate wrapper rpms for. Must be in the COMPLETE state and have no
|
| |
@@ -10900,7 +10910,7 @@
|
| |
priority: the amount to increase (or decrease) the task priority, relative
|
| |
to the default priority; higher values mean lower priority; only
|
| |
admins have the right to specify a negative priority here
|
| |
- channel: the channel to allocate the task to (defaults to the "maven" channel)
|
| |
+ channel: override the channel to allocate the task to
|
| |
|
| |
returns the task ID
|
| |
"""
|
| |
@@ -10923,18 +10933,19 @@
|
| |
logger.warning('The wrapperRPM call ignores repo_id options')
|
| |
del opts['repo_id']
|
| |
|
| |
- taskOpts = {}
|
| |
+ taskOpts = {'default_channel': 'maven'}
|
| |
if priority:
|
| |
if priority < 0:
|
| |
if not context.session.hasPerm('admin'):
|
| |
raise koji.ActionNotAllowed('only admins may create high-priority tasks')
|
| |
taskOpts['priority'] = koji.PRIO_DEFAULT + priority
|
| |
- convert_value(channel, cast=str, check_only=True)
|
| |
- taskOpts['channel'] = channel
|
| |
+ if channel is not None:
|
| |
+ convert_value(channel, cast=str, check_only=True)
|
| |
+ taskOpts['channel'] = channel
|
| |
|
| |
return make_task('wrapperRPM', [url, build_target, build, None, opts], **taskOpts)
|
| |
|
| |
- def chainMaven(self, builds, target, opts=None, priority=None, channel='maven'):
|
| |
+ def chainMaven(self, builds, target, opts=None, priority=None, channel=None):
|
| |
"""Create a Maven chain-build task
|
| |
|
| |
builds: a list of maps defining the parameters for the sequence of builds
|
| |
@@ -10942,7 +10953,7 @@
|
| |
priority: the amount to increase (or decrease) the task priority, relative
|
| |
to the default priority; higher values mean lower priority; only
|
| |
admins have the right to specify a negative priority here
|
| |
- channel: the channel to allocate the task to (defaults to the "maven" channel)
|
| |
+ channel: override the channel to allocate the task to
|
| |
|
| |
Returns the task ID
|
| |
"""
|
| |
@@ -10950,7 +10961,7 @@
|
| |
if not context.opts.get('EnableMaven'):
|
| |
raise koji.GenericError("Maven support not enabled")
|
| |
convert_value(builds, cast=dict, check_only=True)
|
| |
- taskOpts = {}
|
| |
+ taskOpts = {'default_channel': 'maven'}
|
| |
if priority:
|
| |
if priority < 0:
|
| |
if not context.session.hasPerm('admin'):
|
| |
@@ -10961,7 +10972,7 @@
|
| |
|
| |
return make_task('chainmaven', [builds, target, opts], **taskOpts)
|
| |
|
| |
- def winBuild(self, vm, url, target, opts=None, priority=None, channel='vm'):
|
| |
+ def winBuild(self, vm, url, target, opts=None, priority=None, channel=None):
|
| |
"""
|
| |
Create a Windows build task
|
| |
|
| |
@@ -10972,7 +10983,7 @@
|
| |
priority: the amount to increase (or decrease) the task priority, relative
|
| |
to the default priority; higher values mean lower priority; only
|
| |
admins have the right to specify a negative priority here
|
| |
- channel: the channel to allocate the task to (defaults to the "vm" channel)
|
| |
+ channel: override the channel to allocate the task to
|
| |
|
| |
Returns the task ID
|
| |
"""
|
| |
@@ -10987,7 +10998,7 @@
|
| |
assert_policy('vm', policy_data)
|
| |
if not opts:
|
| |
opts = {}
|
| |
- taskOpts = {}
|
| |
+ taskOpts = {'default_channel': 'vm'}
|
| |
if priority:
|
| |
if priority < 0:
|
| |
if not context.session.hasPerm('admin'):
|
| |
@@ -11012,7 +11023,7 @@
|
| |
|
| |
context.session.assertPerm(img_type)
|
| |
|
| |
- taskOpts = {'channel': img_type}
|
| |
+ taskOpts = {'default_channel': img_type}
|
| |
if img_type == 'livemedia':
|
| |
taskOpts['arch'] = 'noarch'
|
| |
else:
|
| |
@@ -11034,7 +11045,7 @@
|
| |
Create an image using two other images and an indirection template
|
| |
"""
|
| |
context.session.assertPerm('image')
|
| |
- taskOpts = {'channel': 'image'}
|
| |
+ taskOpts = {'default_channel': 'image'}
|
| |
if priority:
|
| |
if priority < 0:
|
| |
if not context.session.hasPerm('admin'):
|
| |
@@ -11059,7 +11070,7 @@
|
| |
for i in [name, inst_tree, version]:
|
| |
convert_value(i, cast=str, check_only=True)
|
| |
context.session.assertPerm('image')
|
| |
- taskOpts = {'channel': 'image'}
|
| |
+ taskOpts = {'default_channel': 'image'}
|
| |
if priority:
|
| |
if priority < 0:
|
| |
if not context.session.hasPerm('admin'):
|
| |
@@ -13678,7 +13689,7 @@
|
| |
logger.debug("Cancelling distRepo task %d" % task_id)
|
| |
Task(task_id).cancel(recurse=True)
|
| |
return make_task('distRepo', [tag, repo_id, keys, task_opts],
|
| |
- priority=15, channel='createrepo')
|
| |
+ priority=15, default_channel='createrepo')
|
| |
|
| |
def newRepo(self, tag, event=None, src=False, debuginfo=False, separate_src=False):
|
| |
"""Create a newRepo task. returns task id"""
|
| |
@@ -13706,7 +13717,7 @@
|
| |
if debuginfo:
|
| |
opts['debuginfo'] = True
|
| |
args = koji.encode_args(tag, **opts)
|
| |
- return make_task('newRepo', args, priority=15, channel='createrepo')
|
| |
+ return make_task('newRepo', args, priority=15, default_channel='createrepo')
|
| |
|
| |
def repoExpire(self, repo_id):
|
| |
"""mark repo expired"""
|
| |
Currently, we use the
channel
param tomake_task()
as both a user override mechanism a way for the call handler to adjust the default.Channel is always ultimately determined by policy, but the policy cannot distinguish between the user passing a channel override for a maven task and the call handler indicating that the default should be
"maven"
instead of"default"
.This PR adds a separate mechanism for specifying the default and alters call handlers to use that instead (but still use
channel
for user overrides).Fixes https://pagure.io/koji/issue/4399