[ARVADOS] created: 2.1.0-1815-g1859bc36e

Git user git at public.arvados.org
Fri Jan 7 22:02:24 UTC 2022


        at  1859bc36ee1c7a48c90368d400ff125dcabd032a (commit)


commit 1859bc36ee1c7a48c90368d400ff125dcabd032a
Author: Lucas Di Pentima <lucas.dipentima at curii.com>
Date:   Fri Jan 7 18:58:54 2022 -0300

    17492: Implements Arvados::ArvadosClient to set a request-id on every call.
    
    Also, add the req-id is not present on response.
    
    Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas.dipentima at curii.com>

diff --git a/sdk/cli/bin/arv b/sdk/cli/bin/arv
index 9d4a60937..a9e7c927a 100755
--- a/sdk/cli/bin/arv
+++ b/sdk/cli/bin/arv
@@ -30,7 +30,7 @@ begin
   require 'rubygems'
   # Load the gems with more requirements first, so we respect any version
   # constraints they put on gems loaded later.
-  require 'arvados/google_api_client'
+  require 'arvados'
   require 'active_support/inflector'
   require 'andand'
   require 'curb'
@@ -65,16 +65,6 @@ module Kernel
   end
 end
 
-class ArvadosClient < Google::APIClient
-  def execute(*args)
-    if args.last.is_a? Hash
-      args.last[:headers] ||= {}
-      args.last[:headers]['Accept'] ||= 'application/json'
-    end
-    super(*args)
-  end
-end
-
 def init_config
   # read authentication data from arvados configuration file if present
   lineno = 0
@@ -605,7 +595,7 @@ if ENV['ARVADOS_API_HOST_INSECURE']
 end
 
 begin
-  client = ArvadosClient.new(:host => ENV['ARVADOS_API_HOST'], :application_name => 'arvados-cli', :application_version => '1.0')
+  client = Arvados::ArvadosClient.new(:host => ENV['ARVADOS_API_HOST'], :application_name => 'arvados-cli', :application_version => '1.0')
   arvados = client.discovered_api('arvados', ENV['ARVADOS_API_VERSION'])
 rescue Exception => e
   puts "Failed to connect to Arvados API server: #{e}"
@@ -708,14 +698,23 @@ else
                           })
 end
 
+request_id = result.headers[:x_request_id]
 begin
   results = JSON.parse result.body
 rescue JSON::ParserError => e
-  abort "Failed to parse server response:\n" + e.to_s
+  err_msg = "Failed to parse server response:\n" + e.to_s
+  if request_id
+    err_msg += "\nRequest ID: #{request_id or client.request_id}"
+  end
+  abort err_msg
 end
 
 if results["errors"] then
-  abort "Error: #{results["errors"][0]}"
+  err_message = results["errors"][0]
+  if !err_message.match(/.*req-[0-9a-zA-Z]{20}.*/)
+    err_message += " (#{request_id or client.request_id})"
+  end
+  abort "Error: #{err_message}"
 end
 
 case global_opts[:format]
diff --git a/sdk/ruby/lib/arvados.rb b/sdk/ruby/lib/arvados.rb
index d8a6be1b2..023a1f829 100644
--- a/sdk/ruby/lib/arvados.rb
+++ b/sdk/ruby/lib/arvados.rb
@@ -16,6 +16,26 @@ ActiveSupport::Inflector.inflections do |inflect|
 end
 
 class Arvados
+  class ArvadosClient < Google::APIClient
+    attr_reader :request_id
+
+    def execute(*args)
+      @request_id = "req-" + Random::DEFAULT.rand(2**128).to_s(36)[0..19]
+      if args.last.is_a? Hash
+        args.last[:headers] ||= {}
+        args.last[:headers]['X-Request-Id'] = @request_id
+      end
+      begin
+        super(*args)
+      rescue => e
+        if !e.message.match(/.*req-[0-9a-zA-Z]{20}.*/)
+          e.message += "\nRequest ID: #{e.headers['X-Request-Id'] or @request_id}"
+        end
+        raise e
+      end
+    end
+  end
+
   class TransactionFailedError < StandardError
   end
 
@@ -101,7 +121,7 @@ class Arvados
   end
 
   def client
-    @client ||= Google::APIClient.
+    @client ||= ArvadosClient.
       new(:host => config["ARVADOS_API_HOST"],
           :application_name => @application_name,
           :application_version => @application_version.to_s)
@@ -207,6 +227,9 @@ class Arvados
                 })
       resp = JSON.parse result.body, :symbolize_names => true
       if resp[:errors]
+        if !resp[:errors][0].match(/.*req-[0-9a-zA-Z]{20}.*/)
+          resp[:errors][0] += " (#{result.headers['X-Request-Id'] or client.request_id})"
+        end
         raise Arvados::TransactionFailedError.new(resp[:errors])
       elsif resp[:uuid] and resp[:etag]
         self.new(resp)

commit 997369d9023145be882780fc2c63120674748796
Author: Lucas Di Pentima <lucas.dipentima at curii.com>
Date:   Wed Jan 5 14:48:25 2022 -0300

    17492: Removes unused & deprecated code.
    
    Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas.dipentima at curii.com>

diff --git a/services/api/app/controllers/application_controller.rb b/services/api/app/controllers/application_controller.rb
index 3750befb3..4625ef654 100644
--- a/services/api/app/controllers/application_controller.rb
+++ b/services/api/app/controllers/application_controller.rb
@@ -688,11 +688,6 @@ class ApplicationController < ActionController::Base
     }
   end
 
-  def client_accepts_plain_text_stream
-    (request.headers['Accept'].split(' ') &
-     ['text/plain', '*/*']).count > 0
-  end
-
   def render *opts
     if opts.first
       response = opts.first[:json]

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list