Merge branch 'master' into 7330-improved-sso-package
[arvados.git] / services / api / script / crunch-dispatch.rb
index 515bfaada00cf768c602bba154c9045d33cca3f5..4a1fdbce758d7b552f529419f7c37f970299d298 100755 (executable)
@@ -1,5 +1,9 @@
 #!/usr/bin/env ruby
 
+# We want files written by crunch-dispatch to be writable by other processes
+# with the same GID, see bug #7228
+File.umask(0002)
+
 require 'shellwords'
 include Process
 
@@ -63,6 +67,8 @@ class Dispatcher
       raise "No CRUNCH_JOB_BIN env var, and crunch-job not in path."
     end
 
+    @docker_bin = ENV['CRUNCH_JOB_DOCKER_BIN']
+
     @arvados_internal = Rails.configuration.git_internal_dir
     if not File.exists? @arvados_internal
       $stderr.puts `mkdir -p #{@arvados_internal.shellescape} && git init --bare #{@arvados_internal.shellescape}`
@@ -372,6 +378,7 @@ class Dispatcher
       if Server::Application.config.crunch_job_user
         cmd_args.unshift("sudo", "-E", "-u",
                          Server::Application.config.crunch_job_user,
+                         "LD_LIBRARY_PATH=#{ENV['LD_LIBRARY_PATH']}",
                          "PATH=#{ENV['PATH']}",
                          "PERLLIB=#{ENV['PERLLIB']}",
                          "PYTHONPATH=#{ENV['PYTHONPATH']}",
@@ -421,6 +428,10 @@ class Dispatcher
                    '--job', job.uuid,
                    '--git-dir', @arvados_internal]
 
+      if @docker_bin
+        cmd_args += ['--docker-bin', @docker_bin]
+      end
+
       if @todo_job_retries.include?(job.uuid)
         cmd_args << "--force-unlock"
       end
@@ -740,6 +751,7 @@ class Dispatcher
 
   def run
     act_as_system_user
+    User.first.group_permissions
     $stderr.puts "dispatch: ready"
     while !$signal[:term] or @running.size > 0
       read_pipes