[ARVADOS] created: 9a15397a7e030704f63441d6e7893cb3d8be1d64

git at public.curoverse.com git at public.curoverse.com
Wed Sep 24 23:16:53 EDT 2014


        at  9a15397a7e030704f63441d6e7893cb3d8be1d64 (commit)


commit 9a15397a7e030704f63441d6e7893cb3d8be1d64
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Wed Sep 24 23:16:44 2014 -0400

    3168: Check internal git repository if the commit already exists before calling
    fetch-pack.  Check if a job tag has already been created or not, and if the tag
    already exists, that it points to the expected commit.

diff --git a/services/api/script/crunch-dispatch.rb b/services/api/script/crunch-dispatch.rb
index 45fb6dd..00b0220 100755
--- a/services/api/script/crunch-dispatch.rb
+++ b/services/api/script/crunch-dispatch.rb
@@ -263,12 +263,45 @@ class Dispatcher
         end
       end
 
-      $stderr.puts `cd #{arvados_internal.shellescape} && git fetch-pack --all #{src_repo.shellescape} && git tag #{job.uuid.shellescape} #{job.script_version.shellescape}`
-      unless $? == 0
-        $stderr.puts "dispatch: git fetch-pack && tag failed"
-        sleep 1
-        untake job
-        next
+      git = "git --git-dir=#{arvados_internal.shellescape}"
+
+      # check if the commit needs to be fetched or not
+      commit_rev = `#{git} rev-list -n1 #{job.script_version.shellescape} 2>/dev/null`.chomp
+      unless $? == 0 and commit_rev == job.script_version
+        # commit does not exist in internal repository, so import the source repository using git fetch-pack
+        cmd = "#{git} fetch-pack --no-progress --all #{src_repo.shellescape}"
+        $stderr.puts cmd
+        $stderr.puts `#{cmd}`
+        unless $? == 0
+          $stderr.puts "dispatch: git fetch-pack failed"
+          sleep 1
+          untake job
+          next
+        end        
+      end
+
+      # check if the commit needs to be tagged with this job uuid
+      tag_rev = `#{git} rev-list -n1 #{job.uuid.shellescape} 2>/dev/null`.chomp
+      if $? != 0
+        # no job tag found, so create one
+        cmd = "#{git} tag #{job.uuid.shellescape} #{job.script_version.shellescape}"
+        $stderr.puts cmd
+        $stderr.puts `#{cmd}`
+        unless $? == 0
+          $stderr.puts "dispatch: git tag failed"
+          sleep 1
+          untake job
+          next
+        end
+      else
+        # job tag found, check that it has the expected revision
+        unless tag_rev == job.script_version
+          # uh oh, the tag doesn't point to the revision we were expecting.
+          $stderr.puts "dispatch: Already a tag #{job.script_version} pointing to commit #{tag_rev} but expected commit #{job.script_version}"
+          sleep 1
+          untake job
+          next
+        end
       end
 
       cmd_args << crunch_job_bin

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list