[ARVADOS] created: 3f73d1132380d90e383861bcc50ebbcf6b078abb

git at public.curoverse.com git at public.curoverse.com
Tue Aug 12 14:40:26 EDT 2014


        at  3f73d1132380d90e383861bcc50ebbcf6b078abb (commit)


commit 3f73d1132380d90e383861bcc50ebbcf6b078abb
Author: Brett Smith <brett at curoverse.com>
Date:   Tue Aug 12 14:41:55 2014 -0400

    3405: Log errors about launching pipeline instances.
    
    There's a couple of components to this:
    
    * Do some basic checks on the organization of the pipeline instance
      before we start running it, and abort if any of them fail.
    
    * If the pipeline runner aborts for any reason, send that as pipeline
      instance stderr to the API server, so other tools like Workbench can
      render it for users' benefit.

diff --git a/sdk/cli/bin/arv-run-pipeline-instance b/sdk/cli/bin/arv-run-pipeline-instance
index f20aceb..d78e50d 100755
--- a/sdk/cli/bin/arv-run-pipeline-instance
+++ b/sdk/cli/bin/arv-run-pipeline-instance
@@ -285,6 +285,16 @@ class PipelineInstance
   def [](x)
     @pi[x]
   end
+
+  def log_stderr(msg)
+    $arv.log.create log: {
+      event_type: 'stderr',
+      object_uuid: self[:uuid],
+      owner_uuid: self[:owner_uuid],
+      properties: {"text" => msg},
+    }
+  end
+
   protected
   def initialize(j)
     @attributes_to_update = {}
@@ -345,19 +355,7 @@ class JobCache
       end
       msg += "Job submission was: #{body.to_json}"
 
-      $client.execute(:api_method => $arvados.logs.create,
-                      :body_object => {
-                        :log => {
-                          :object_uuid => pipeline[:uuid],
-                          :event_type => 'stderr',
-                          :owner_uuid => pipeline[:owner_uuid],
-                          :properties => {"text" => msg}
-                        }
-                      },
-                      :authenticated => false,
-                      :headers => {
-                        authorization: 'OAuth2 '+ENV['ARVADOS_API_TOKEN']
-                      })
+      pipeline.log_stderr(msg)
       nil
     end
   end
@@ -380,10 +378,6 @@ class WhRunPipelineInstance
     if template.match /[^-0-9a-z]/
       # Doesn't look like a uuid -- use it as a filename.
       @template = JSON.parse File.read(template), :symbolize_names => true
-      if !@template[:components]
-        abort ("#{$0}: Template loaded from #{template} " +
-               "does not have a \"components\" key")
-      end
     else
       result = $client.execute(:api_method => $arvados.pipeline_templates.get,
                                :parameters => {
@@ -422,8 +416,18 @@ class WhRunPipelineInstance
       end
     end
 
+    if not @template[:components].is_a?(Hash)
+      abort "\n#{Time.now} -- pipeline_template #{@template[:uuid]}\nSyntax error: Template missing \"components\" hash"
+    end
     @components = @template[:components].dup
 
+    bad_components = @components.each_pair.select do |cname, cspec|
+      not cspec[:script_parameters].is_a?(Hash)
+    end
+    if bad_components.any?
+      abort "\n#{Time.now} -- pipeline_template #{@template[:uuid]}\nSyntax error: Components missing \"script_parameters\" hashes: #{bad_components.map(&:first).join(', ')}"
+    end
+
     errors = []
     @components.each do |componentname, component|
       component[:script_parameters].each do |parametername, parameter|
@@ -711,6 +715,11 @@ class WhRunPipelineInstance
       end
     end
   end
+
+  def abort(msg)
+    @instance.log_stderr(msg) if @instance
+    Kernel::abort(msg)
+  end
 end
 
 runner = WhRunPipelineInstance.new($options)

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list