[ARVADOS] updated: 39fc7bc4040c014140e56dc277a72777e0799ca7

git at public.curoverse.com git at public.curoverse.com
Mon Apr 6 15:20:58 EDT 2015


Summary of changes:
 docker/cwl-runner/Dockerfile                     |  14 ++-
 docker/{base => cwl-runner}/apt.arvados.org.list |   0
 docker/{compute => cwl-runner}/wrapdocker        |  41 +++++++--
 sdk/cli/bin/crunch-job                           |   6 --
 sdk/python/arvados/commands/cwl_job.py           |  60 +++++++++----
 sdk/python/arvados/commands/keepdocker.py        | 103 ++++++++++++-----------
 sdk/python/tests/run_test_server.py              |  24 +++++-
 sdk/python/tests/test_cwl_job.py                 |  47 ++++++++++-
 services/api/config/application.default.yml      |   2 +
 services/api/script/crunch-dispatch.rb           |   9 +-
 services/arv-git-httpd/main.go                   |  20 +++++
 11 files changed, 239 insertions(+), 87 deletions(-)
 copy docker/{base => cwl-runner}/apt.arvados.org.list (100%)
 copy docker/{compute => cwl-runner}/wrapdocker (74%)

       via  39fc7bc4040c014140e56dc277a72777e0799ca7 (commit)
       via  0ef21f750e2734d24d2840cf39fee6b763ae3f67 (commit)
       via  9122bc6b0f68ffe7a429cfeaea58d27523a6de8f (commit)
       via  f37409d91396a5d111829cef70fb0f83daffeeb7 (commit)
      from  555c19acd8547135cb43fdd062c16d7f02344b7c (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 39fc7bc4040c014140e56dc277a72777e0799ca7
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Mon Apr 6 15:24:42 2015 -0400

    4685: Working on cwl_job test harness.

diff --git a/sdk/python/arvados/commands/cwl_job.py b/sdk/python/arvados/commands/cwl_job.py
index 212f536..28894de 100644
--- a/sdk/python/arvados/commands/cwl_job.py
+++ b/sdk/python/arvados/commands/cwl_job.py
@@ -20,19 +20,24 @@ EX_TEMPFAIL = 75
 TASK_TEMPFAIL = 111
 TASK_CANCELED = 112
 
+def parse_ranges(l):
+    r = []
+    for n in l.split(","):
+        rn = re.match("([^[]+)\[(\d+)-(\d+)\]", n)
+        if rn:
+            for c in range(int(rn.group(2)), int(rn.group(3))+1):
+                yield "%s%i" % (rn.group(1), c)
+        else:
+            yield n
+
 def parse_sinfo(sinfo):
     nodes = {}
     for l in sinfo.splitlines():
         m = re.match("(\d+) (.*)", l)
         if m:
             cpus = int(m.group(1))
-            for n in m.group(2).split(","):
-                rn = re.match("([^[]+)\[(\d+)-(\d+)\]", n)
-                if rn:
-                    for c in range(int(rn.group(2)), int(rn.group(3))+1):
-                        nodes["%s%i" % (rn.group(1), c)] = {"slots": cpus}
-                else:
-                    nodes[n] = {"slots": cpus}
+            for n in parse_ranges(m.group(2)):
+                nodes[n] = {"slots": cpus}
     return nodes
 
 def make_slots(nodes):
diff --git a/sdk/python/tests/test_cwl_job.py b/sdk/python/tests/test_cwl_job.py
index 2ab4791..365415b 100644
--- a/sdk/python/tests/test_cwl_job.py
+++ b/sdk/python/tests/test_cwl_job.py
@@ -2,8 +2,39 @@ import arvados
 import unittest
 import arvados_testutil as tutil
 import arvados.commands.cwl_job as cwl_job
+import run_test_server
+import subprocess
+import os
+import stat
+
+class CwlJobTestCase(run_test_server.TestCaseWithServers):
+    MAIN_SERVER = {}
+    KEEP_SERVER = {}
+    ARV_GIT_SERVER = {}
+
+    @classmethod
+    def setUpClass(cls):
+        super(CwlJobTestCase, cls).setUpClass()
+        run_test_server.authorize_with("admin")
+        cls.api_client = arvados.api('v1')
+        os.chdir(os.path.join(run_test_server.ARVADOS_DIR, "docker"))
+        subprocess.check_call(["./build.sh", "cwl-runner-image"])
+        arvados.commands.keepdocker.upload_image(cls.api_client, ["arvados/cwl-runner"])
+
+        repo = cls.api_client.repositories().create(body={"repository": {
+            "owner_uuid": "zzzzz-tpzed-000000000000000",
+            "name": "testrepo"
+            }}).execute()
+
+        os.mkdir(os.path.join(run_test_server.ARVADOS_DIR, "services/api/tmp/git/testrepo"))
+        os.chdir(os.path.join(run_test_server.ARVADOS_DIR, "services/api/tmp/git/testrepo"))
+        subprocess.check_call(["git", "init"])
+        with open("foo.cwl", "w") as f:
+            f.write("foo")
+        os.chmod("foo.cwl", stat.S_IRUSR|stat.S_IRGRP|stat.S_IROTH|stat.S_IXUSR|stat.S_IXGRP|stat.S_IXOTH)
+        subprocess.check_call(["git", "add", "foo.cwl"])
+        subprocess.check_call(["git", "commit", "-mTest"])
 
-class CwlJobTestCase(unittest.TestCase):
     def test_parse_sinfo(self):
         nodes = cwl_job.parse_sinfo("""
 16 compute0,compute2
@@ -18,7 +49,6 @@ class CwlJobTestCase(unittest.TestCase):
                           "compute7": {"slots": 8}},
         nodes)
 
-
     def test_make_slots(self):
         slots = cwl_job.make_slots({"compute0": {"slots": 2}, "compute1": {"slots": 4}})
         self.assertEqual({"compute0[0]": {"node": "compute0", "slot": 0, "task": None},
@@ -28,3 +58,16 @@ class CwlJobTestCase(unittest.TestCase):
                           "compute1[2]": {"node": "compute1", "slot": 2, "task": None},
                           "compute1[3]": {"node": "compute1", "slot": 3, "task": None}},
                           slots)
+
+    def test_run_job(self):
+        job = CwlJobTestCase.api_client.jobs().create(body={"job": {
+            "script": "foo.cwl",
+            "script_version": "master",
+            "script_parameters": { },
+            "repository": "testrepo",
+            "runtime_constraints": {
+                "docker_image": "arvados/cwl-runner",
+                "cwl_job": True
+            } } }).execute()
+        cwl_job.main(["--job", job["uuid"],
+                      "--job-api-token", os.environ["ARVADOS_API_TOKEN"]])

commit 0ef21f750e2734d24d2840cf39fee6b763ae3f67
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Mon Apr 6 15:24:25 2015 -0400

    4685: Refactor docker image uploading into upload_image().

diff --git a/sdk/python/arvados/commands/keepdocker.py b/sdk/python/arvados/commands/keepdocker.py
index 3f943d7..145deb1 100644
--- a/sdk/python/arvados/commands/keepdocker.py
+++ b/sdk/python/arvados/commands/keepdocker.py
@@ -263,56 +263,8 @@ def load_image_from_collection(api_client, docker_image_locator):
     else:
         raise arvados.errors.ArgumentError("Failed to find Docker image in collection %s" % docker_image_locator)
 
-
-def main(arguments=None):
+def upload_image(api, arguments):
     args = arg_parser.parse_args(arguments)
-    api = arvados.api('v1')
-
-    if args.image is None or args.image == 'images':
-        if args.no_trunc:
-            fmt = "{:30}  {:10}  {:64}  {:29}  {:20}"
-        else:
-            fmt = "{:30}  {:10}  {:12}  {:29}  {:20}"
-        print fmt.format("REPOSITORY", "TAG", "IMAGE ID", "COLLECTION", "CREATED")
-        for i, j in list_images_in_arv(api, args.retries):
-            print(fmt.format(j["repo"], j["tag"],
-                             j["dockerhash"] if args.no_trunc else j["dockerhash"][0:12],
-                             i, j["timestamp"].strftime("%c")))
-        sys.exit(0)
-
-    if args.download:
-        # search by name and tag
-        imgs_in_arv = list_images_in_arv(api, args.retries, image_name=args.image)
-        do_tag = True
-
-        if not imgs_in_arv:
-            # searh by image hash
-            imgs_in_arv = list_images_in_arv(api, args.retries, image_hash=args.image)
-            do_tag = False
-
-        if not imgs_in_arv and arvados.util.collection_uuid_pattern.match(args.image):
-            # search by collection uuid
-            imgs_in_arv = list_images_in_arv(api, args.retries, image_collection=args.image)
-            do_tag = True
-
-        if not imgs_in_arv and arvados.util.keep_locator_pattern.match(args.image):
-            # search by manifest portable data hash
-            imgs_in_arv = [[args.image]]
-            do_tag = False
-
-        if imgs_in_arv:
-            imghash = load_image_from_collection(api, imgs_in_arv[0][0])
-            if do_tag:
-                popen_docker(["tag", imghash, args.image], stdin=None, stdout=None).wait()
-            sys.exit(0)
-        else:
-            print >>sys.stderr, "arv-keepdocker: Docker image '%s' not found in Arvados" % args.image
-            sys.exit(1)
-
-    # Pull the image if requested, unless the image is specified as a hash
-    # that we already have.
-    if args.pull and not find_image_hashes(args.image):
-        pull_image(args.image, args.tag)
 
     try:
         image_hash = find_one_image_hash(args.image, args.tag)
@@ -434,5 +386,58 @@ def main(arguments=None):
             if error.errno != errno.ENOENT:
                 raise
 
+
+def main(arguments=None):
+    args = arg_parser.parse_args(arguments)
+    api = arvados.api('v1')
+
+    if args.image is None or args.image == 'images':
+        if args.no_trunc:
+            fmt = "{:30}  {:10}  {:64}  {:29}  {:20}"
+        else:
+            fmt = "{:30}  {:10}  {:12}  {:29}  {:20}"
+        print fmt.format("REPOSITORY", "TAG", "IMAGE ID", "COLLECTION", "CREATED")
+        for i, j in list_images_in_arv(api, args.retries):
+            print(fmt.format(j["repo"], j["tag"],
+                             j["dockerhash"] if args.no_trunc else j["dockerhash"][0:12],
+                             i, j["timestamp"].strftime("%c")))
+        sys.exit(0)
+
+    if args.download:
+        # search by name and tag
+        imgs_in_arv = list_images_in_arv(api, args.retries, image_name=args.image)
+        do_tag = True
+
+        if not imgs_in_arv:
+            # searh by image hash
+            imgs_in_arv = list_images_in_arv(api, args.retries, image_hash=args.image)
+            do_tag = False
+
+        if not imgs_in_arv and arvados.util.collection_uuid_pattern.match(args.image):
+            # search by collection uuid
+            imgs_in_arv = list_images_in_arv(api, args.retries, image_collection=args.image)
+            do_tag = True
+
+        if not imgs_in_arv and arvados.util.keep_locator_pattern.match(args.image):
+            # search by manifest portable data hash
+            imgs_in_arv = [[args.image]]
+            do_tag = False
+
+        if imgs_in_arv:
+            imghash = load_image_from_collection(api, imgs_in_arv[0][0])
+            if do_tag:
+                popen_docker(["tag", imghash, args.image], stdin=None, stdout=None).wait()
+            sys.exit(0)
+        else:
+            print >>sys.stderr, "arv-keepdocker: Docker image '%s' not found in Arvados" % args.image
+            sys.exit(1)
+
+    # Pull the image if requested, unless the image is specified as a hash
+    # that we already have.
+    if args.pull and not find_image_hashes(args.image):
+        pull_image(args.image, args.tag)
+
+    upload_image(api, arguments)
+
 if __name__ == '__main__':
     main()

commit 9122bc6b0f68ffe7a429cfeaea58d27523a6de8f
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Mon Apr 6 15:23:57 2015 -0400

    4685: run_test_server support for arv-git-httpd.

diff --git a/sdk/python/tests/run_test_server.py b/sdk/python/tests/run_test_server.py
index b9502f0..99d66ca 100644
--- a/sdk/python/tests/run_test_server.py
+++ b/sdk/python/tests/run_test_server.py
@@ -351,6 +351,26 @@ def run_keep_proxy():
 def stop_keep_proxy():
     kill_server_pid(os.path.join(TEST_TMPDIR, "keepproxy.pid"), 0)
 
+def run_arv_git():
+    stop_arv_git()
+
+    admin_token = auth_token('admin')
+    env = os.environ.copy()
+    env['ARVADOS_API_TOKEN'] = admin_token
+    shutil.rmtree(os.path.join(ARVADOS_DIR, "services/api/tmp/git"), ignore_errors=True)
+    os.mkdir(os.path.join(ARVADOS_DIR, "services/api/tmp/git"))
+    argh = subprocess.Popen(
+        ["arv-git-httpd",
+         "-address=:3005",
+         "-repo-root=%s" % os.path.join(ARVADOS_DIR, "services/api/tmp/git"),
+         "-pid={}/arv-git-httpd.pid".format(TEST_TMPDIR),
+         ],
+        env=env)
+
+def stop_arv_git():
+    kill_server_pid(os.path.join(TEST_TMPDIR, "arv-git-httpd.pid"), 0)
+
+
 def fixture(fix):
     '''load a fixture yaml file'''
     with open(os.path.join(SERVICES_SRC_DIR, 'api', "test", "fixtures",
@@ -391,6 +411,7 @@ class TestCaseWithServers(unittest.TestCase):
     MAIN_SERVER = None
     KEEP_SERVER = None
     KEEP_PROXY_SERVER = None
+    ARV_GIT_SERVER = None
 
     @staticmethod
     def _restore_dict(src, dest):
@@ -409,7 +430,8 @@ class TestCaseWithServers(unittest.TestCase):
         for server_kwargs, start_func, stop_func in (
                 (cls.MAIN_SERVER, run, reset),
                 (cls.KEEP_SERVER, run_keep, stop_keep),
-                (cls.KEEP_PROXY_SERVER, run_keep_proxy, stop_keep_proxy)):
+                (cls.KEEP_PROXY_SERVER, run_keep_proxy, stop_keep_proxy),
+                (cls.ARV_GIT_SERVER, run_arv_git, stop_arv_git)):
             if server_kwargs is not None:
                 start_func(**server_kwargs)
                 cls._cleanup_funcs.append(stop_func)
diff --git a/services/api/config/application.default.yml b/services/api/config/application.default.yml
index 1696e2c..d6a58f9 100644
--- a/services/api/config/application.default.yml
+++ b/services/api/config/application.default.yml
@@ -45,6 +45,8 @@ test:
   blob_signing_key: zfhgfenhffzltr9dixws36j1yhksjoll2grmku38mi7yxd66h5j4q9w4jzanezacp8s6q0ro3hxakfye02152hncy6zml2ed0uc
   user_profile_notification_address: arvados at example.com
   workbench_address: https://localhost:3001/
+  git_repositories_dir: <%= "#{Dir.pwd}/tmp/git" %>
+  git_host: http://localhost:3005
 
 common:
   # The prefix used for all database identifiers to identify the record as
diff --git a/services/arv-git-httpd/main.go b/services/arv-git-httpd/main.go
index 0e92393..2b585ff 100644
--- a/services/arv-git-httpd/main.go
+++ b/services/arv-git-httpd/main.go
@@ -2,6 +2,7 @@ package main
 
 import (
 	"flag"
+	"fmt"
 	"log"
 	"os"
 )
@@ -10,6 +11,7 @@ type config struct {
 	Addr       string
 	GitCommand string
 	Root       string
+	Pidfile    string
 }
 
 var theConfig *config
@@ -27,6 +29,12 @@ func init() {
 	flag.StringVar(&theConfig.Root, "repo-root", cwd,
 		"Path to git repositories.")
 
+	flag.StringVar(
+		&theConfig.Pidfile,
+		"pid",
+		"",
+		"Path to write pid file")
+
 	// MakeArvadosClient returns an error if token is unset (even
 	// though we don't need to do anything requiring
 	// authentication yet). We can't do this in newArvadosClient()
@@ -42,7 +50,19 @@ func main() {
 	if err := srv.Start(); err != nil {
 		log.Fatal(err)
 	}
+
+	if theConfig.Pidfile != "" {
+		f, err := os.Create(theConfig.Pidfile)
+		if err != nil {
+			log.Fatalf("Error writing pid file (%s): %s", theConfig.Pidfile, err.Error())
+		}
+		fmt.Fprint(f, os.Getpid())
+		f.Close()
+		defer os.Remove(theConfig.Pidfile)
+	}
+
 	log.Println("Listening at", srv.Addr)
+
 	if err := srv.Wait(); err != nil {
 		log.Fatal(err)
 	}

commit f37409d91396a5d111829cef70fb0f83daffeeb7
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Mon Apr 6 13:47:15 2015 -0400

    4685: Docker-in-Docker seems to be working for cwl-runner.

diff --git a/docker/cwl-runner/Dockerfile b/docker/cwl-runner/Dockerfile
index 6c47624..e5dd48c 100644
--- a/docker/cwl-runner/Dockerfile
+++ b/docker/cwl-runner/Dockerfile
@@ -6,8 +6,20 @@ MAINTAINER Ward Vandewege <ward at curoverse.com>
 
 ENV DEBIAN_FRONTEND noninteractive
 
-RUN apt-get update && apt-get install -qqy git python-setuptools
+ADD apt.arvados.org.list /etc/apt/sources.list.d/
+RUN apt-key adv --keyserver pool.sks-keyservers.net --recv 1078ECD7
+
+RUN apt-get update -qq
+RUN apt-get install -qqy apt-utils \
+  iptables dmsetup ca-certificates lxc apt-transport-https docker.io \
+  procps git python-setuptools
+
+ADD wrapdocker /usr/local/bin/wrapdocker.sh
 
 ADD generated/sdk.tar.gz /usr/src/arvados/sdk
 
 RUN cd /usr/src/arvados/sdk/python && python setup.py install
+
+VOLUME /var/lib/docker
+
+ENTRYPOINT ["/usr/local/bin/wrapdocker.sh"]
diff --git a/docker/cwl-runner/apt.arvados.org.list b/docker/cwl-runner/apt.arvados.org.list
new file mode 100644
index 0000000..7eb8716
--- /dev/null
+++ b/docker/cwl-runner/apt.arvados.org.list
@@ -0,0 +1,2 @@
+# apt.arvados.org
+deb http://apt.arvados.org/ wheezy main
diff --git a/docker/cwl-runner/wrapdocker b/docker/cwl-runner/wrapdocker
new file mode 100755
index 0000000..bbd7b37
--- /dev/null
+++ b/docker/cwl-runner/wrapdocker
@@ -0,0 +1,113 @@
+#!/bin/bash
+
+# Ensure that all nodes in /dev/mapper correspond to mapped devices currently loaded by the device-mapper kernel driver
+dmsetup mknodes
+
+# First, make sure that cgroups are mounted correctly.
+CGROUP=/sys/fs/cgroup
+: {LOG:=stdio}
+
+[ -d $CGROUP ] || 
+	mkdir $CGROUP
+
+mountpoint -q $CGROUP || 
+	mount -n -t tmpfs -o uid=0,gid=0,mode=0755 cgroup $CGROUP || {
+		echo "Could not make a tmpfs mount. Did you use --privileged?"
+		exit 1
+	}
+
+if [ -d /sys/kernel/security ] && ! mountpoint -q /sys/kernel/security
+then
+    mount -t securityfs none /sys/kernel/security || {
+        echo "Could not mount /sys/kernel/security."
+        echo "AppArmor detection and --privileged mode might break."
+    }
+fi
+
+# Mount the cgroup hierarchies exactly as they are in the parent system.
+for SUBSYS in $(cut -d: -f2 /proc/1/cgroup)
+do
+        [ -d $CGROUP/$SUBSYS ] || mkdir $CGROUP/$SUBSYS
+        mountpoint -q $CGROUP/$SUBSYS || 
+                mount -n -t cgroup -o $SUBSYS cgroup $CGROUP/$SUBSYS
+
+        # The two following sections address a bug which manifests itself
+        # by a cryptic "lxc-start: no ns_cgroup option specified" when
+        # trying to start containers withina container.
+        # The bug seems to appear when the cgroup hierarchies are not
+        # mounted on the exact same directories in the host, and in the
+        # container.
+
+        # Named, control-less cgroups are mounted with "-o name=foo"
+        # (and appear as such under /proc/<pid>/cgroup) but are usually
+        # mounted on a directory named "foo" (without the "name=" prefix).
+        # Systemd and OpenRC (and possibly others) both create such a
+        # cgroup. To avoid the aforementioned bug, we symlink "foo" to
+        # "name=foo". This shouldn't have any adverse effect.
+        echo $SUBSYS | grep -q ^name= && {
+                NAME=$(echo $SUBSYS | sed s/^name=//)
+                ln -s $SUBSYS $CGROUP/$NAME
+        }
+
+        # Likewise, on at least one system, it has been reported that
+        # systemd would mount the CPU and CPU accounting controllers
+        # (respectively "cpu" and "cpuacct") with "-o cpuacct,cpu"
+        # but on a directory called "cpu,cpuacct" (note the inversion
+        # in the order of the groups). This tries to work around it.
+        [ $SUBSYS = cpuacct,cpu ] && ln -s $SUBSYS $CGROUP/cpu,cpuacct
+done
+
+# Note: as I write those lines, the LXC userland tools cannot setup
+# a "sub-container" properly if the "devices" cgroup is not in its
+# own hierarchy. Let's detect this and issue a warning.
+grep -q :devices: /proc/1/cgroup ||
+	echo "WARNING: the 'devices' cgroup should be in its own hierarchy."
+grep -qw devices /proc/1/cgroup ||
+	echo "WARNING: it looks like the 'devices' cgroup is not mounted."
+
+# Now, close extraneous file descriptors.
+pushd /proc/self/fd >/dev/null
+for FD in *
+do
+	case "$FD" in
+	# Keep stdin/stdout/stderr
+	[012])
+		;;
+	# Nuke everything else
+	*)
+		eval exec "$FD>&-"
+		;;
+	esac
+done
+popd >/dev/null
+
+
+# If a pidfile is still around (for example after a container restart),
+# delete it so that docker can start.
+rm -rf /var/run/docker.pid
+
+# If we were given a PORT environment variable, start as a simple daemon;
+# otherwise, spawn a shell as well
+if [ "$PORT" ]
+then
+	exec docker -d -H 0.0.0.0:$PORT -H unix://var/run/docker.sock \
+		$DOCKER_DAEMON_ARGS
+else
+	if [ "$LOG" == "file" ]
+	then
+		docker -d $DOCKER_DAEMON_ARGS &>/var/log/docker.log &
+	else
+		docker -d $DOCKER_DAEMON_ARGS &
+	fi
+	(( timeout = 60 + SECONDS ))
+	until docker info >/dev/null 2>&1
+	do
+		if (( SECONDS >= timeout )); then
+			echo 'Timed out trying to connect to internal docker host.' >&2
+			break
+		fi
+		sleep 1
+	done
+	[[ $1 ]] && exec "$@"
+	exec bash --login
+fi
diff --git a/sdk/cli/bin/crunch-job b/sdk/cli/bin/crunch-job
index c3bf1f0..294696c 100755
--- a/sdk/cli/bin/crunch-job
+++ b/sdk/cli/bin/crunch-job
@@ -118,7 +118,6 @@ $ENV{"CRUNCH_INSTALL"} = "$ENV{CRUNCH_TMP}/opt";
 $ENV{"CRUNCH_WORK"} = $ENV{"JOB_WORK"}; # deprecated
 mkdir ($ENV{"JOB_WORK"});
 
-my @save_argv = @ARGV;
 my $force_unlock;
 my $git_dir;
 my $jobspec;
@@ -166,11 +165,6 @@ if ($jobspec =~ /^[-a-z\d]+$/)
 {
   # $jobspec is an Arvados UUID, not a JSON job specification
   $Job = api_call("jobs/get", uuid => $jobspec);
-
-  if ($Job->{'runtime_constraints'}->{'cwl_job'}) {
-    exec "/home/peter/work/arvados/sdk/python/bin/arv-cwl-job", @save_argv;
-  }
-
   if (!$force_unlock) {
     # Claim this job, and make sure nobody else does
     eval { api_call("jobs/lock", uuid => $Job->{uuid}); };
diff --git a/sdk/python/arvados/commands/cwl_job.py b/sdk/python/arvados/commands/cwl_job.py
index b45bafb..212f536 100644
--- a/sdk/python/arvados/commands/cwl_job.py
+++ b/sdk/python/arvados/commands/cwl_job.py
@@ -49,10 +49,16 @@ set -v
 read pid cmd state ppid pgrp session tty_nr tpgid rest < /proc/self/stat
 trap "kill -TERM -$$pgrp; exit $TASK_CANCELED" INT QUIT TERM
 
+export ARVADOS_API_HOST=$ARVADOS_API_HOST
+export ARVADOS_API_TOKEN=$ARVADOS_API_TOKEN
+export ARVADOS_API_HOST_INSECURE=$ARVADOS_API_HOST_INSECURE
+
 arv-keepdocker --download $docker_hash
 
 rm -rf $tmpdir
 mkdir -p $tmpdir
+
+DNS="$$(ip -o address show scope global | gawk 'match($$4, /^([0-9\.:]+)\//, x){print "--dns", x[1]}')"
 """
 
 def determine_resources(slurm_jobid=None, slurm_nodelist=None):
@@ -89,10 +95,23 @@ set +e
 
 arv-mount --by-id $tmpdir/keep --allow-other --exec \
   $$CRUNCHSTAT \
-  docker run --attach=stdout --attach=stderr -i --rm
-    --cidfile=$tmpdir/cidfile --sig-proxy \
-    --volume=$tmpdir/keep:/keep:ro --volume=$tmpdir/job_output:/tmp/job_output:rw \
-    --workdir=/tmp/job_output --user=$$UID $env $docker_hash $cmd $stdin_redirect $stdout_redirect
+  docker run \
+    $$DNS \
+    --attach=stdout \
+    --attach=stderr \
+    -i \
+    --rm \
+    --cidfile=$tmpdir/cidfile \
+    --sig-proxy \
+    --volume=$tmpdir/keep:/keep:ro \
+    --volume=$tmpdir/job_output:/tmp/job_output:rw \
+    --workdir=/tmp/job_output \
+    --user=$$UID \
+    $env \
+    $docker_hash \
+    $cmd \
+    $stdin_redirect \
+    $stdout_redirect
 
 code=$$?
 
@@ -139,7 +158,10 @@ exit $$code
                                      stdin_redirect=stdin_redirect,
                                      stdout_redirect=stdout_redirect,
                                      TASK_CANCELED=TASK_CANCELED,
-                                     TASK_TEMPFAIL=TASK_TEMPFAIL)
+                                     TASK_TEMPFAIL=TASK_TEMPFAIL,
+                                     ARVADOS_API_HOST=pipes.quote(api_config["ARVADOS_API_HOST"]),
+                                     ARVADOS_API_TOKEN=pipes.quote(api_config["ARVADOS_API_TOKEN"]),
+                                     ARVADOS_API_HOST_INSECURE=pipes.quote(api_config.get("ARVADOS_API_HOST_INSECURE", "0")))
 
     if resources["have_slurm"]:
         pass
@@ -204,10 +226,11 @@ cd $tmpdir
 git init
 git config --local credential.$githttp/.helper '!tok(){ echo password=$ARVADOS_API_TOKEN; };tok'
 git config --local credential.$githttp/.username none
-ARVADOS_API_HOST=$ARVADOS_API_HOST ARVADOS_API_TOKEN=$ARVADOS_API_TOKEN ARVADOS_API_HOST_INSECURE=$ARVADOS_API_HOST_INSECURE git fetch $githttp/$gitrepo
-git checkout $script_version
+git fetch --quiet $githttp/$gitrepo
+git checkout --quiet $script_version
 
 docker run \
+    $$DNS \
     --env=JOB_UUID=$job_uuid \
     --env=ARVADOS_API_HOST=$ARVADOS_API_HOST \
     --env=ARVADOS_API_TOKEN=$ARVADOS_API_TOKEN \
@@ -233,7 +256,7 @@ docker run \
                                      tmpdir=tmpdir,
                                      ARVADOS_API_HOST=pipes.quote(api_config["ARVADOS_API_HOST"]),
                                      ARVADOS_API_TOKEN=pipes.quote(api_config["ARVADOS_API_TOKEN"]),
-                                     ARVADOS_API_HOST_INSECURE=pipes.quote(api_config.get("ARVADOS_API_TOKEN", "0")),
+                                     ARVADOS_API_HOST_INSECURE=pipes.quote(api_config.get("ARVADOS_API_HOST_INSECURE", "0")),
                                      TASK_CANCELED=TASK_CANCELED,
                                      githttp=pipes.quote(api._rootDesc.get("gitHttpBase")),
                                      gitrepo=pipes.quote(repo),
@@ -241,6 +264,8 @@ docker run \
                                      script_version=pipes.quote(job["script_version"]),
                                      job_uuid=job["uuid"])
 
+    print ex
+
     if resources["have_slurm"]:
         pass
     else:
diff --git a/services/api/script/crunch-dispatch.rb b/services/api/script/crunch-dispatch.rb
index 249582e..85dcc5a 100755
--- a/services/api/script/crunch-dispatch.rb
+++ b/services/api/script/crunch-dispatch.rb
@@ -55,6 +55,7 @@ class Dispatcher
 
   def initialize
     @crunch_job_bin = (ENV['CRUNCH_JOB_BIN'] || `which arv-crunch-job`.strip)
+    @cwl_job_bin = (ENV['CWL_JOB_BIN'] || `which arv-cwl-job`.strip)
     if @crunch_job_bin.empty?
       raise "No CRUNCH_JOB_BIN env var, and crunch-job not in path."
     end
@@ -390,10 +391,10 @@ class Dispatcher
       end
       next unless ready
 
-      cmd_args += [@crunch_job_bin,
-                   '--job-api-token', @authorizations[job.uuid].api_token,
-                   '--job', job.uuid,
-                   '--git-dir', @arvados_internal]
+      cmd_args += [(if job.runtime_constraints["cwl_job"] then @cwl_job_bin else @crunch_job_bin end),
+                    '--job-api-token', @authorizations[job.uuid].api_token,
+                    '--job', job.uuid,
+                    '--git-dir', @arvados_internal]
 
       $stderr.puts "dispatch: #{cmd_args.join ' '}"
 

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list