From fbcc5ab5e7a5ad65b81e3965f93b1679d1b1e06f Mon Sep 17 00:00:00 2001 From: Tom Clegg Date: Fri, 22 May 2015 15:40:29 -0400 Subject: [PATCH] 6094: Consider arvados_sdk_version (not just script_version) when deciding there's no need to extract or install anything. --- sdk/cli/bin/crunch-job | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/sdk/cli/bin/crunch-job b/sdk/cli/bin/crunch-job index ae9d1e2c1e..d76bbd97cd 100755 --- a/sdk/cli/bin/crunch-job +++ b/sdk/cli/bin/crunch-job @@ -597,6 +597,7 @@ else { my @execargs = ("sh", "-c", "mkdir -p $ENV{CRUNCH_INSTALL} && cd $ENV{CRUNCH_TMP} && perl -"); + $ENV{"CRUNCH_GIT_ARCHIVE_HASH"} = md5_hex($git_archive); my $installpid = fork(); if ($installpid == 0) { @@ -1888,7 +1889,7 @@ use constant TASK_TEMPFAIL => 111; my %SDK_ENVVARS = ("perl/lib" => "PERLLIB", "ruby/lib" => "RUBYLIB"); my $destdir = $ENV{"CRUNCH_SRC"}; -my $commit = $ENV{"CRUNCH_SRC_COMMIT"}; +my $archive_hash = $ENV{"CRUNCH_GIT_ARCHIVE_HASH"}; my $repo = $ENV{"CRUNCH_SRC_URL"}; my $install_dir = $ENV{"CRUNCH_INSTALL"} || (getcwd() . "/opt"); my $job_work = $ENV{"JOB_WORK"}; @@ -1981,8 +1982,9 @@ if (@ARGV) { ### Installation mode open L, ">", "$destdir.lock" or die "$destdir.lock: $!"; flock L, LOCK_EX; -if (readlink ("$destdir.commit") eq $commit && -d $destdir) { - # This version already installed -> nothing to do. +if (readlink ("$destdir.archive_hash") eq $archive_hash && -d $destdir) { + # This exact git archive (source + arvados sdk) is already installed + # here, so there's no need to reinstall it. # We must consume our DATA section, though: otherwise the process # feeding it to us will get SIGPIPE. @@ -1992,7 +1994,7 @@ if (readlink ("$destdir.commit") eq $commit && -d $destdir) { exit(0); } -unlink "$destdir.commit"; +unlink "$destdir.archive_hash"; mkdir $destdir; if (!open(TARX, "|-", "tar", "-xC", $destdir)) { @@ -2041,10 +2043,10 @@ if (-e "$destdir/crunch_scripts/install") { shell_or_die (undef, "./install.sh", $install_dir); } -if ($commit) { - unlink "$destdir.commit.new"; - symlink ($commit, "$destdir.commit.new") or die "$destdir.commit.new: $!"; - rename ("$destdir.commit.new", "$destdir.commit") or die "$destdir.commit: $!"; +if ($archive_hash) { + unlink "$destdir.archive_hash.new"; + symlink ($archive_hash, "$destdir.archive_hash.new") or die "$destdir.archive_hash.new: $!"; + rename ("$destdir.archive_hash.new", "$destdir.archive_hash") or die "$destdir.archive_hash: $!"; } close L; -- 2.30.2