#2711 Task priority policy
Merged 3 years ago by tkopecek. Opened 3 years ago by tkopecek.
tkopecek/koji issue2710  into  master

@@ -10,6 +10,7 @@ 

  * allowing builds from expired repos

  * managing the package list for a tag

  * managing which channel a task goes to

+ * altering task priority

  

  In the future, we expect to add more policy hooks for controlling more aspects

  of the system.
@@ -145,7 +146,7 @@ 

  Most of the policies are simply allow/deny policies. They have two possible

  actions: ``allow`` or ``deny``.

  

- The channel policy is used to determine the channel for a task. It supports

+ The **channel** policy is used to determine the channel for a task. It supports

  the following actions:

  

  ``use <channel>``
@@ -161,6 +162,37 @@ 

      * only valid for child tasks

      * recommend using the ``is_child_task`` test to be sure

  

+ The **priority** policy is used to alter task's priority. In most cases you

+ should manage priorities by different channels and builders assigned to them.

+ There is nevertheless few corner-cases which can benefit from altering task's

+ priority.

+ 

+ Note, that you can easily get to deadlock situation if this is not handled with

+ caution (lower priority tasks will get assigned only if there is no higher

+ priority task for given channel).

+ 

+ .. note::

+     For example OSBS use this mechanism to propagate higher priority tasks to

+     its plugin.  Deadlock problem is here mitigated by limiting policy to

+     ``buildContainer`` tasks only. These tasks are consumed only by dedicated

+     builders/channel, so they will not take priority over other types of tasks

+     (e.g. ``newRepo`` or ``tagBuild`` tasks which could be blocked otherwise.

+ 

+ Technically it is very similar to **channel** policy. Only actions are

+ different:

+ 

+ ``stay``

+     * don't touch the default priority of the task

+ 

+ ``set <int>``

+     * set priority to this value

+ 

+ ``adjust +<int>``

+     * increment default priority

+ 

+ ``adjust -<int>``

+     * decrement default priority

+ 

  Available tests

  ===============

  ``true``

file modified
+24
@@ -593,6 +593,30 @@ 

              logger.error("Invalid result from channel policy: %s", ruleset.last_rule())

              raise koji.GenericError("invalid channel policy")

  

+     ruleset = context.policy.get('priority')

+     result = ruleset.apply(policy_data)

+     if result is None:

+         logger.warning('Priority policy returned no result, using default value: %s'

+                        % opts['priority'])

+     else:

+         try:

+             parts = result.split()

+             if parts[0] == 'stay':

+                 # dont' change priority

+                 pass

+             elif parts[0] == 'set':

+                 # fixed value

+                 opts['priority'] = int(parts[1])

+             elif parts[0] == 'adjust':

+                 # note: int() will accept our preferred "+1" representation for increments

+                 opts['priority'] += int(parts[1])

+             else:

+                 logger.error("Invalid result from priority policy: %s", ruleset.last_rule())

+                 raise koji.GenericError("invalid priority policy")

+         except (IndexError, ValueError):

+             logger.error("Invalid result from priority policy: %s", ruleset.last_rule())

+             raise koji.GenericError("invalid priority policy")

+ 

      # encode xmlrpc request

      opts['request'] = koji.xmlrpcplus.dumps(tuple(arglist), methodname=method)

      opts['state'] = koji.TASK_STATES['FREE']

file modified
+3
@@ -543,6 +543,9 @@ 

      'volume': '''

              all :: DEFAULT

              ''',

+     'priority': '''

+             all :: stay

+             ''',

  }

  

  

Metadata Update from @tkopecek:
- Pull-request tagged with: testing-ready

3 years ago

Can we list the exact corner-cases here to make it clearer to administrators when they should use this feature? Should we mention how this relates to OSBS?

1 new commit added

  • doc: expanding doc on priority policy
3 years ago

Added a note - is it better? Any other idea? I think that most of the cases would be related to plugins. Not sure if we have any sensible use in koji itself.

Thanks! This is much clearer. One adjustment: OSBS tasks are named "buildContainer".

rebased onto a36cb8b

3 years ago

Commit a5d43db fixes this pull-request

Pull-Request has been merged by tkopecek

3 years ago

Metadata Update from @jcupova:
- Pull-request tagged with: testing-done

3 years ago