Dynamic destinations - easier, high-level reasoning about docker tool support.

Added supports_docker function to RuleHelper for use in dynamic destination rules.

Add a very simple stock dynamic destination type (docker_dispatcher) that will send all jobs into either a docker enabled destination or a vanilla destination depending on whether the tool being mapped supports docker (at this time that means is annotated explicitly with a container id).
This commit is contained in:
John Chilton
2014-08-17 18:43:54 -04:00
parent b0673d1dd2
commit 0d457d30c1
4 changed files with 35 additions and 1 deletions
+11
View File
@@ -266,6 +266,17 @@
<param id="num_jobs">50</param>
<!-- <param id="job_states">queued</param> -->
</destination>
<destination id="docker_dispatch" runner="dynamic">
<!-- Follow dynamic destination type will send all tool's that
support docker to static destination defined by
docker_destination_id (docker_cluster in this example) and all
other tools to default_destination_id (normal_cluster in this
example).
-->
<param id="type">docker_dispatch</param>
<param id="docker_destination_id">docker_cluster</param>
<param id="default_destination_id">normal_cluster</param>
</destination>
<destination id="secure_pulsar_rest_dest" runner="pulsar_rest">
<param id="url">https://examle.com:8913/</param>
<!-- If set, private_token must match token in remote Pulsar's
+2 -1
View File
@@ -31,7 +31,8 @@ class JobNotReadyException( Exception ):
STOCK_RULES = dict(
choose_one=stock_rules.choose_one,
burst=stock_rules.burst
burst=stock_rules.burst,
docker_dispatch=stock_rules.docker_dispatch,
)
+18
View File
@@ -27,6 +27,24 @@ class RuleHelper( object ):
def __init__( self, app ):
self.app = app
def supports_docker( self, job_or_tool ):
""" Job rules can pass this function a job, job_wrapper, or tool and
determine if the underlying tool believes it can be containered.
"""
# Not a ton of logic in this method - but the idea is to shield rule
# developers from the details and they shouldn't have to know how to
# interrogate tool or job to figure out if it can be run in a
# container.
if hasattr( job_or_tool, 'containers' ):
tool = job_or_tool
elif hasattr( job_or_tool, 'tool' ):
# Have a JobWrapper-like
tool = job_or_tool.tool
else:
# Have a Job object.
tool = self.app.toolbox.get_tool( job_or_tool.tool_id )
return any( [ c.type == "docker" for c in tool.containers ] )
def job_count(
self,
**kwds
+4
View File
@@ -19,3 +19,7 @@ def burst( rule_helper, job, from_destination_ids, to_destination_id, num_jobs,
return to_destination_id
else:
return from_destination_ids[ 0 ]
def docker_dispatch( rule_helper, tool, docker_destination_id, default_destination_id ):
return docker_destination_id if rule_helper.supports_docker( tool ) else default_destination_id