Merge branch '15680-arv-put-retry'
authorTom Clegg <tclegg@veritasgenetics.com>
Mon, 21 Oct 2019 15:42:39 +0000 (11:42 -0400)
committerTom Clegg <tclegg@veritasgenetics.com>
Mon, 21 Oct 2019 15:42:39 +0000 (11:42 -0400)
fixes #15680

Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tclegg@veritasgenetics.com>

14 files changed:
apps/workbench/Gemfile
apps/workbench/Gemfile.lock
apps/workbench/app/assets/javascripts/components/search.js
apps/workbench/app/assets/javascripts/filterable.js
apps/workbench/app/assets/javascripts/ilike_filters.js [new file with mode: 0644]
apps/workbench/app/assets/javascripts/to_tsquery.js [deleted file]
sdk/go/keepclient/discover.go
sdk/ruby/lib/arvados/collection.rb
sdk/ruby/test/test_collection.rb
services/api/Gemfile
services/api/Gemfile.lock
services/api/app/helpers/commits_helper.rb
services/api/app/models/keep_service.rb
services/api/lib/tasks/symbols.rake

index bc62407bc5173fa77b63daaa7f6f58882c29be33..559c2fdc224a613a3d2d2a1757b56c4762c7b7f8 100644 (file)
@@ -5,7 +5,7 @@
 source 'https://rubygems.org'
 
 gem 'rails', '~> 5.0.0'
-gem 'arvados', '>= 0.1.20150511150219'
+gem 'arvados', git: 'https://github.com/curoverse/arvados.git', glob: 'sdk/ruby/arvados.gemspec'
 
 gem 'activerecord-nulldb-adapter', git: 'https://github.com/curoverse/nulldb'
 gem 'multi_json'
index ce328dc8954393d24b295fddaccf1b1487715a5f..409ed6615b2413719bfb76ad05dd5602865d386a 100644 (file)
@@ -1,3 +1,17 @@
+GIT
+  remote: https://github.com/curoverse/arvados.git
+  revision: dd9f2403f43bcb93da5908ddde57d8c0491bb4c2
+  glob: sdk/ruby/arvados.gemspec
+  specs:
+    arvados (1.4.1.20191019025325)
+      activesupport (>= 3)
+      andand (~> 1.3, >= 1.3.3)
+      arvados-google-api-client (>= 0.7, < 0.8.9)
+      faraday (< 0.16)
+      i18n (~> 0)
+      json (>= 1.7.7, < 3)
+      jwt (>= 0.1.5, < 2)
+
 GIT
   remote: https://github.com/curoverse/nulldb
   revision: d8e0073b665acdd2537c5eb15178a60f02f4b413
@@ -58,14 +72,7 @@ GEM
     andand (1.3.3)
     angularjs-rails (1.3.15)
     arel (7.1.4)
-    arvados (1.3.3.20190320201707)
-      activesupport (>= 3)
-      andand (~> 1.3, >= 1.3.3)
-      arvados-google-api-client (>= 0.7, < 0.8.9)
-      i18n (~> 0)
-      json (>= 1.7.7, < 3)
-      jwt (>= 0.1.5, < 2)
-    arvados-google-api-client (0.8.7.2)
+    arvados-google-api-client (0.8.7.3)
       activesupport (>= 3.2, < 5.1)
       addressable (~> 2.3)
       autoparse (~> 0.3)
@@ -127,13 +134,13 @@ GEM
     flamegraph (0.9.5)
     globalid (0.4.2)
       activesupport (>= 4.2.0)
-    googleauth (0.9.0)
+    googleauth (0.10.0)
       faraday (~> 0.12)
       jwt (>= 1.4, < 3.0)
       memoist (~> 0.16)
       multi_json (~> 1.11)
       os (>= 0.9, < 2.0)
-      signet (~> 0.7)
+      signet (~> 0.12)
     headless (1.0.2)
     highline (2.0.2)
     httpclient (2.8.3)
@@ -153,7 +160,7 @@ GEM
       actionpack (>= 4)
       less (~> 2.6.0)
       sprockets (>= 2)
-    libv8 (3.16.14.19-x86_64-linux)
+    libv8 (3.16.14.19)
     lograge (0.10.0)
       actionpack (>= 4)
       activesupport (>= 4)
@@ -178,7 +185,7 @@ GEM
       metaclass (~> 0.0.1)
     morrisjs-rails (0.5.1.2)
       railties (> 3.1, < 6)
-    multi_json (1.13.1)
+    multi_json (1.14.1)
     multipart-post (2.1.1)
     net-scp (2.0.0)
       net-ssh (>= 2.6.5, < 6.0.0)
@@ -275,7 +282,7 @@ GEM
     selenium-webdriver (3.141.0)
       childprocess (~> 0.5)
       rubyzip (~> 1.2, >= 1.2.2)
-    signet (0.11.0)
+    signet (0.12.0)
       addressable (~> 2.3)
       faraday (~> 0.9)
       jwt (>= 1.5, < 3.0)
@@ -320,7 +327,7 @@ DEPENDENCIES
   activerecord-nulldb-adapter!
   andand
   angularjs-rails (~> 1.3.8)
-  arvados (>= 0.1.20150511150219)
+  arvados!
   bootstrap-sass (~> 3.4.1)
   bootstrap-tab-history-rails
   bootstrap-x-editable-rails
index 04572ec3cc9ebd82e5ef896d086339337771a431..fc6308678002a20969d4a44cbadf834731e067dd 100644 (file)
@@ -142,11 +142,7 @@ window.Search = {
                                 sessionKey: key,
                                 loadFunc: function(filters) {
                                     // Apply additional type dependant filters
-                                    filters = filters.concat(obj_type.filters)
-                                    var tsquery = to_tsquery(q)
-                                    if (tsquery) {
-                                        filters.push(['any', '@@', tsquery])
-                                    }
+                                    filters = filters.concat(obj_type.filters).concat(ilike_filters(q))
                                     return vnode.state.sessionDB.request(session, obj_type.api_path, {
                                         data: {
                                             filters: JSON.stringify(filters),
index e571e32db91560388167fed7c0a2725d649f678d..bf859c350a08ca794a1e7a11575d8cc73b5624f1 100644 (file)
 function updateFilterableQueryNow($target) {
     var newquery = $target.data('filterable-query-new');
     var params = $target.data('infinite-content-params-filterable') || {};
-    var tsquery = to_tsquery(newquery);
-    if (tsquery == null) {
-        params.filters = [];
-    } else {
-        params.filters = [['any', '@@', tsquery]];
-    }
+    params.filters = ilike_filters(newquery);
     $(".modal-dialog-preview-pane").html("");
     $target.data('infinite-content-params-filterable', params);
     $target.data('filterable-query', newquery);
diff --git a/apps/workbench/app/assets/javascripts/ilike_filters.js b/apps/workbench/app/assets/javascripts/ilike_filters.js
new file mode 100644 (file)
index 0000000..4f5cd48
--- /dev/null
@@ -0,0 +1,29 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+// ilike_filters() converts a user-entered search query to a list of
+// filters using the newly added (as of Arvados 1.5) trigram indexes. It returns
+// [] (empty list) if it can't come up with anything valid (e.g., q consists
+// entirely of punctuation).
+//
+// Examples:
+//
+// "foo"     => [["any", "ilike", "%foo%"]]
+// "foo.bar" => [["any", "ilike", "%foo.bar%"]]                         // "." is a word char in ilike queries
+// "foo/b-r" => [["any", "ilike", "%foo/b-r%"]]                         // "/" and "-", too
+// "foo_bar" => [["any", "ilike", "%foo\\_bar%"]                        // "_" should be escaped so it can be used as a literal
+// "foo bar" => [["any", "ilike", "%foo%"], ["any", "ilike", "%bar%"]]
+// "foo|bar" => [["any", "ilike", "%foo%"], ["any", "ilike", "%bar%"]]
+// " oo|bar" => [["any", "ilike", "%oo%"], ["any", "ilike", "%bar%"]]
+// ""        => []
+// " "       => []
+// null      => []
+window.ilike_filters = function(q) {
+    q = (q || '').replace(/[^-\w\.\/]+/g, ' ').trim().replace(/_/g, '\\_')
+    if (q == '')
+        return []
+    return q.split(" ").map(function(term) {
+        return ["any", "ilike", "%"+term+"%"]
+    })
+}
\ No newline at end of file
diff --git a/apps/workbench/app/assets/javascripts/to_tsquery.js b/apps/workbench/app/assets/javascripts/to_tsquery.js
deleted file mode 100644 (file)
index f2e34d9..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright (C) The Arvados Authors. All rights reserved.
-//
-// SPDX-License-Identifier: AGPL-3.0
-
-// to_tsquery() converts a user-entered search query to a useful
-// operand for the Arvados API "@@" filter. It returns null if it
-// can't come up with anything valid (e.g., q consists entirely of
-// punctuation).
-//
-// Examples:
-//
-// "foo"     => "foo:*"
-// "foo_bar" => "foo:*&bar:*"
-// "foo.bar" => "foo.bar:*"    // "." is a word char in FT queries
-// "foo/b-r" => "foo/b-r:*"    // "/" and "-", too
-// "foo|bar" => "foo:*&bar:*"
-// " oo|ba " => "oo:*&ba:*"
-// "__ "     => null
-// ""        => null
-// null      => null
-window.to_tsquery = function(q) {
-    q = (q || '').replace(/[^-\w\.\/]+/g, ' ').trim().replace(/ /g, ':*&')
-    if (q == '')
-        return null
-    return q + ':*'
-}
index 62936e71831fb1fa055b213fac470f2adeb5ea16..02c788bd9ae2196812bd856a2894855c372ca9df 100644 (file)
@@ -27,8 +27,9 @@ func RefreshServiceDiscovery() {
        defer svcListCacheMtx.Unlock()
        for _, ent := range svcListCache {
                wg.Add(1)
+               clear := ent.clear
                go func() {
-                       ent.clear <- struct{}{}
+                       clear <- struct{}{}
                        wg.Done()
                }()
        }
index 29c7663f7ba521543e542d83da11f7f419a01793..e29deba6c9de314f1deb9c14fd6e723c8e085ac9 100644 (file)
@@ -207,7 +207,7 @@ module Arv
         loop do
           ii = (lo + hi) / 2
           range = @ranges[ii]
-          if range.include?(target) && (target < range.end || ii == hi)
+          if range.include?(target) && (target < range.end || ii == hi-1)
             return ii
           elsif ii == lo
             raise RangeError.new("%i not in segment" % target)
index 1979443733a7821b4a655833d96ac19b41ba4fa6..8b747c365211b742d303a2d2894129253d830d37 100644 (file)
@@ -36,6 +36,29 @@ class CollectionTest < Minitest::Test
     end
   end
 
+  def test_range_edge_cases
+    [
+      ". d41d8cd98f00b204e9800998ecf8427e+0 0:0:file1\n",
+      ". d41d8cd98f00b204e9800998ecf8427e+0 0:0:file1 0:0:file2\n",
+      ". d41d8cd98f00b204e9800998ecf8427e+0 0:0:file1 0:0:file1\n",
+      ". d41d8cd98f00b204e9800998ecf8427e+0 0:0:file1 0:0:file2 0:0:file1\n",
+      ". 0cc175b9c0f1b6a831c399e269772661+1 0:0:file1 1:0:file2 1:0:file1\n",
+    ].each do |txt|
+      coll = Arv::Collection.new(txt)
+      coll.normalize
+      assert_match(/ 0:0:file1/, coll.manifest_text)
+    end
+    [
+      ". d41d8cd98f00b204e9800998ecf8427e+0 1:0:file1\n",
+      ". 0cc175b9c0f1b6a831c399e269772661+1 0:0:file1 2:0:file2 1:0:file1\n",
+    ].each do |txt|
+      assert_raises(RangeError) do
+        coll = Arv::Collection.new(txt)
+        coll.normalize
+      end
+    end
+  end
+
   def test_non_manifest_construction_error
     ["word", ". abc def", ". #{random_block} 0:", ". / !"].each do |m_text|
       assert_raises(ArgumentError,
index 804d2a479d3d4701489c8d1bed812c7a6873c252..b106ab199c6a3b2db2ca64788506c5fbdedc43b5 100644 (file)
@@ -25,9 +25,6 @@ group :test, :development do
   gem 'byebug'
 end
 
-# We need this dependency because of crunchv1
-gem 'arvados-cli'
-
 gem 'pg', '~> 1.0'
 
 gem 'multi_json'
@@ -58,7 +55,12 @@ gem 'faye-websocket'
 
 gem 'themes_for_rails', git: 'https://github.com/curoverse/themes_for_rails'
 
-gem 'arvados', '>= 1.3.1.20190301212059'
+# We need arvados-cli because of crunchv1. Note: bundler can't handle
+# two gems with the same "git" url but different "glob" values, hence
+# the use of a wildcard here instead of literal paths
+# (sdk/cli/arvados-cli.gem and sdk/ruby/arvados.gem).
+gem 'arvados-cli', git: 'https://github.com/curoverse/arvados.git', glob: 'sdk/*/*.gemspec'
+gem 'arvados', git: 'https://github.com/curoverse/arvados.git', glob: 'sdk/*/*.gemspec'
 gem 'httpclient'
 
 gem 'sshkey'
index b5ac62c9fb397dfe2d429ab365bce8ea7b5c1aba..e80f87e2a570f1fb351a2e20b1936543fd7c960e 100644 (file)
@@ -1,3 +1,27 @@
+GIT
+  remote: https://github.com/curoverse/arvados.git
+  revision: dd9f2403f43bcb93da5908ddde57d8c0491bb4c2
+  glob: sdk/*/*.gemspec
+  specs:
+    arvados (1.4.1.20191019025325)
+      activesupport (>= 3)
+      andand (~> 1.3, >= 1.3.3)
+      arvados-google-api-client (>= 0.7, < 0.8.9)
+      faraday (< 0.16)
+      i18n (~> 0)
+      json (>= 1.7.7, < 3)
+      jwt (>= 0.1.5, < 2)
+    arvados-cli (1.4.1.20191017145711)
+      activesupport (>= 3.2.13, < 5.1)
+      andand (~> 1.3, >= 1.3.3)
+      arvados (>= 1.4.1.20190320201707)
+      arvados-google-api-client (~> 0.6, >= 0.6.3, < 0.8.9)
+      curb (~> 0.8)
+      faraday (< 0.16)
+      json (>= 1.7.7, < 3)
+      oj (~> 3.0)
+      optimist (~> 3.0)
+
 GIT
   remote: https://github.com/curoverse/themes_for_rails
   revision: ddf6e592b3b6493ea0c2de7b5d3faa120ed35be0
@@ -49,27 +73,11 @@ GEM
       activemodel (>= 3.0.0)
       activesupport (>= 3.0.0)
       rack (>= 1.1.0)
-    addressable (2.6.0)
-      public_suffix (>= 2.0.2, < 4.0)
+    addressable (2.7.0)
+      public_suffix (>= 2.0.2, < 5.0)
     andand (1.3.3)
     arel (7.1.4)
-    arvados (1.3.1.20190320201707)
-      activesupport (>= 3)
-      andand (~> 1.3, >= 1.3.3)
-      arvados-google-api-client (>= 0.7, < 0.8.9)
-      i18n (~> 0)
-      json (>= 1.7.7, < 3)
-      jwt (>= 0.1.5, < 2)
-    arvados-cli (1.3.1.20190320201707)
-      activesupport (>= 3.2.13, < 5.1)
-      andand (~> 1.3, >= 1.3.3)
-      arvados (~> 1.3.0, >= 1.3.0)
-      arvados-google-api-client (~> 0.6, >= 0.6.3, < 0.8.9)
-      curb (~> 0.8)
-      json (>= 1.7.7, < 3)
-      oj (~> 3.0)
-      optimist (~> 3.0)
-    arvados-google-api-client (0.8.7.2)
+    arvados-google-api-client (0.8.7.3)
       activesupport (>= 3.2, < 5.1)
       addressable (~> 2.3)
       autoparse (~> 0.3)
@@ -94,7 +102,7 @@ GEM
       net-ssh-gateway (>= 1.1.0)
     concurrent-ruby (1.1.5)
     crass (1.0.4)
-    curb (0.9.9)
+    curb (0.9.10)
     database_cleaner (1.7.0)
     erubis (2.7.0)
     eventmachine (1.2.7)
@@ -113,13 +121,13 @@ GEM
     ffi (1.9.25)
     globalid (0.4.2)
       activesupport (>= 4.2.0)
-    googleauth (0.8.0)
+    googleauth (0.10.0)
       faraday (~> 0.12)
       jwt (>= 1.4, < 3.0)
       memoist (~> 0.16)
       multi_json (~> 1.11)
       os (>= 0.9, < 2.0)
-      signet (~> 0.7)
+      signet (~> 0.12)
     hashie (3.6.0)
     highline (2.0.1)
     httpclient (2.8.3)
@@ -153,9 +161,9 @@ GEM
     minitest (5.10.3)
     mocha (1.8.0)
       metaclass (~> 0.0.1)
-    multi_json (1.13.1)
+    multi_json (1.14.1)
     multi_xml (0.6.0)
-    multipart-post (2.0.0)
+    multipart-post (2.1.1)
     net-scp (2.0.0)
       net-ssh (>= 2.6.5, < 6.0.0)
     net-sftp (2.1.2)
@@ -172,7 +180,7 @@ GEM
       multi_json (~> 1.3)
       multi_xml (~> 0.5)
       rack (>= 1.2, < 3)
-    oj (3.7.11)
+    oj (3.9.2)
     omniauth (1.4.3)
       hashie (>= 1.2, < 4)
       rack (>= 1.6.2, < 3)
@@ -180,13 +188,13 @@ GEM
       oauth2 (~> 1.1)
       omniauth (~> 1.2)
     optimist (3.0.0)
-    os (1.0.0)
+    os (1.0.1)
     passenger (6.0.2)
       rack
       rake (>= 0.8.1)
     pg (1.1.4)
     power_assert (1.1.4)
-    public_suffix (3.0.3)
+    public_suffix (4.0.1)
     rack (2.0.7)
     rack-test (0.6.3)
       rack (>= 1.0)
@@ -246,7 +254,7 @@ GEM
       sprockets (>= 2.8, < 4.0)
       sprockets-rails (>= 2.0, < 4.0)
       tilt (>= 1.1, < 3)
-    signet (0.11.0)
+    signet (0.12.0)
       addressable (~> 2.3)
       faraday (~> 0.9)
       jwt (>= 1.5, < 3.0)
@@ -288,8 +296,8 @@ PLATFORMS
 DEPENDENCIES
   acts_as_api
   andand
-  arvados (>= 1.3.1.20190301212059)
-  arvados-cli
+  arvados!
+  arvados-cli!
   byebug
   database_cleaner
   factory_bot_rails
index b1c02b2a76a1597f7caf0837cf609b2deffa1eac..fdb83a03751b1b81e45b0e9cd71ec910a81f7cca 100644 (file)
@@ -3,6 +3,7 @@
 # SPDX-License-Identifier: AGPL-3.0
 
 module CommitsHelper
+  extend CurrentApiClient
 
   class GitError < RequestError
     def http_status
index 60f2632029dc4bf2cf2ead9dc19522551b8bbb10..f76f5e47a5c68c7cb338a1e2bc836d80bf05a314 100644 (file)
@@ -7,6 +7,7 @@ class KeepService < ArvadosModel
   include KindAndEtag
   include CommonApiTemplate
   extend DbCurrentTime
+  extend CurrentApiClient
 
   SERVER_START_TIME = db_current_time
 
index a2e6df8b580c0fc8c80f7a97188699870352f754..dc9ed461dd95831a1f67318f2eeb47c9c63d0e21 100644 (file)
@@ -4,7 +4,12 @@
 
 require 'current_api_client'
 
-include CurrentApiClient
+# This is needed instead of just including CurrentApiClient so that its
+# methods don't get imported as Object's class methods; this is a problem because
+# the methods would be imported only on test environment. See #15716 for more info.
+class CurrentApiClientHelper
+  extend CurrentApiClient
+end
 
 def has_symbols? x
   if x.is_a? Hash
@@ -83,7 +88,7 @@ namespace :symbols do
      Node, PipelineInstance, PipelineTemplate,
      Repository, Specimen, Trait, User, VirtualMachine,
      Workflow].each do |klass|
-      act_as_system_user do
+      CurrentApiClientHelper.act_as_system_user do
         klass.all.each do |c|
           check_for_serialized_symbols c
         end
@@ -99,7 +104,7 @@ namespace :symbols do
      Node, PipelineInstance, PipelineTemplate,
      Repository, Specimen, Trait, User, VirtualMachine,
      Workflow].each do |klass|
-      act_as_system_user do
+      CurrentApiClientHelper.act_as_system_user do
         klass.all.each do |c|
           stringify_serialized_symbols c
         end