Merge branch 'wtsi/14110-c-d-s-limit-slurm-concurrency' refs #14110
authorPeter Amstutz <pamstutz@veritasgenetics.com>
Wed, 5 Sep 2018 18:47:19 +0000 (14:47 -0400)
committerPeter Amstutz <pamstutz@veritasgenetics.com>
Wed, 5 Sep 2018 18:47:19 +0000 (14:47 -0400)
Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <pamstutz@veritasgenetics.com>

47 files changed:
apps/workbench/test/integration/work_units_test.rb
build/build.list
build/package-build-dockerfiles/centos7/Dockerfile
build/package-build-dockerfiles/debian8/Dockerfile
build/package-build-dockerfiles/ubuntu1404/Dockerfile
build/package-build-dockerfiles/ubuntu1604/Dockerfile
build/package-build-dockerfiles/ubuntu1804/Dockerfile
build/package-test-dockerfiles/centos7/Dockerfile
build/package-test-dockerfiles/debian8/Dockerfile
build/package-test-dockerfiles/ubuntu1404/Dockerfile
build/package-test-dockerfiles/ubuntu1604/Dockerfile
build/run-tests.sh
doc/_includes/_install_compute_docker.liquid
doc/install/install-arv-git-httpd.html.textile.liquid
doc/install/install-keepstore.html.textile.liquid
sdk/cli/arvados-cli.gemspec
sdk/cli/bin/arv
sdk/cli/bin/arv-run-pipeline-instance
sdk/cli/bin/arv-tag
sdk/cwl/setup.py
sdk/cwl/tests/test_container.py
sdk/cwl/tests/test_job.py
sdk/cwl/tests/test_submit.py
sdk/go/arvadosclient/arvadosclient.go
sdk/go/dispatch/dispatch.go
sdk/python/arvados/commands/run.py
sdk/python/setup.py
sdk/python/tests/run_test_server.py
sdk/ruby/arvados.gemspec
services/api/app/models/arvados_model.rb
services/api/app/models/container.rb
services/api/app/models/container_request.rb
services/api/db/migrate/20180820132617_add_lock_index_to_containers.rb [new file with mode: 0644]
services/api/db/migrate/20180824152014_add_md5_index_to_containers.rb [new file with mode: 0644]
services/api/db/migrate/20180824155207_add_queue_index_to_containers.rb [new file with mode: 0644]
services/api/db/structure.sql
services/api/test/fixtures/container_requests.yml
services/api/test/functional/arvados/v1/groups_controller_test.rb
services/api/test/unit/container_request_test.rb
services/crunch-dispatch-local/crunch-dispatch-local.go
services/crunch-dispatch-local/crunch-dispatch-local_test.go
services/crunch-dispatch-slurm/crunch-dispatch-slurm.go
services/crunch-dispatch-slurm/crunch-dispatch-slurm_test.go
services/crunch-dispatch-slurm/squeue.go
services/crunch-dispatch-slurm/squeue_test.go
services/keepstore/s3_volume.go
services/login-sync/arvados-login-sync.gemspec

index 5f6ef9988bab245ad054e78f13da5b6d65462850..e5cc6e4dc050d47bfa2d6220a4ec02528ef7aa05 100644 (file)
@@ -93,7 +93,7 @@ class WorkUnitsTest < ActionDispatch::IntegrationTest
 
       assert_text 'created_at'
       if cancelable
-        assert_text 'priority: 1' if type.include?('container')
+        assert_text 'priority: 501' if type.include?('container')
         if type.include?('pipeline')
           assert_selector 'a', text: 'Pause'
           first('a,link', text: 'Pause').click
index f2197ecdbb62e2795bf176c650871812602673a0..4c3d740b0b82c21a71e274bfc0db1311bdcd3e43 100644 (file)
@@ -11,7 +11,7 @@ debian8,debian9,ubuntu1404,centos7|pyasn1-modules|0.0.5|2|python|all
 debian8,debian9,ubuntu1404,ubuntu1604,ubuntu1804,centos7|rsa|3.4.2|2|python|all
 debian8,debian9,ubuntu1404,ubuntu1604,ubuntu1804,centos7|uritemplate|3.0.0|2|python|all
 debian8,debian9,ubuntu1404,ubuntu1604,ubuntu1804,centos7|httplib2|0.9.2|3|python|all
-debian8,debian9,centos7|ws4py|0.4.2|2|python|all
+debian8,debian9,centos7,ubuntu1404,ubuntu1604|ws4py|0.4.2|2|python|all
 debian8,debian9,centos7|pykka|1.2.1|2|python|all
 debian8,debian9,ubuntu1404,centos7|six|1.10.0|2|python|all
 debian8,debian9,ubuntu1404,ubuntu1604,ubuntu1804,centos7|ciso8601|1.0.6|3|python|amd64
@@ -44,7 +44,7 @@ centos7|networkx|1.11|0|python|all
 centos7|psutil|5.0.1|0|python|all
 debian8,debian9,ubuntu1404,ubuntu1604,ubuntu1804,centos7|lockfile|0.12.2|2|python|all|--epoch 1
 debian8,debian9,ubuntu1404,ubuntu1604,ubuntu1804,centos7|subprocess32|3.5.1|2|python|all
-centos7,debian8,debian9,ubuntu1404,ubuntu1604|ruamel.yaml|0.15.34|1|python|amd64|--python-setup-py-arguments --single-version-externally-managed
+all|ruamel.yaml|0.14.12|2|python|amd64|--python-setup-py-arguments --single-version-externally-managed
 all|cwltest|1.0.20180518074130|4|python|all|--depends 'python-futures >= 3.0.5' --depends 'python-subprocess32 >= 3.5.0'
 all|junit-xml|1.8|3|python|all
 all|rdflib-jsonld|0.4.0|2|python|all
index 0731eb26cb90c762add201faa3dddd81aebbf0fe..216c5cbbad079bfc4ef7a16d5734579b8578995b 100644 (file)
@@ -9,7 +9,7 @@ MAINTAINER Ward Vandewege <ward@curoverse.com>
 RUN yum -q -y install make automake gcc gcc-c++ libyaml-devel patch readline-devel zlib-devel libffi-devel openssl-devel bzip2 libtool bison sqlite-devel rpm-build git perl-ExtUtils-MakeMaker libattr-devel nss-devel libcurl-devel which tar unzip scl-utils centos-release-scl postgresql-devel python-devel python-setuptools fuse-devel xz-libs git
 
 # Install RVM
-RUN gpg --keyserver pool.sks-keyservers.net --recv-keys D39DC0E3 && \
+RUN gpg --keyserver ha.pool.sks-keyservers.net --recv-keys D39DC0E3 && \
     curl -L https://get.rvm.io | bash -s stable && \
     /usr/local/rvm/bin/rvm install 2.3 && \
     /usr/local/rvm/bin/rvm alias create default ruby-2.3 && \
index bce60c544202b924ae4ca0835648a7b5e230d6e9..fb1209027bdf75438790d8736b6ce710ef656b67 100644 (file)
@@ -11,7 +11,7 @@ ENV DEBIAN_FRONTEND noninteractive
 RUN /usr/bin/apt-get update && /usr/bin/apt-get install -q -y python2.7-dev python3 python-setuptools python3-setuptools libcurl4-gnutls-dev curl git procps libattr1-dev libfuse-dev libgnutls28-dev libpq-dev python-pip unzip
 
 # Install RVM
-RUN gpg --keyserver pool.sks-keyservers.net --recv-keys D39DC0E3 && \
+RUN gpg --keyserver ha.pool.sks-keyservers.net --recv-keys D39DC0E3 && \
     curl -L https://get.rvm.io | bash -s stable && \
     /usr/local/rvm/bin/rvm install 2.3 && \
     /usr/local/rvm/bin/rvm alias create default ruby-2.3 && \
index 272c313c1db62d77d9c03c43cc8229f1bd45ebe1..b7d4081ffb98e8aa2be1d241d30938d7eaf21820 100644 (file)
@@ -11,7 +11,7 @@ ENV DEBIAN_FRONTEND noninteractive
 RUN /usr/bin/apt-get update && /usr/bin/apt-get install -q -y python2.7-dev python3 python-setuptools python3-setuptools libcurl4-gnutls-dev curl git libattr1-dev libfuse-dev libpq-dev python-pip unzip 
 
 # Install RVM
-RUN gpg --keyserver pool.sks-keyservers.net --recv-keys D39DC0E3 && \
+RUN gpg --keyserver ha.pool.sks-keyservers.net --recv-keys D39DC0E3 && \
     curl -L https://get.rvm.io | bash -s stable && \
     /usr/local/rvm/bin/rvm install 2.3 && \
     /usr/local/rvm/bin/rvm alias create default ruby-2.3 && \
index 59c5acfb1abc15a8b505d7152e6a57310a58597c..6220652e56e15faa8c917c8838b024e12bbe740c 100644 (file)
@@ -11,7 +11,7 @@ ENV DEBIAN_FRONTEND noninteractive
 RUN /usr/bin/apt-get update && /usr/bin/apt-get install -q -y python2.7-dev python3 python-setuptools python3-setuptools libcurl4-gnutls-dev libgnutls-dev curl git libattr1-dev libfuse-dev libpq-dev python-pip unzip tzdata
 
 # Install RVM
-RUN gpg --keyserver pool.sks-keyservers.net --recv-keys D39DC0E3 && \
+RUN gpg --keyserver ha.pool.sks-keyservers.net --recv-keys D39DC0E3 && \
     curl -L https://get.rvm.io | bash -s stable && \
     /usr/local/rvm/bin/rvm install 2.3 && \
     /usr/local/rvm/bin/rvm alias create default ruby-2.3 && \
index cff0f897c659895e5beb5bc117e9111c83935cd1..68df124d9e5cbebd428ebda62938b3af22c9f850 100644 (file)
@@ -11,7 +11,7 @@ ENV DEBIAN_FRONTEND noninteractive
 RUN /usr/bin/apt-get update && /usr/bin/apt-get install -q -y python2.7-dev python3 python-setuptools python3-pip libcurl4-gnutls-dev libgnutls28-dev curl git libattr1-dev libfuse-dev libpq-dev python-pip unzip tzdata
 
 # Install RVM
-RUN gpg --keyserver pool.sks-keyservers.net --recv-keys D39DC0E3 && \
+RUN gpg --keyserver ha.pool.sks-keyservers.net --recv-keys D39DC0E3 && \
     curl -L https://get.rvm.io | bash -s stable && \
     /usr/local/rvm/bin/rvm install 2.3 && \
     /usr/local/rvm/bin/rvm alias create default ruby-2.3 && \
index fd2f9e3d8cdbafced2990875f56ce72a2719672f..fa959a1eb8cc2e7aa39d89338ae203c5fe599933 100644 (file)
@@ -9,7 +9,7 @@ RUN yum -q -y install scl-utils centos-release-scl which tar
 
 # Install RVM
 RUN touch /var/lib/rpm/* && \
-    gpg --keyserver pool.sks-keyservers.net --recv-keys D39DC0E3 && \
+    gpg --keyserver ha.pool.sks-keyservers.net --recv-keys D39DC0E3 && \
     curl -L https://get.rvm.io | bash -s stable && \
     /usr/local/rvm/bin/rvm install 2.3 && \
     /usr/local/rvm/bin/rvm alias create default ruby-2.3 && \
index dcf581a1e036876cb85676e305b78eb399381448..c40ed820790a8672e63b9f01e19ba4ea86c3313f 100644 (file)
@@ -10,7 +10,7 @@ ENV DEBIAN_FRONTEND noninteractive
 # Install RVM
 RUN apt-get update && \
     apt-get -y install --no-install-recommends curl ca-certificates && \
-    gpg --keyserver pool.sks-keyservers.net --recv-keys D39DC0E3 && \
+    gpg --keyserver ha.pool.sks-keyservers.net --recv-keys D39DC0E3 && \
     curl -L https://get.rvm.io | bash -s stable && \
     /usr/local/rvm/bin/rvm install 2.3 && \
     /usr/local/rvm/bin/rvm alias create default ruby-2.3
index a1bc48443ea4eb48e4939d04deb8952c67220882..6d929e84948e3eb3d91f974b5b292b18b22fea62 100644 (file)
@@ -10,7 +10,7 @@ ENV DEBIAN_FRONTEND noninteractive
 # Install dependencies and RVM
 RUN apt-get update && \
     apt-get -y install --no-install-recommends curl ca-certificates python2.7-dev python3 python-setuptools python3-setuptools libcurl4-gnutls-dev curl git libattr1-dev libfuse-dev libpq-dev python-pip unzip binutils build-essential ca-certificates  && \
-    gpg --keyserver pool.sks-keyservers.net --recv-keys D39DC0E3 && \
+    gpg --keyserver ha.pool.sks-keyservers.net --recv-keys D39DC0E3 && \
     curl -L https://get.rvm.io | bash -s stable && \
     /usr/local/rvm/bin/rvm install 2.3 && \
     /usr/local/rvm/bin/rvm alias create default ruby-2.3
index 25d49dc5019112cc7d9cc6b251904780471faa79..54b1f401cf00cd2a3b6248676de51aee99915b29 100644 (file)
@@ -10,7 +10,7 @@ ENV DEBIAN_FRONTEND noninteractive
 # Install RVM
 RUN apt-get update && \
     apt-get -y install --no-install-recommends curl ca-certificates && \
-    gpg --keyserver pool.sks-keyservers.net --recv-keys D39DC0E3 && \
+    gpg --keyserver ha.pool.sks-keyservers.net --recv-keys D39DC0E3 && \
     curl -L https://get.rvm.io | bash -s stable && \
     /usr/local/rvm/bin/rvm install 2.3 && \
     /usr/local/rvm/bin/rvm alias create default ruby-2.3
index e669e326c512b8d29694c05106ad26d05507a4fa..4ddbf89c1d7ccb286fcfe887fb941734bffbb519 100755 (executable)
@@ -270,6 +270,7 @@ rotate_logfile() {
 
 declare -a failures
 declare -A skip
+declare -A only
 declare -A testargs
 skip[apps/workbench_profile]=1
 # nodemanager_integration tests are not reliable, see #12061.
@@ -288,7 +289,7 @@ do
             skip[$1]=1; shift
             ;;
         --only)
-            only="$1"; skip[$1]=""; shift
+            only[$1]=1; skip[$1]=""; shift
             ;;
         --short)
             short=1
@@ -331,14 +332,19 @@ done
 # required when testing it. Skip that step if it is not needed.
 NEED_SDK_R=true
 
-if [[ ! -z "${only}" && "${only}" != "sdk/R" ]]; then
+if [[ ${#only[@]} -ne 0 ]] &&
+   [[ -z "${only['sdk/R']}" && -z "${only['doc']}" ]]; then
   NEED_SDK_R=false
 fi
 
-if [[ ! -z "${skip}" && "${skip}" == "sdk/R" ]]; then
+if [[ ${skip["sdk/R"]} == 1 && ${skip["doc"]} == 1 ]]; then
   NEED_SDK_R=false
 fi
 
+if [[ $NEED_SDK_R == false ]]; then
+       echo "R SDK not needed, it will not be installed."
+fi
+
 start_services() {
     echo 'Starting API, keepproxy, keep-web, ws, arv-git-httpd, and nginx ssl proxy...'
     if [[ ! -d "$WORKSPACE/services/api/log" ]]; then
@@ -658,9 +664,9 @@ do_test() {
             ;;
     esac
     if [[ -z "${skip[$suite]}" && -z "${skip[$1]}" && \
-              (-z "${only}" || "${only}" == "${suite}" || \
-                   "${only}" == "${1}") ||
-                  "${only}" == "${2}" ]]; then
+              (${#only[@]} -eq 0 || ${only[$suite]} -eq 1 || \
+                   ${only[$1]} -eq 1) ||
+                  ${only[$2]} -eq 1 ]]; then
         retry do_test_once ${@}
     else
         title "Skipping ${1} tests"
index 6a1a7318650ceeb0cfd83436b23c55120e759267..eb808e41835bdb3a887758f5e0044cfe03d449c8 100644 (file)
@@ -55,7 +55,8 @@ h2. Create a project for Docker images
 Here we create a default project for the standard Arvados Docker images, and give all users read access to it. The project is owned by the system user.
 
 <notextile>
-<pre><code>~$ <span class="userinput">project_uuid=`arv --format=uuid group create --group "{\"owner_uuid\":\"$prefix-tpzed-000000000000000\", \"name\":\"Arvados Standard Docker Images\"}"`</span>
+<pre><code>~$ <span class="userinput">uuid_prefix=`arv --format=uuid user current | cut -d- -f1`</span>
+~$ <span class="userinput">project_uuid=`arv --format=uuid group create --group "{\"owner_uuid\":\"$uuid_prefix-tpzed-000000000000000\", \"name\":\"Arvados Standard Docker Images\"}"`</span>
 ~$ <span class="userinput">echo "Arvados project uuid is '$project_uuid'"</span>
 ~$ <span class="userinput">read -rd $'\000' newlink &lt;&lt;EOF; arv link create --link "$newlink"</span>
 <span class="userinput">{
index 7f39bf51d2ebafcde977f03890a56d75c49943ee..7fc332177dcf812a1f44f3f5554d9d8583844952 100644 (file)
@@ -345,10 +345,10 @@ h2. Clone Arvados repository
 Here we create a repository object which will be used to set up a hosted clone of the arvados repository on this cluster.
 
 <notextile>
-<pre><code>~$ <span class="userinput">prefix=`arv --format=uuid user current | cut -d- -f1`</span>
-~$ <span class="userinput">echo "Site prefix is '$prefix'"</span>
-~$ <span class="userinput">all_users_group_uuid="$prefix-j7d0g-fffffffffffffff"</span>
-~$ <span class="userinput">repo_uuid=`arv --format=uuid repository create --repository "{\"owner_uuid\":\"$prefix-tpzed-000000000000000\", \"name\":\"arvados\"}"`</span>
+<pre><code>~$ <span class="userinput">uuid_prefix=`arv --format=uuid user current | cut -d- -f1`</span>
+~$ <span class="userinput">echo "Site prefix is '$uuid_prefix'"</span>
+~$ <span class="userinput">all_users_group_uuid="$uuid_prefix-j7d0g-fffffffffffffff"</span>
+~$ <span class="userinput">repo_uuid=`arv --format=uuid repository create --repository "{\"owner_uuid\":\"$uuid_prefix-tpzed-000000000000000\", \"name\":\"arvados\"}"`</span>
 ~$ <span class="userinput">echo "Arvados repository uuid is '$repo_uuid'"</span>
 </code></pre></notextile>
 
index 64a710f9126fe7aa905817b3fb1fae162407a603..943c9bae36b1c7e2358a83f9636bb3eb3ddf3cd3 100644 (file)
@@ -214,8 +214,8 @@ export ARVADOS_API_TOKEN=zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
 Use this command to register each keepstore server you have installed.  Make sure to update the @service_host@ value.
 
 <notextile>
-<pre><code>~$ <span class="userinput">prefix=`arv --format=uuid user current | cut -d- -f1`</span>
-~$ <span class="userinput">echo "Site prefix is '$prefix'"</span>
+<pre><code>~$ <span class="userinput">uuid_prefix=`arv --format=uuid user current | cut -d- -f1`</span>
+~$ <span class="userinput">echo "Site prefix is '$uuid_prefix'"</span>
 ~$ <span class="userinput">read -rd $'\000' keepservice &lt;&lt;EOF; arv keep_service create --keep-service "$keepservice"</span>
 <span class="userinput">{
  "service_host":"<strong>keep0.$uuid_prefix.your.domain</strong>",
index 6f6035b39ee1f1a07e734fdfb4891ee24a8deb43..723b5166865ab6b272dbb885b92f73c009125141 100644 (file)
@@ -30,13 +30,13 @@ Gem::Specification.new do |s|
   s.executables << "arv-crunch-job"
   s.executables << "arv-tag"
   s.required_ruby_version = '>= 2.1.0'
-  s.add_runtime_dependency 'arvados', '~> 1.1.0', '>= 1.1.4'
+  s.add_runtime_dependency 'arvados', '~> 1.2.0', '>= 1.2.0'
   # Our google-api-client dependency used to be < 0.9, but that could be
   # satisfied by the buggy 0.9.pre*.  https://dev.arvados.org/issues/9213
-  s.add_runtime_dependency 'google-api-client', '~> 0.6', '>= 0.6.3', '<0.8.9'
+  s.add_runtime_dependency 'cure-google-api-client', '~> 0.6', '>= 0.6.3', '<0.8.9'
   s.add_runtime_dependency 'activesupport', '>= 3.2.13', '< 5'
   s.add_runtime_dependency 'json', '>= 1.7.7', '<3'
-  s.add_runtime_dependency 'trollop', '~> 2.0'
+  s.add_runtime_dependency 'optimist', '~> 3.0'
   s.add_runtime_dependency 'andand', '~> 1.3', '>= 1.3.3'
   s.add_runtime_dependency 'oj', '~> 3.0'
   s.add_runtime_dependency 'curb', '~> 0.8'
index 9783af202fffd029e5921d99002990eabbb466bb..7110b4b991ab41da1f77fc256ed67b7eadd3daef 100755 (executable)
@@ -35,7 +35,7 @@ begin
   require 'andand'
   require 'curb'
   require 'oj'
-  require 'trollop'
+  require 'optimist'
 rescue LoadError => error
   abort <<-EOS
 
@@ -43,7 +43,7 @@ Error loading gems: #{error}
 
 Please install all required gems:
 
-  gem install arvados activesupport andand curb json oj trollop
+  gem install arvados activesupport andand curb json oj optimist
 
   EOS
 end
@@ -375,7 +375,7 @@ end
 
 def arv_create client, arvados, global_opts, remaining_opts
   types = resource_types(arvados.discovery_document)
-  create_opts = Trollop::options do
+  create_opts = Optimist::options do
     opt :project_uuid, "Project uuid in which to create the object", :type => :string
     stop_on resource_types(arvados.discovery_document)
   end
@@ -392,7 +392,7 @@ def arv_create client, arvados, global_opts, remaining_opts
   rsc = rsc.first
 
   discovered_params = arvados.discovery_document["resources"][rsc]["methods"]["create"]["parameters"]
-  method_opts = Trollop::options do
+  method_opts = Optimist::options do
     banner head_banner
     banner "Usage: arv create [--project-uuid] #{object_type} [create parameters]"
     banner ""
@@ -402,7 +402,7 @@ def arv_create client, arvados, global_opts, remaining_opts
       opts = Hash.new()
       opts[:type] = v["type"].to_sym if v.include?("type")
       if [:datetime, :text, :object, :array].index opts[:type]
-        opts[:type] = :string                       # else trollop bork
+        opts[:type] = :string                       # else optimist bork
       end
       opts[:default] = v["default"] if v.include?("default")
       opts[:default] = v["default"].to_i if opts[:type] == :integer
@@ -483,7 +483,7 @@ end
 def parse_arguments(discovery_document, subcommands)
   resources_and_subcommands = resource_types(discovery_document) + subcommands
 
-  option_parser = Trollop::Parser.new do
+  option_parser = Optimist::Parser.new do
     version __FILE__
     banner head_banner
     banner "Usage: arv [--flags] subcommand|resource [method] [--parameters]"
@@ -513,7 +513,7 @@ def parse_arguments(discovery_document, subcommands)
     stop_on resources_and_subcommands
   end
 
-  global_opts = Trollop::with_standard_exception_handling option_parser do
+  global_opts = Optimist::with_standard_exception_handling option_parser do
     o = option_parser.parse ARGV
   end
 
@@ -544,7 +544,7 @@ def parse_arguments(discovery_document, subcommands)
     discovered_params = discovery_document\
     ["resources"][resource.pluralize]\
     ["methods"][method]["parameters"]
-    method_opts = Trollop::options do
+    method_opts = Optimist::options do
       banner head_banner
       banner "Usage: arv #{resource} #{method} [--parameters]"
       banner ""
@@ -554,7 +554,7 @@ def parse_arguments(discovery_document, subcommands)
         opts = Hash.new()
         opts[:type] = v["type"].to_sym if v.include?("type")
         if [:datetime, :text, :object, :array].index opts[:type]
-          opts[:type] = :string                       # else trollop bork
+          opts[:type] = :string                       # else optimist bork
         end
         opts[:default] = v["default"] if v.include?("default")
         opts[:default] = v["default"].to_i if opts[:type] == :integer
@@ -672,7 +672,7 @@ if resource_body
   elsif resource_body_is_readable_file
     resource_body = resource_body_file.read()
     begin
-      # we don't actually need the results of the parsing, 
+      # we don't actually need the results of the parsing,
       # just checking for the JSON::ParserError exception
       JSON.parse resource_body
     rescue JSON::ParserError => e
index b66e9c0526e3a9b7926b381d9fee7ec8cbb6b901..336b1a2c74500b7125fec392717dd1c557e5f2bf 100755 (executable)
@@ -17,14 +17,14 @@ begin
   require 'rubygems'
   require 'json'
   require 'pp'
-  require 'trollop'
+  require 'optimist'
   require 'google/api_client'
 rescue LoadError => l
   $stderr.puts $:
   abort <<-EOS
 #{$0}: fatal: #{l.message}
 Some runtime dependencies may be missing.
-Try: gem install arvados pp google-api-client json trollop
+Try: gem install arvados pp google-api-client json optimist
   EOS
 end
 
@@ -35,7 +35,7 @@ end
 # Parse command line options (the kind that control the behavior of
 # this program, that is, not the pipeline component parameters).
 
-p = Trollop::Parser.new do
+p = Optimist::Parser.new do
   version __FILE__
   banner(<<EOF)
 
@@ -122,7 +122,7 @@ EOF
       type: :string)
   stop_on [:'--']
 end
-$options = Trollop::with_standard_exception_handling p do
+$options = Optimist::with_standard_exception_handling p do
   p.parse ARGV
 end
 $debuglevel = $options[:debug_level] || ($options[:debug] && 1) || 0
index b1783bccf3f277cd705b5012b382182cb3e6b3ad..f709020fc75e91a3449adceabfebd31e02dca13d 100755 (executable)
@@ -113,11 +113,11 @@ begin
   require 'json'
   require 'pp'
   require 'oj'
-  require 'trollop'
+  require 'optimist'
 rescue LoadError
   abort <<-EOS
 #{$0}: fatal: some runtime dependencies are missing.
-Try: gem install pp google-api-client json trollop
+Try: gem install pp google-api-client json optimist
   EOS
 end
 
@@ -156,7 +156,7 @@ class Google::APIClient
   end
 end
 
-global_opts = Trollop::options do
+global_opts = Optimist::options do
   banner usage_string
   banner ""
   opt :dry_run, "Don't actually do anything", :short => "-n"
@@ -169,7 +169,7 @@ global_opts = Trollop::options do
   stop_on ['add', 'remove']
 end
 
-p = Trollop::Parser.new do
+p = Optimist::Parser.new do
   opt(:all,
       "Remove this tag from all objects under your ownership. Only valid with `tag remove'.",
       :short => :none)
@@ -180,7 +180,7 @@ p = Trollop::Parser.new do
       :short => :o)
 end
 
-$options = Trollop::with_standard_exception_handling p do
+$options = Optimist::with_standard_exception_handling p do
   p.parse ARGV
 end
 
index e452ce26440da32cdf3732cdc8f43f271600b432..2b7b31b9f3f4b4070cbd14d986ffe87259989200 100644 (file)
@@ -36,7 +36,9 @@ setup(name='arvados-cwl-runner',
           'cwltool==1.0.20180806194258',
           'schema-salad==2.7.20180719125426',
           'typing >= 3.6.4',
-          'ruamel.yaml >=0.13.11, <0.16',
+          # Need to limit ruamel.yaml version to 0.15.26 because of bug
+          # https://bitbucket.org/ruamel/yaml/issues/227/regression-parsing-flow-mapping
+          'ruamel.yaml >=0.13.11, <= 0.15.26',
           'arvados-python-client>=1.1.4.20180607143841',
           'setuptools',
           'ciso8601 >=1.0.6, <2.0.0',
index 3f8a32816ddccdad01c78eedfdce1ed0b2be5e64..69f3ae046e31ca3e02aa52be7967e43da2394d00 100644 (file)
@@ -5,6 +5,7 @@
 import arvados_cwl
 import arvados_cwl.context
 from arvados_cwl.arvdocker import arv_docker_clear_cache
+import arvados.config
 import logging
 import mock
 import unittest
@@ -21,6 +22,32 @@ if not os.getenv('ARVADOS_DEBUG'):
     logging.getLogger('arvados.cwl-runner').setLevel(logging.WARN)
     logging.getLogger('arvados.arv-run').setLevel(logging.WARN)
 
+class CollectionMock(object):
+    def __init__(self, vwdmock, *args, **kwargs):
+        self.vwdmock = vwdmock
+        self.count = 0
+
+    def open(self, *args, **kwargs):
+        self.count += 1
+        return self.vwdmock.open(*args, **kwargs)
+
+    def copy(self, *args, **kwargs):
+        self.count += 1
+        self.vwdmock.copy(*args, **kwargs)
+
+    def save_new(self, *args, **kwargs):
+        pass
+
+    def __len__(self):
+        return self.count
+
+    def portable_data_hash(self):
+        if self.count == 0:
+            return arvados.config.EMPTY_BLOCK_LOCATOR
+        else:
+            return "99999999999999999999999999999996+99"
+
+
 class TestContainer(unittest.TestCase):
 
     def helper(self, runner, enable_reuse=True):
@@ -231,8 +258,7 @@ class TestContainer(unittest.TestCase):
         runner.fs_access.get_collection.side_effect = get_collection_mock
 
         vwdmock = mock.MagicMock()
-        collection_mock.return_value = vwdmock
-        vwdmock.portable_data_hash.return_value = "99999999999999999999999999999996+99"
+        collection_mock.side_effect = lambda *args, **kwargs: CollectionMock(vwdmock, *args, **kwargs)
 
         tool = cmap({
             "inputs": [],
index 4473b88ca0d785dbb2eaff961bf64fd21c25c280..20efe1513981585b3c699f73d0dbba6994f7c682 100644 (file)
@@ -19,6 +19,7 @@ from schema_salad.ref_resolver import Loader
 from schema_salad.sourceline import cmap
 from .mock_discovery import get_rootDesc
 from .matcher import JsonDiffMatcher, StripYAMLComments
+from .test_container import CollectionMock
 
 if not os.getenv('ARVADOS_DEBUG'):
     logging.getLogger('arvados.cwl-runner').setLevel(logging.WARN)
@@ -388,7 +389,8 @@ class TestWorkflow(unittest.TestCase):
         tool, metadata = loadingContext.loader.resolve_ref("tests/wf/scatter2.cwl")
         metadata["cwlVersion"] = tool["cwlVersion"]
 
-        mockcollection().portable_data_hash.return_value = "99999999999999999999999999999999+118"
+        mockc = mock.MagicMock()
+        mockcollection.side_effect = lambda *args, **kwargs: CollectionMock(mockc, *args, **kwargs)
         mockcollectionreader().find.return_value = arvados.arvfile.ArvadosFile(mock.MagicMock(), "token.txt")
 
         arvtool = arvados_cwl.ArvadosWorkflow(runner, tool, loadingContext)
@@ -412,8 +414,8 @@ class TestWorkflow(unittest.TestCase):
                         'HOME': '$(task.outdir)',
                         'TMPDIR': '$(task.tmpdir)'},
                                'task.vwd': {
-                                   'workflow.cwl': '$(task.keep)/99999999999999999999999999999999+118/workflow.cwl',
-                                   'cwl.input.yml': '$(task.keep)/99999999999999999999999999999999+118/cwl.input.yml'
+                                   'workflow.cwl': '$(task.keep)/99999999999999999999999999999996+99/workflow.cwl',
+                                   'cwl.input.yml': '$(task.keep)/99999999999999999999999999999996+99/cwl.input.yml'
                                },
                     'command': [u'cwltool', u'--no-container', u'--move-outputs', u'--preserve-entire-environment', u'workflow.cwl#main', u'cwl.input.yml'],
                     'task.stdout': 'cwl.output.json'}]},
@@ -430,8 +432,8 @@ class TestWorkflow(unittest.TestCase):
                      ['docker_image_locator', 'in docker', 'arvados/jobs']],
             find_or_create=True)
 
-        mockcollection().open().__enter__().write.assert_has_calls([mock.call(subwf)])
-        mockcollection().open().__enter__().write.assert_has_calls([mock.call(
+        mockc.open().__enter__().write.assert_has_calls([mock.call(subwf)])
+        mockc.open().__enter__().write.assert_has_calls([mock.call(
 '''{
   "fileblub": {
     "basename": "token.txt",
@@ -469,7 +471,7 @@ class TestWorkflow(unittest.TestCase):
         tool, metadata = loadingContext.loader.resolve_ref("tests/wf/echo-wf.cwl")
         metadata["cwlVersion"] = tool["cwlVersion"]
 
-        mockcollection().portable_data_hash.return_value = "99999999999999999999999999999999+118"
+        mockcollection.side_effect = lambda *args, **kwargs: CollectionMock(mock.MagicMock(), *args, **kwargs)
 
         arvtool = arvados_cwl.ArvadosWorkflow(runner, tool, loadingContext)
         arvtool.formatgraph = None
@@ -491,8 +493,8 @@ class TestWorkflow(unittest.TestCase):
                         'HOME': '$(task.outdir)',
                         'TMPDIR': '$(task.tmpdir)'},
                                'task.vwd': {
-                                   'workflow.cwl': '$(task.keep)/99999999999999999999999999999999+118/workflow.cwl',
-                                   'cwl.input.yml': '$(task.keep)/99999999999999999999999999999999+118/cwl.input.yml'
+                                   'workflow.cwl': '$(task.keep)/99999999999999999999999999999996+99/workflow.cwl',
+                                   'cwl.input.yml': '$(task.keep)/99999999999999999999999999999996+99/cwl.input.yml'
                                },
                     'command': [u'cwltool', u'--no-container', u'--move-outputs', u'--preserve-entire-environment', u'workflow.cwl#main', u'cwl.input.yml'],
                     'task.stdout': 'cwl.output.json'}]},
index d980db575dd8d6e3db1ac3dbb0f7709cb14a894e..8875b7d954d916e332175b5dbdd67103833719b1 100644 (file)
@@ -289,14 +289,14 @@ class TestSubmit(unittest.TestCase):
                 'manifest_text':
                 '. 5bcc9fe8f8d5992e6cf418dc7ce4dbb3+16 0:16:blub.txt\n',
                 'replication_desired': None,
-                'name': 'submit_tool.cwl dependencies',
-            }), ensure_unique_name=True),
+                'name': 'submit_tool.cwl dependencies (5d373e7629203ce39e7c22af98a0f881+52)',
+            }), ensure_unique_name=False),
             mock.call(body=JsonDiffMatcher({
                 'manifest_text':
                 '. 979af1245a12a1fed634d4222473bfdc+16 0:16:blorp.txt\n',
                 'replication_desired': None,
-                'name': 'submit_wf.cwl input',
-            }), ensure_unique_name=True),
+                'name': 'submit_wf.cwl input (169f39d466a5438ac4a90e779bf750c7+53)',
+            }), ensure_unique_name=False),
             mock.call(body=JsonDiffMatcher({
                 'manifest_text':
                 '. 61df2ed9ee3eb7dd9b799e5ca35305fa+1217 0:1217:workflow.cwl\n',
@@ -485,14 +485,14 @@ class TestSubmit(unittest.TestCase):
                 'manifest_text':
                 '. 5bcc9fe8f8d5992e6cf418dc7ce4dbb3+16 0:16:blub.txt\n',
                 'replication_desired': None,
-                'name': 'submit_tool.cwl dependencies',
-            }), ensure_unique_name=True),
+                'name': 'submit_tool.cwl dependencies (5d373e7629203ce39e7c22af98a0f881+52)',
+            }), ensure_unique_name=False),
             mock.call(body=JsonDiffMatcher({
                 'manifest_text':
                 '. 979af1245a12a1fed634d4222473bfdc+16 0:16:blorp.txt\n',
                 'replication_desired': None,
-                'name': 'submit_wf.cwl input',
-            }), ensure_unique_name=True)])
+                'name': 'submit_wf.cwl input (169f39d466a5438ac4a90e779bf750c7+53)',
+            }), ensure_unique_name=False)])
 
         expect_container = copy.deepcopy(stubs.expect_container_spec)
         stubs.api.container_requests().create.assert_called_with(
index 91da5a3fd62ce6eb099e4ce0c0e206a1220268ae..e3a9f4ae8d892ea03f379e7dad3ded4a6dc951fc 100644 (file)
@@ -173,8 +173,11 @@ func New(c *arvados.Client) (*ArvadosClient, error) {
                ApiServer:   c.APIHost,
                ApiToken:    c.AuthToken,
                ApiInsecure: c.Insecure,
-               Client: &http.Client{Transport: &http.Transport{
-                       TLSClientConfig: MakeTLSConfig(c.Insecure)}},
+               Client: &http.Client{
+                       Timeout: 5 * time.Minute,
+                       Transport: &http.Transport{
+                               TLSClientConfig: MakeTLSConfig(c.Insecure)},
+               },
                External:          false,
                Retries:           2,
                KeepServiceURIs:   c.KeepServiceURIs,
index 4e25ba4f0603699569402d619127dd4b9fd99fb1..c8fb5aeb37e97eb9a43846301e2a07ea63e28ae7 100644 (file)
@@ -9,12 +9,12 @@ package dispatch
 import (
        "context"
        "fmt"
-       "log"
        "sync"
        "time"
 
        "git.curoverse.com/arvados.git/sdk/go/arvados"
        "git.curoverse.com/arvados.git/sdk/go/arvadosclient"
+       "github.com/Sirupsen/logrus"
 )
 
 const (
@@ -25,10 +25,18 @@ const (
        Cancelled = arvados.ContainerStateCancelled
 )
 
+type Logger interface {
+       Printf(string, ...interface{})
+       Warnf(string, ...interface{})
+       Debugf(string, ...interface{})
+}
+
 // Dispatcher struct
 type Dispatcher struct {
        Arv *arvadosclient.ArvadosClient
 
+       Logger Logger
+
        // Batch size for container queries
        BatchSize int64
 
@@ -65,6 +73,10 @@ type DispatchFunc func(*Dispatcher, arvados.Container, <-chan arvados.Container)
 // dispatcher's token. When a new one appears, Run calls RunContainer
 // in a new goroutine.
 func (d *Dispatcher) Run(ctx context.Context) error {
+       if d.Logger == nil {
+               d.Logger = logrus.StandardLogger()
+       }
+
        err := d.Arv.Call("GET", "api_client_authorizations", "", "current", nil, &d.auth)
        if err != nil {
                return fmt.Errorf("error getting my token UUID: %v", err)
@@ -142,7 +154,7 @@ func (d *Dispatcher) Run(ctx context.Context) error {
                // Containers that I know about that didn't show up in any
                // query should be let go.
                for uuid, tracker := range todo {
-                       log.Printf("Container %q not returned by any query, stopping tracking.", uuid)
+                       d.Logger.Printf("Container %q not returned by any query, stopping tracking.", uuid)
                        tracker.close()
                }
 
@@ -152,7 +164,10 @@ func (d *Dispatcher) Run(ctx context.Context) error {
 // Start a runner in a new goroutine, and send the initial container
 // record to its updates channel.
 func (d *Dispatcher) start(c arvados.Container) *runTracker {
-       tracker := &runTracker{updates: make(chan arvados.Container, 1)}
+       tracker := &runTracker{
+               updates: make(chan arvados.Container, 1),
+               logger:  d.Logger,
+       }
        tracker.updates <- c
        go func() {
                d.RunContainer(d, c, tracker.updates)
@@ -174,7 +189,7 @@ func (d *Dispatcher) checkForUpdates(filters [][]interface{}, todo map[string]*r
                "order":   []string{"priority desc"}}
        err := d.Arv.List("containers", params, &countList)
        if err != nil {
-               log.Printf("error getting count of containers: %q", err)
+               d.Logger.Warnf("error getting count of containers: %q", err)
                return false
        }
        itemsAvailable := countList.ItemsAvailable
@@ -195,7 +210,7 @@ func (d *Dispatcher) checkForUpdates(filters [][]interface{}, todo map[string]*r
 
                err := d.Arv.List("containers", params, &list)
                if err != nil {
-                       log.Printf("Error getting list of containers: %q", err)
+                       d.Logger.Warnf("error getting list of containers: %q", err)
                        return false
                }
                d.checkListForUpdates(list.Items, todo)
@@ -218,7 +233,7 @@ func (d *Dispatcher) checkListForUpdates(containers []arvados.Container, todo ma
                delete(todo, c.UUID)
 
                if c.LockedByUUID != "" && c.LockedByUUID != d.auth.UUID {
-                       log.Printf("debug: ignoring %s locked by %s", c.UUID, c.LockedByUUID)
+                       d.Logger.Debugf("ignoring %s locked by %s", c.UUID, c.LockedByUUID)
                } else if alreadyTracking {
                        switch c.State {
                        case Queued:
@@ -236,7 +251,7 @@ func (d *Dispatcher) checkListForUpdates(containers []arvados.Container, todo ma
                                }
                                err := d.lock(c.UUID)
                                if err != nil {
-                                       log.Printf("debug: error locking container %s: %s", c.UUID, err)
+                                       d.Logger.Warnf("error locking container %s: %s", c.UUID, err)
                                        break
                                }
                                c.State = Locked
@@ -260,7 +275,7 @@ func (d *Dispatcher) UpdateState(uuid string, state arvados.ContainerState) erro
                        "container": arvadosclient.Dict{"state": state},
                }, nil)
        if err != nil {
-               log.Printf("Error updating container %s to state %q: %s", uuid, state, err)
+               d.Logger.Warnf("error updating container %s to state %q: %s", uuid, state, err)
        }
        return err
 }
@@ -315,6 +330,7 @@ func (d *Dispatcher) TrackContainer(uuid string) error {
 type runTracker struct {
        closing bool
        updates chan arvados.Container
+       logger  Logger
 }
 
 func (tracker *runTracker) close() {
@@ -330,7 +346,7 @@ func (tracker *runTracker) update(c arvados.Container) {
        }
        select {
        case <-tracker.updates:
-               log.Printf("debug: runner is handling updates slowly, discarded previous update for %s", c.UUID)
+               tracker.logger.Debugf("runner is handling updates slowly, discarded previous update for %s", c.UUID)
        default:
        }
        tracker.updates <- c
index c4748fa995759ef0cc934b699a14523f8a3181f8..96f5bdd44a12ae42c25fbe64f68b342cb0356fcf 100644 (file)
@@ -1,6 +1,19 @@
 # Copyright (C) The Arvados Authors. All rights reserved.
+# Copyright (C) 2018 Genome Research Ltd.
 #
 # SPDX-License-Identifier: Apache-2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
 
 from __future__ import print_function
 from __future__ import absolute_import
@@ -22,6 +35,7 @@ import sys
 import errno
 import arvados.commands._util as arv_cmd
 import arvados.collection
+import arvados.config as config
 
 from arvados._version import __version__
 
@@ -207,22 +221,48 @@ def uploadfiles(files, api, dry_run=False, num_retries=0,
                     for src in iterfiles:
                         write_file(collection, pathprefix, os.path.join(root, src), not packed)
 
-        filters=[["portable_data_hash", "=", collection.portable_data_hash()]]
-        if name:
-            filters.append(["name", "like", name+"%"])
-        if project:
-            filters.append(["owner_uuid", "=", project])
-
-        exists = api.collections().list(filters=filters, limit=1).execute(num_retries=num_retries)
-
-        if exists["items"]:
-            item = exists["items"][0]
-            pdh = item["portable_data_hash"]
-            logger.info("Using collection %s (%s)", pdh, item["uuid"])
-        elif len(collection) > 0:
-            collection.save_new(name=name, owner_uuid=project, ensure_unique_name=True)
+        pdh = None
+        if len(collection) > 0:
+            # non-empty collection
+            filters = [["portable_data_hash", "=", collection.portable_data_hash()]]
+            name_pdh = "%s (%s)" % (name, collection.portable_data_hash())
+            if name:
+                filters.append(["name", "=", name_pdh])
+            if project:
+                filters.append(["owner_uuid", "=", project])
+
+            # do the list / create in a loop with up to 2 tries as we are using `ensure_unique_name=False`
+            # and there is a potential race with other workflows that may have created the collection
+            # between when we list it and find it does not exist and when we attempt to create it.
+            tries = 2
+            while pdh is None and tries > 0:
+                exists = api.collections().list(filters=filters, limit=1).execute(num_retries=num_retries)
+
+                if exists["items"]:
+                    item = exists["items"][0]
+                    pdh = item["portable_data_hash"]
+                    logger.info("Using collection %s (%s)", pdh, item["uuid"])
+                else:
+                    try:
+                        collection.save_new(name=name_pdh, owner_uuid=project, ensure_unique_name=False)
+                        pdh = collection.portable_data_hash()
+                        logger.info("Uploaded to %s (%s)", pdh, collection.manifest_locator())
+                    except arvados.errors.ApiError as ae:
+                        tries -= 1
+            if pdh is None:
+                # Something weird going on here, probably a collection
+                # with a conflicting name but wrong PDH.  We won't
+                # able to reuse it but we still need to save our
+                # collection, so so save it with unique name.
+                logger.info("Name conflict on '%s', existing collection has an unexpected portable data hash", name_pdh)
+                collection.save_new(name=name_pdh, owner_uuid=project, ensure_unique_name=True)
+                pdh = collection.portable_data_hash()
+                logger.info("Uploaded to %s (%s)", pdh, collection.manifest_locator())
+        else:
+            # empty collection
             pdh = collection.portable_data_hash()
-            logger.info("Uploaded to %s (%s)", pdh, collection.manifest_locator())
+            assert (pdh == config.EMPTY_BLOCK_LOCATOR), "Empty collection portable_data_hash did not have expected locator, was %s" % pdh
+            logger.info("Using empty collection %s", pdh)
 
     for c in files:
         c.keepref = "%s/%s" % (pdh, c.fn)
index f748d52179b2d95f665027eea48dfa5c607fa0d7..8f576196bc4cd623076ed59c4166e4f40a48f369 100644 (file)
@@ -51,7 +51,7 @@ setup(name='arvados-python-client',
           'google-api-python-client >=1.6.2, <1.7',
           'httplib2 >=0.9.2',
           'pycurl >=7.19.5.1',
-          'ruamel.yaml >=0.13.11, <0.16',
+          'ruamel.yaml >=0.13.11, <= 0.15.26',
           'setuptools',
           'ws4py >=0.4.2',
           'subprocess32 >=3.5.1',
index 8df95553d49e825db63286d9125077b6c53682a6..7b1f6059aeef07b8ff2a2d03a6d4980f9d5a835f 100644 (file)
@@ -413,6 +413,7 @@ def run_controller():
         f.write("""
 Clusters:
   zzzzz:
+    HTTPRequestTimeout: 30s
     PostgreSQL:
       ConnectionPool: 32
       Connection:
index e39c4263177b8ed4f290c17cb744c309725c56bc..609af6e23dda07b2467f6cc78dfe3f69ae00bb65 100644 (file)
@@ -29,7 +29,7 @@ Gem::Specification.new do |s|
   s.add_dependency('andand', '~> 1.3', '>= 1.3.3')
   # Our google-api-client dependency used to be < 0.9, but that could be
   # satisfied by the buggy 0.9.pre*.  https://dev.arvados.org/issues/9213
-  s.add_dependency('google-api-client', '>= 0.7', '< 0.8.9')
+  s.add_dependency('cure-google-api-client', '>= 0.7', '< 0.8.9')
   # work around undeclared dependency on i18n in some activesupport 3.x.x:
   s.add_dependency('i18n', '~> 0')
   s.add_dependency('json', '>= 1.7.7', '<3')
index b9edeae06ecf93f0a1b6014eef0772224deed1a1..e43978980125a0fc91b22259ba34d8bb96963c13 100644 (file)
@@ -596,16 +596,24 @@ class ArvadosModel < ActiveRecord::Base
     end
   end
 
-  def self.where_serialized(colname, value)
+  def self.where_serialized(colname, value, md5: false)
+    colsql = colname.to_s
+    if md5
+      colsql = "md5(#{colsql})"
+    end
     if value.empty?
       # rails4 stores as null, rails3 stored as serialized [] or {}
-      sql = "#{colname.to_s} is null or #{colname.to_s} IN (?)"
+      sql = "#{colsql} is null or #{colsql} IN (?)"
       sorted = value
     else
-      sql = "#{colname.to_s} IN (?)"
+      sql = "#{colsql} IN (?)"
       sorted = deep_sort_hash(value)
     end
-    where(sql, [sorted.to_yaml, SafeJSON.dump(sorted)])
+    params = [sorted.to_yaml, SafeJSON.dump(sorted)]
+    if md5
+      params = params.map { |x| Digest::MD5.hexdigest(x) }
+    end
+    where(sql, params)
   end
 
   Serializer = {
index 7ec9845bc1983c0819f4d801e5044d8e5765f00f..7176bda926d8aa1cdb0c499958ae4ff6ffc97850 100644 (file)
@@ -228,13 +228,13 @@ class Container < ArvadosModel
 
   def self.find_reusable(attrs)
     log_reuse_info { "starting with #{Container.all.count} container records in database" }
-    candidates = Container.where_serialized(:command, attrs[:command])
+    candidates = Container.where_serialized(:command, attrs[:command], md5: true)
     log_reuse_info(candidates) { "after filtering on command #{attrs[:command].inspect}" }
 
     candidates = candidates.where('cwd = ?', attrs[:cwd])
     log_reuse_info(candidates) { "after filtering on cwd #{attrs[:cwd].inspect}" }
 
-    candidates = candidates.where_serialized(:environment, attrs[:environment])
+    candidates = candidates.where_serialized(:environment, attrs[:environment], md5: true)
     log_reuse_info(candidates) { "after filtering on environment #{attrs[:environment].inspect}" }
 
     candidates = candidates.where('output_path = ?', attrs[:output_path])
@@ -244,13 +244,14 @@ class Container < ArvadosModel
     candidates = candidates.where('container_image = ?', image)
     log_reuse_info(candidates) { "after filtering on container_image #{image.inspect} (resolved from #{attrs[:container_image].inspect})" }
 
-    candidates = candidates.where_serialized(:mounts, resolve_mounts(attrs[:mounts]))
+    candidates = candidates.where_serialized(:mounts, resolve_mounts(attrs[:mounts]), md5: true)
     log_reuse_info(candidates) { "after filtering on mounts #{attrs[:mounts].inspect}" }
 
-    candidates = candidates.where('secret_mounts_md5 = ?', Digest::MD5.hexdigest(SafeJSON.dump(self.deep_sort_hash(attrs[:secret_mounts]))))
-    log_reuse_info(candidates) { "after filtering on mounts #{attrs[:mounts].inspect}" }
+    secret_mounts_md5 = Digest::MD5.hexdigest(SafeJSON.dump(self.deep_sort_hash(attrs[:secret_mounts])))
+    candidates = candidates.where('secret_mounts_md5 = ?', secret_mounts_md5)
+    log_reuse_info(candidates) { "after filtering on secret_mounts_md5 #{secret_mounts_md5.inspect}" }
 
-    candidates = candidates.where_serialized(:runtime_constraints, resolve_runtime_constraints(attrs[:runtime_constraints]))
+    candidates = candidates.where_serialized(:runtime_constraints, resolve_runtime_constraints(attrs[:runtime_constraints]), md5: true)
     log_reuse_info(candidates) { "after filtering on runtime_constraints #{attrs[:runtime_constraints].inspect}" }
 
     log_reuse_info { "checking for state=Complete with readable output and log..." }
index c434ee031773f598b66268bddc434e02aca550a8..470388a7c7f6786662b4661a454686d9d48e0d15 100644 (file)
@@ -359,7 +359,13 @@ class ContainerRequest < ArvadosModel
     c = get_requesting_container()
     if !c.nil?
       self.requesting_container_uuid = c.uuid
-      self.priority = c.priority>0 ? 1 : 0
+      # Determine the priority of container request for the requesting
+      # container.
+      self.priority = ContainerRequest.
+            where('container_uuid=? and priority>0', self.requesting_container_uuid).
+            map do |cr|
+        cr.priority
+      end.max || 0
     end
   end
 
diff --git a/services/api/db/migrate/20180820132617_add_lock_index_to_containers.rb b/services/api/db/migrate/20180820132617_add_lock_index_to_containers.rb
new file mode 100644 (file)
index 0000000..94ca100
--- /dev/null
@@ -0,0 +1,13 @@
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: AGPL-3.0
+
+class AddLockIndexToContainers < ActiveRecord::Migration
+  def change
+    # For the current code in sdk/go/dispatch:
+    add_index :containers, [:locked_by_uuid, :priority]
+    # For future dispatchers that use filters instead of offset for
+    # more predictable paging:
+    add_index :containers, [:locked_by_uuid, :uuid]
+  end
+end
diff --git a/services/api/db/migrate/20180824152014_add_md5_index_to_containers.rb b/services/api/db/migrate/20180824152014_add_md5_index_to_containers.rb
new file mode 100644 (file)
index 0000000..a58932e
--- /dev/null
@@ -0,0 +1,8 @@
+class AddMd5IndexToContainers < ActiveRecord::Migration
+  def up
+    ActiveRecord::Base.connection.execute 'CREATE INDEX index_containers_on_reuse_columns on containers (md5(command), cwd, md5(environment), output_path, container_image, md5(mounts), secret_mounts_md5, md5(runtime_constraints))'
+  end
+  def down
+    ActiveRecord::Base.connection.execute 'DROP INDEX index_containers_on_reuse_columns'
+  end
+end
diff --git a/services/api/db/migrate/20180824155207_add_queue_index_to_containers.rb b/services/api/db/migrate/20180824155207_add_queue_index_to_containers.rb
new file mode 100644 (file)
index 0000000..7245108
--- /dev/null
@@ -0,0 +1,12 @@
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: AGPL-3.0
+
+class AddQueueIndexToContainers < ActiveRecord::Migration
+  def up
+    ActiveRecord::Base.connection.execute 'CREATE INDEX index_containers_on_queued_state on containers (state, (priority > 0))'
+  end
+  def down
+    ActiveRecord::Base.connection.execute 'DROP INDEX index_containers_on_queued_state'
+  end
+end
index d7ee1532d0f3807338421824e4564dd35ec4ada8..32b77ed17aa0a4b511fafb50dd04c7d5f45371fa 100644 (file)
@@ -1899,6 +1899,20 @@ CREATE UNIQUE INDEX index_container_requests_on_uuid ON public.container_request
 CREATE INDEX index_containers_on_auth_uuid ON public.containers USING btree (auth_uuid);
 
 
+--
+-- Name: index_containers_on_locked_by_uuid_and_priority; Type: INDEX; Schema: public; Owner: -
+--
+
+CREATE INDEX index_containers_on_locked_by_uuid_and_priority ON public.containers USING btree (locked_by_uuid, priority);
+
+
+--
+-- Name: index_containers_on_locked_by_uuid_and_uuid; Type: INDEX; Schema: public; Owner: -
+--
+
+CREATE INDEX index_containers_on_locked_by_uuid_and_uuid ON public.containers USING btree (locked_by_uuid, uuid);
+
+
 --
 -- Name: index_containers_on_modified_at_uuid; Type: INDEX; Schema: public; Owner: -
 --
@@ -1913,6 +1927,20 @@ CREATE INDEX index_containers_on_modified_at_uuid ON public.containers USING btr
 CREATE INDEX index_containers_on_owner_uuid ON public.containers USING btree (owner_uuid);
 
 
+--
+-- Name: index_containers_on_queued_state; Type: INDEX; Schema: public; Owner: -
+--
+
+CREATE INDEX index_containers_on_queued_state ON public.containers USING btree (state, ((priority > 0)));
+
+
+--
+-- Name: index_containers_on_reuse_columns; Type: INDEX; Schema: public; Owner: -
+--
+
+CREATE INDEX index_containers_on_reuse_columns ON public.containers USING btree (md5(command), cwd, md5(environment), output_path, container_image, md5(mounts), secret_mounts_md5, md5(runtime_constraints));
+
+
 --
 -- Name: index_containers_on_secret_mounts_md5; Type: INDEX; Schema: public; Owner: -
 --
@@ -3123,5 +3151,11 @@ INSERT INTO schema_migrations (version) VALUES ('20180806133039');
 
 INSERT INTO schema_migrations (version) VALUES ('20180820130357');
 
+INSERT INTO schema_migrations (version) VALUES ('20180820132617');
+
 INSERT INTO schema_migrations (version) VALUES ('20180820135808');
 
+INSERT INTO schema_migrations (version) VALUES ('20180824152014');
+
+INSERT INTO schema_migrations (version) VALUES ('20180824155207');
+
index 21674d44c7cdcf8c7482b6673c7240297ff6e32c..5d3531eead8fb5a90c7ef4b7ef750a937da6ee90 100644 (file)
@@ -26,7 +26,7 @@ running:
   owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz
   name: running
   state: Committed
-  priority: 1
+  priority: 501
   created_at: <%= 2.minute.ago.to_s(:db) %>
   updated_at: <%= 1.minute.ago.to_s(:db) %>
   modified_at: <%= 1.minute.ago.to_s(:db) %>
index 4506f76c6dd56655fb15c03677f0fddc26efb18e..05bcec2e268f44c9a83bf754b3a51a3796c96b9b 100644 (file)
@@ -116,6 +116,25 @@ class Arvados::V1::GroupsControllerTest < ActionController::TestCase
     end
   end
 
+  test "list trashed collections and projects" do
+    authorize_with :active
+    get(:contents, {
+          format: :json,
+          include_trash: true,
+          filters: [
+            ['uuid', 'is_a', ['arvados#collection', 'arvados#group']],
+            ['is_trashed', '=', true],
+          ],
+          limit: 10000,
+        })
+    assert_response :success
+    found_uuids = json_response['items'].collect { |i| i['uuid'] }
+    assert_includes found_uuids, groups(:trashed_project).uuid
+    refute_includes found_uuids, groups(:aproject).uuid
+    assert_includes found_uuids, collections(:expired_collection).uuid
+    refute_includes found_uuids, collections(:w_a_z_file).uuid
+  end
+
   test "list objects in home project" do
     authorize_with :active
     get :contents, {
@@ -194,25 +213,6 @@ class Arvados::V1::GroupsControllerTest < ActionController::TestCase
     assert actually_checked_anything, "Didn't even find two items to compare."
   end
 
-  test 'list objects across multiple projects' do
-    authorize_with :project_viewer
-    get :contents, {
-      format: :json,
-      filters: [['uuid', 'is_a', 'arvados#specimen']]
-    }
-    assert_response :success
-    found_uuids = json_response['items'].collect { |i| i['uuid'] }
-    [[:in_aproject, true],
-     [:in_asubproject, true],
-     [:owned_by_private_group, false]].each do |specimen_fixture, should_find|
-      if should_find
-        assert_includes found_uuids, specimens(specimen_fixture).uuid, "did not find specimen fixture '#{specimen_fixture}'"
-      else
-        refute_includes found_uuids, specimens(specimen_fixture).uuid, "found specimen fixture '#{specimen_fixture}'"
-      end
-    end
-  end
-
   # Even though the project_viewer tests go through other controllers,
   # I'm putting them here so they're easy to find alongside the other
   # project tests.
index 0a3b9b285e8011e533663033e4349800c128722d..81b49ff4fcce525b5e7fba88ff0c6f78087e7686 100644 (file)
@@ -379,7 +379,7 @@ class ContainerRequestTest < ActiveSupport::TestCase
   end
 
   [
-    ['running_container_auth', 'zzzzz-dz642-runningcontainr', 1],
+    ['running_container_auth', 'zzzzz-dz642-runningcontainr', 501],
     ['active_no_prefs', nil, 0],
   ].each do |token, expected, expected_priority|
     test "create as #{token} and expect requesting_container_uuid to be #{expected}" do
index 279327ba18811ba8ad6339600cc124460f2fc35c..fc10393626be103c17b01b5b1bfde615ed470bc9 100644 (file)
@@ -10,7 +10,6 @@ import (
        "context"
        "flag"
        "fmt"
-       "log"
        "os"
        "os/exec"
        "os/signal"
@@ -21,6 +20,7 @@ import (
        "git.curoverse.com/arvados.git/sdk/go/arvados"
        "git.curoverse.com/arvados.git/sdk/go/arvadosclient"
        "git.curoverse.com/arvados.git/sdk/go/dispatch"
+       "github.com/Sirupsen/logrus"
 )
 
 var version = "dev"
@@ -28,7 +28,7 @@ var version = "dev"
 func main() {
        err := doMain()
        if err != nil {
-               log.Fatalf("%q", err)
+               logrus.Fatalf("%q", err)
        }
 }
 
@@ -40,6 +40,14 @@ var (
 )
 
 func doMain() error {
+       logger := logrus.StandardLogger()
+       if os.Getenv("DEBUG") != "" {
+               logger.SetLevel(logrus.DebugLevel)
+       }
+       logger.Formatter = &logrus.JSONFormatter{
+               TimestampFormat: "2006-01-02T15:04:05.000000000Z07:00",
+       }
+
        flags := flag.NewFlagSet("crunch-dispatch-local", flag.ExitOnError)
 
        pollInterval := flags.Int(
@@ -66,18 +74,19 @@ func doMain() error {
                return nil
        }
 
-       log.Printf("crunch-dispatch-local %s started", version)
+       logger.Printf("crunch-dispatch-local %s started", version)
 
        runningCmds = make(map[string]*exec.Cmd)
 
        arv, err := arvadosclient.MakeArvadosClient()
        if err != nil {
-               log.Printf("Error making Arvados client: %v", err)
+               logger.Errorf("error making Arvados client: %v", err)
                return err
        }
        arv.Retries = 25
 
        dispatcher := dispatch.Dispatcher{
+               Logger:       logger,
                Arv:          arv,
                RunContainer: run,
                PollPeriod:   time.Duration(*pollInterval) * time.Second,
@@ -92,7 +101,7 @@ func doMain() error {
        c := make(chan os.Signal, 1)
        signal.Notify(c, os.Interrupt, syscall.SIGTERM, syscall.SIGQUIT)
        sig := <-c
-       log.Printf("Received %s, shutting down", sig)
+       logger.Printf("Received %s, shutting down", sig)
        signal.Stop(c)
 
        cancel()
@@ -138,7 +147,7 @@ func run(dispatcher *dispatch.Dispatcher,
                cmd.Stderr = os.Stderr
                cmd.Stdout = os.Stderr
 
-               log.Printf("Starting container %v", uuid)
+               dispatcher.Logger.Printf("starting container %v", uuid)
 
                // Add this crunch job to the list of runningCmds only if we
                // succeed in starting crunch-run.
@@ -146,7 +155,7 @@ func run(dispatcher *dispatch.Dispatcher,
                runningCmdsMutex.Lock()
                if err := startCmd(container, cmd); err != nil {
                        runningCmdsMutex.Unlock()
-                       log.Printf("Error starting %v for %v: %q", *crunchRunCommand, uuid, err)
+                       dispatcher.Logger.Warnf("error starting %q for %s: %s", *crunchRunCommand, uuid, err)
                        dispatcher.UpdateState(uuid, dispatch.Cancelled)
                } else {
                        runningCmds[uuid] = cmd
@@ -157,9 +166,9 @@ func run(dispatcher *dispatch.Dispatcher,
 
                        go func() {
                                if _, err := cmd.Process.Wait(); err != nil {
-                                       log.Printf("Error while waiting for crunch job to finish for %v: %q", uuid, err)
+                                       dispatcher.Logger.Warnf("error while waiting for crunch job to finish for %v: %q", uuid, err)
                                }
-                               log.Printf("sending done")
+                               dispatcher.Logger.Debugf("sending done")
                                done <- struct{}{}
                        }()
 
@@ -171,14 +180,14 @@ func run(dispatcher *dispatch.Dispatcher,
                                case c := <-status:
                                        // Interrupt the child process if priority changes to 0
                                        if (c.State == dispatch.Locked || c.State == dispatch.Running) && c.Priority == 0 {
-                                               log.Printf("Sending SIGINT to pid %d to cancel container %v", cmd.Process.Pid, uuid)
+                                               dispatcher.Logger.Printf("sending SIGINT to pid %d to cancel container %v", cmd.Process.Pid, uuid)
                                                cmd.Process.Signal(os.Interrupt)
                                        }
                                }
                        }
                        close(done)
 
-                       log.Printf("Finished container run for %v", uuid)
+                       dispatcher.Logger.Printf("finished container run for %v", uuid)
 
                        // Remove the crunch job from runningCmds
                        runningCmdsMutex.Lock()
@@ -191,11 +200,11 @@ func run(dispatcher *dispatch.Dispatcher,
        // If the container is not finalized, then change it to "Cancelled".
        err := dispatcher.Arv.Get("containers", uuid, nil, &container)
        if err != nil {
-               log.Printf("Error getting final container state: %v", err)
+               dispatcher.Logger.Warnf("error getting final container state: %v", err)
        }
        if container.State == dispatch.Locked || container.State == dispatch.Running {
-               log.Printf("After %s process termination, container state for %v is %q.  Updating it to %q",
-                       *crunchRunCommand, container.State, uuid, dispatch.Cancelled)
+               dispatcher.Logger.Warnf("after %q process termination, container state for %v is %q; updating it to %q",
+                       *crunchRunCommand, uuid, container.State, dispatch.Cancelled)
                dispatcher.UpdateState(uuid, dispatch.Cancelled)
        }
 
@@ -203,5 +212,5 @@ func run(dispatcher *dispatch.Dispatcher,
        for range status {
        }
 
-       log.Printf("Finalized container %v", uuid)
+       dispatcher.Logger.Printf("finalized container %v", uuid)
 }
index 534de6916c52168465ee887c5600b0dab86c9000..6da17ea86cc06ccdbce21c37d2b703b1f937fded 100644 (file)
@@ -8,12 +8,11 @@ import (
        "bytes"
        "context"
        "io"
-       "log"
        "net/http"
        "net/http/httptest"
        "os"
        "os/exec"
-       "strings"
+       "regexp"
        "testing"
        "time"
 
@@ -21,6 +20,7 @@ import (
        "git.curoverse.com/arvados.git/sdk/go/arvadosclient"
        "git.curoverse.com/arvados.git/sdk/go/arvadostest"
        "git.curoverse.com/arvados.git/sdk/go/dispatch"
+       "github.com/Sirupsen/logrus"
        . "gopkg.in/check.v1"
 )
 
@@ -41,6 +41,7 @@ func (s *TestSuite) SetUpSuite(c *C) {
        initialArgs = os.Args
        arvadostest.StartAPI()
        runningCmds = make(map[string]*exec.Cmd)
+       logrus.SetFormatter(&logrus.TextFormatter{DisableColors: true})
 }
 
 func (s *TestSuite) TearDownSuite(c *C) {
@@ -133,7 +134,7 @@ func (s *MockArvadosServerSuite) Test_ContainerStillInRunningAfterRun(c *C) {
                arvadostest.StubResponse{200, string(`{"uuid":"zzzzz-dz642-xxxxxxxxxxxxxx2", "state":"Running", "priority":1, "locked_by_uuid": "` + arvadostest.Dispatch1AuthUUID + `"}`)}
 
        testWithServerStub(c, apiStubResponses, "echo",
-               `After echo process termination, container state for Running is "zzzzz-dz642-xxxxxxxxxxxxxx2".  Updating it to "Cancelled"`)
+               `after \\"echo\\" process termination, container state for zzzzz-dz642-xxxxxxxxxxxxxx2 is \\"Running\\"; updating it to \\"Cancelled\\"`)
 }
 
 func (s *MockArvadosServerSuite) Test_ErrorRunningContainer(c *C) {
@@ -144,7 +145,7 @@ func (s *MockArvadosServerSuite) Test_ErrorRunningContainer(c *C) {
        apiStubResponses["/arvados/v1/containers/zzzzz-dz642-xxxxxxxxxxxxxx3/lock"] =
                arvadostest.StubResponse{200, string(`{"uuid":"zzzzz-dz642-xxxxxxxxxxxxxx3", "state":"Locked", "priority":1}`)}
 
-       testWithServerStub(c, apiStubResponses, "nosuchcommand", "Error starting nosuchcommand for zzzzz-dz642-xxxxxxxxxxxxxx3")
+       testWithServerStub(c, apiStubResponses, "nosuchcommand", `error starting \\"nosuchcommand\\" for zzzzz-dz642-xxxxxxxxxxxxxx3`)
 }
 
 func testWithServerStub(c *C, apiStubResponses map[string]arvadostest.StubResponse, crunchCmd string, expected string) {
@@ -165,15 +166,15 @@ func testWithServerStub(c *C, apiStubResponses map[string]arvadostest.StubRespon
        }
 
        buf := bytes.NewBuffer(nil)
-       log.SetOutput(io.MultiWriter(buf, os.Stderr))
-       defer log.SetOutput(os.Stderr)
+       logrus.SetOutput(io.MultiWriter(buf, os.Stderr))
+       defer logrus.SetOutput(os.Stderr)
 
        *crunchRunCommand = crunchCmd
 
        ctx, cancel := context.WithCancel(context.Background())
        dispatcher := dispatch.Dispatcher{
                Arv:        arv,
-               PollPeriod: time.Duration(1) * time.Second,
+               PollPeriod: time.Second / 20,
                RunContainer: func(d *dispatch.Dispatcher, c arvados.Container, s <-chan arvados.Container) {
                        run(d, c, s)
                        cancel()
@@ -186,8 +187,9 @@ func testWithServerStub(c *C, apiStubResponses map[string]arvadostest.StubRespon
                return cmd.Start()
        }
 
+       re := regexp.MustCompile(`(?ms).*` + expected + `.*`)
        go func() {
-               for i := 0; i < 80 && !strings.Contains(buf.String(), expected); i++ {
+               for i := 0; i < 80 && !re.MatchString(buf.String()); i++ {
                        time.Sleep(100 * time.Millisecond)
                }
                cancel()
index 16d9fd18db2765adb6aa05ab1d742660f51790d8..084700d39bfad76b109078f29e81ecf82c40c5be 100644 (file)
@@ -23,9 +23,15 @@ import (
        "git.curoverse.com/arvados.git/sdk/go/arvadosclient"
        "git.curoverse.com/arvados.git/sdk/go/config"
        "git.curoverse.com/arvados.git/sdk/go/dispatch"
+       "github.com/Sirupsen/logrus"
        "github.com/coreos/go-systemd/daemon"
 )
 
+type logger interface {
+       dispatch.Logger
+       Fatalf(string, ...interface{})
+}
+
 const initialNiceValue int64 = 10000
 
 var (
@@ -35,6 +41,7 @@ var (
 
 type Dispatcher struct {
        *dispatch.Dispatcher
+       logger  logrus.FieldLogger
        cluster *arvados.Cluster
        sqCheck *SqueueChecker
        slurm   Slurm
@@ -63,10 +70,17 @@ type Dispatcher struct {
 }
 
 func main() {
-       disp := &Dispatcher{}
+       logger := logrus.StandardLogger()
+       if os.Getenv("DEBUG") != "" {
+               logger.SetLevel(logrus.DebugLevel)
+       }
+       logger.Formatter = &logrus.JSONFormatter{
+               TimestampFormat: "2006-01-02T15:04:05.000000000Z07:00",
+       }
+       disp := &Dispatcher{logger: logger}
        err := disp.Run(os.Args[0], os.Args[1:])
        if err != nil {
-               log.Fatal(err)
+               logrus.Fatalf("%s", err)
        }
 }
 
@@ -104,7 +118,7 @@ func (disp *Dispatcher) configure(prog string, args []string) error {
                return nil
        }
 
-       log.Printf("crunch-dispatch-slurm %s started", version)
+       disp.logger.Printf("crunch-dispatch-slurm %s started", version)
 
        err := disp.readConfig(*configPath)
        if err != nil {
@@ -132,7 +146,7 @@ func (disp *Dispatcher) configure(prog string, args []string) error {
                os.Setenv("ARVADOS_KEEP_SERVICES", strings.Join(disp.Client.KeepServiceURIs, " "))
                os.Setenv("ARVADOS_EXTERNAL_CLIENT", "")
        } else {
-               log.Printf("warning: Client credentials missing from config, so falling back on environment variables (deprecated).")
+               disp.logger.Warnf("Client credentials missing from config, so falling back on environment variables (deprecated).")
        }
 
        if *dumpConfig {
@@ -141,7 +155,7 @@ func (disp *Dispatcher) configure(prog string, args []string) error {
 
        siteConfig, err := arvados.GetConfig(arvados.DefaultConfigFile)
        if os.IsNotExist(err) {
-               log.Printf("warning: no cluster config (%s), proceeding with no node types defined", err)
+               disp.logger.Warnf("no cluster config (%s), proceeding with no node types defined", err)
        } else if err != nil {
                return fmt.Errorf("error loading config: %s", err)
        } else if disp.cluster, err = siteConfig.GetCluster(""); err != nil {
@@ -153,20 +167,25 @@ func (disp *Dispatcher) configure(prog string, args []string) error {
 
 // setup() initializes private fields after configure().
 func (disp *Dispatcher) setup() {
+       if disp.logger == nil {
+               disp.logger = logrus.StandardLogger()
+       }
        arv, err := arvadosclient.MakeArvadosClient()
        if err != nil {
-               log.Fatalf("Error making Arvados client: %v", err)
+               disp.logger.Fatalf("Error making Arvados client: %v", err)
        }
        arv.Retries = 25
 
        disp.slurm = NewSlurmCLI()
        disp.sqCheck = &SqueueChecker{
+               Logger:         disp.logger,
                Period:         time.Duration(disp.PollPeriod),
                PrioritySpread: disp.PrioritySpread,
                Slurm:          disp.slurm,
        }
        disp.Dispatcher = &dispatch.Dispatcher{
                Arv:            arv,
+               Logger:         disp.logger,
                BatchSize:      disp.BatchSize,
                RunContainer:   disp.runContainer,
                PollPeriod:     time.Duration(disp.PollPeriod),
@@ -325,7 +344,7 @@ func (disp *Dispatcher) runContainer(_ *dispatch.Dispatcher, ctr arvados.Contain
                case <-ctx.Done():
                        // Disappeared from squeue
                        if err := disp.Arv.Get("containers", ctr.UUID, nil, &ctr); err != nil {
-                               log.Printf("Error getting final container state for %s: %s", ctr.UUID, err)
+                               log.Printf("error getting final container state for %s: %s", ctr.UUID, err)
                        }
                        switch ctr.State {
                        case dispatch.Running:
index 33cad3af1f4341bd909e81502944e6cc4366d9f6..b76ece314d47806afcfb328ba12970b9171b58d5 100644 (file)
@@ -11,7 +11,6 @@ import (
        "fmt"
        "io"
        "io/ioutil"
-       "log"
        "net/http"
        "net/http/httptest"
        "os"
@@ -25,6 +24,7 @@ import (
        "git.curoverse.com/arvados.git/sdk/go/arvadosclient"
        "git.curoverse.com/arvados.git/sdk/go/arvadostest"
        "git.curoverse.com/arvados.git/sdk/go/dispatch"
+       "github.com/Sirupsen/logrus"
        . "gopkg.in/check.v1"
 )
 
@@ -138,7 +138,11 @@ func (s *IntegrationSuite) integrationTest(c *C,
        }
 
        s.disp.slurm = &s.slurm
-       s.disp.sqCheck = &SqueueChecker{Period: 500 * time.Millisecond, Slurm: s.disp.slurm}
+       s.disp.sqCheck = &SqueueChecker{
+               Logger: logrus.StandardLogger(),
+               Period: 500 * time.Millisecond,
+               Slurm:  s.disp.slurm,
+       }
 
        err = s.disp.Dispatcher.Run(ctx)
        <-doneRun
@@ -264,8 +268,8 @@ func (s *StubbedSuite) testWithServerStub(c *C, apiStubResponses map[string]arva
        }
 
        buf := bytes.NewBuffer(nil)
-       log.SetOutput(io.MultiWriter(buf, os.Stderr))
-       defer log.SetOutput(os.Stderr)
+       logrus.SetOutput(io.MultiWriter(buf, os.Stderr))
+       defer logrus.SetOutput(os.Stderr)
 
        s.disp.CrunchRunCommand = []string{crunchCmd}
 
index 0ce4fb6732f4d81bd03966c3857e0b975aa18769..5aee7e087b2658945b2eebe1f2f309d67c351d16 100644 (file)
@@ -7,7 +7,6 @@ package main
 import (
        "bytes"
        "fmt"
-       "log"
        "sort"
        "strings"
        "sync"
@@ -27,6 +26,7 @@ type slurmJob struct {
 // Squeue implements asynchronous polling monitor of the SLURM queue using the
 // command 'squeue'.
 type SqueueChecker struct {
+       Logger         logger
        Period         time.Duration
        PrioritySpread int64
        Slurm          Slurm
@@ -121,7 +121,7 @@ func (sqc *SqueueChecker) reniceAll() {
                }
                err := sqc.Slurm.Renice(job.uuid, niceNew)
                if err != nil && niceNew > slurm15NiceLimit && strings.Contains(err.Error(), "Invalid nice value") {
-                       log.Printf("container %q clamping nice values at %d, priority order will not be correct -- see https://dev.arvados.org/projects/arvados/wiki/SLURM_integration#Limited-nice-values-SLURM-15", job.uuid, slurm15NiceLimit)
+                       sqc.Logger.Warnf("container %q clamping nice values at %d, priority order will not be correct -- see https://dev.arvados.org/projects/arvados/wiki/SLURM_integration#Limited-nice-values-SLURM-15", job.uuid, slurm15NiceLimit)
                        job.hitNiceLimit = true
                }
        }
@@ -143,7 +143,7 @@ func (sqc *SqueueChecker) check() {
        stdout, stderr := &bytes.Buffer{}, &bytes.Buffer{}
        cmd.Stdout, cmd.Stderr = stdout, stderr
        if err := cmd.Run(); err != nil {
-               log.Printf("Error running %q %q: %s %q", cmd.Path, cmd.Args, err, stderr.String())
+               sqc.Logger.Warnf("Error running %q %q: %s %q", cmd.Path, cmd.Args, err, stderr.String())
                return
        }
 
@@ -156,7 +156,7 @@ func (sqc *SqueueChecker) check() {
                var uuid, state, reason string
                var n, p int64
                if _, err := fmt.Sscan(line, &uuid, &n, &p, &state, &reason); err != nil {
-                       log.Printf("warning: ignoring unparsed line in squeue output: %q", line)
+                       sqc.Logger.Warnf("ignoring unparsed line in squeue output: %q", line)
                        continue
                }
 
@@ -192,10 +192,10 @@ func (sqc *SqueueChecker) check() {
                        // "launch failed requeued held" seems to be
                        // another manifestation of this problem,
                        // resolved the same way.
-                       log.Printf("releasing held job %q (priority=%d, state=%q, reason=%q)", uuid, p, state, reason)
+                       sqc.Logger.Printf("releasing held job %q (priority=%d, state=%q, reason=%q)", uuid, p, state, reason)
                        sqc.Slurm.Release(uuid)
                } else if state != "RUNNING" && p <= 2*slurm15NiceLimit && replacing.wantPriority > 0 {
-                       log.Printf("warning: job %q has low priority %d, nice %d, state %q, reason %q", uuid, p, n, state, reason)
+                       sqc.Logger.Warnf("job %q has low priority %d, nice %d, state %q, reason %q", uuid, p, n, state, reason)
                }
        }
        sqc.lock.Lock()
index ef036dabd781edd425b29fc28f847ae18370d700..de674a1397a0fcc24a64d2c417b262e18e9554ae 100644 (file)
@@ -7,6 +7,7 @@ package main
 import (
        "time"
 
+       "github.com/Sirupsen/logrus"
        . "gopkg.in/check.v1"
 )
 
@@ -24,6 +25,7 @@ func (s *SqueueSuite) TestReleasePending(c *C) {
                queue: uuids[0] + " 10000 4294000000 PENDING Resources\n" + uuids[1] + " 10000 4294000111 PENDING Resources\n" + uuids[2] + " 10000 0 PENDING BadConstraints\n",
        }
        sqc := &SqueueChecker{
+               Logger: logrus.StandardLogger(),
                Slurm:  slurm,
                Period: time.Hour,
        }
@@ -88,6 +90,7 @@ func (s *SqueueSuite) TestReniceAll(c *C) {
                        queue: test.squeue,
                }
                sqc := &SqueueChecker{
+                       Logger:         logrus.StandardLogger(),
                        Slurm:          slurm,
                        PrioritySpread: test.spread,
                        Period:         time.Hour,
@@ -112,6 +115,7 @@ func (s *SqueueSuite) TestReniceInvalidNiceValue(c *C) {
                rejectNice10K: true,
        }
        sqc := &SqueueChecker{
+               Logger:         logrus.StandardLogger(),
                Slurm:          slurm,
                PrioritySpread: 1,
                Period:         time.Hour,
@@ -155,6 +159,7 @@ func (s *SqueueSuite) TestSetPriorityBeforeQueued(c *C) {
 
        slurm := &slurmFake{}
        sqc := &SqueueChecker{
+               Logger: logrus.StandardLogger(),
                Slurm:  slurm,
                Period: time.Hour,
        }
index bdab58927bdc243605b8cf1d7e95b34d2f610272..f78084dbcf0ce0c9ae5cf2c9f02724217f9ff2bb 100644 (file)
@@ -235,6 +235,10 @@ func (v *S3Volume) Start() error {
        }
 
        client := s3.New(auth, region)
+       if region.EC2Endpoint.Signer == aws.V4Signature {
+               // Currently affects only eu-central-1
+               client.Signature = aws.V4Signature
+       }
        client.ConnectTimeout = time.Duration(v.ConnectTimeout)
        client.ReadTimeout = time.Duration(v.ReadTimeout)
        v.bucket = &s3bucket{
index 515a7832d52ba146d0cc719544273a716b9d9c40..f2c5735985a7131129c38469e2183ffb70ef10f6 100644 (file)
@@ -24,7 +24,7 @@ Gem::Specification.new do |s|
   s.files       = ["bin/arvados-login-sync", "agpl-3.0.txt"]
   s.executables << "arvados-login-sync"
   s.required_ruby_version = '>= 2.1.0'
-  s.add_runtime_dependency 'arvados', '~> 1.1.0', '>= 1.1.4'
+  s.add_runtime_dependency 'arvados', '~> 1.2.0', '>= 1.2.0'
   s.homepage    =
     'https://arvados.org'
 end