projects
/
arvados.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
During task setup, if it exists, run /crunch_scripts/install instead
[arvados.git]
/
services
/
crunch
/
crunch-job
diff --git
a/services/crunch/crunch-job
b/services/crunch/crunch-job
index 710fc0b0c8caa404eaa19dc865270f6ef6bd3e74..10acb8cbbe72ee99a539e49ebd0dfe168405c924 100755
(executable)
--- a/
services/crunch/crunch-job
+++ b/
services/crunch/crunch-job
@@
-76,8
+76,13
@@
use IPC::System::Simple qw(capturex);
$ENV{"TMPDIR"} ||= "/tmp";
$ENV{"CRUNCH_TMP"} = $ENV{"TMPDIR"} . "/crunch-job";
$ENV{"TMPDIR"} ||= "/tmp";
$ENV{"CRUNCH_TMP"} = $ENV{"TMPDIR"} . "/crunch-job";
-$ENV{"CRUNCH_WORK"} = $ENV{"CRUNCH_TMP"} . "/work";
-mkdir ($ENV{"CRUNCH_TMP"});
+if ($ENV{"USER"} ne "crunch" && $< != 0) {
+ # use a tmp dir unique for my uid
+ $ENV{"CRUNCH_TMP"} .= "-$<";
+}
+$ENV{"JOB_WORK"} = $ENV{"CRUNCH_TMP"} . "/work";
+$ENV{"CRUNCH_WORK"} = $ENV{"JOB_WORK"}; # deprecated
+mkdir ($ENV{"JOB_WORK"});
my $force_unlock;
my $git_dir;
my $force_unlock;
my $git_dir;
@@
-130,8
+135,8
@@
if ($job_has_uuid)
{
$Job = $arv->{'jobs'}->{'get'}->execute('uuid' => $jobspec);
if (!$force_unlock) {
{
$Job = $arv->{'jobs'}->{'get'}->execute('uuid' => $jobspec);
if (!$force_unlock) {
- if ($Job->{'is_locked_by'}) {
- croak("Job is locked: " . $Job->{'is_locked_by'});
+ if ($Job->{'is_locked_by
_uuid
'}) {
+ croak("Job is locked: " . $Job->{'is_locked_by
_uuid
'});
}
if ($Job->{'success'} ne undef) {
croak("Job 'success' flag (" . $Job->{'success'} . ") is not null");
}
if ($Job->{'success'} ne undef) {
croak("Job 'success' flag (" . $Job->{'success'} . ") is not null");
@@
-154,7
+159,7
@@
else
qw(script script_version script_parameters);
}
qw(script script_version script_parameters);
}
- $Job->{'is_locked_by'} = $User->{'uuid'};
+ $Job->{'is_locked_by
_uuid
'} = $User->{'uuid'};
$Job->{'started_at'} = gmtime;
$Job = $arv->{'jobs'}->{'create'}->execute('job' => $Job);
$Job->{'started_at'} = gmtime;
$Job = $arv->{'jobs'}->{'create'}->execute('job' => $Job);
@@
-251,7
+256,7
@@
if ($job_has_uuid)
{
# Claim this job, and make sure nobody else does
{
# Claim this job, and make sure nobody else does
- $Job->{'is_locked_by'} = $User->{'uuid'};
+ $Job->{'is_locked_by
_uuid
'} = $User->{'uuid'};
$Job->{'started_at'} = gmtime;
$Job->{'running'} = 1;
$Job->{'success'} = undef;
$Job->{'started_at'} = gmtime;
$Job->{'running'} = 1;
$Job->{'success'} = undef;
@@
-260,7
+265,7
@@
if ($job_has_uuid)
'running' => 0,
'done' => 0 };
if ($job_has_uuid) {
'running' => 0,
'done' => 0 };
if ($job_has_uuid) {
- unless ($Job->save() && $Job->{'is_locked_by'} == $User->{'uuid'}) {
+ unless ($Job->save() && $Job->{'is_locked_by
_uuid
'} == $User->{'uuid'}) {
croak("Error while updating / locking job");
}
}
croak("Error while updating / locking job");
}
}
@@
-340,7
+345,7
@@
else
if ($cleanpid == 0)
{
srun (["srun", "--nodelist=$nodelist", "-D", $ENV{'TMPDIR'}],
if ($cleanpid == 0)
{
srun (["srun", "--nodelist=$nodelist", "-D", $ENV{'TMPDIR'}],
- ['bash', '-c', 'if mount | grep -q $
CRUNCH_WORK/; then sudo /bin/umount $CRUNCH_WORK/* 2>/dev/null; fi; sleep 1; rm -rf $CRUNCH
_WORK $CRUNCH_TMP/opt']);
+ ['bash', '-c', 'if mount | grep -q $
JOB_WORK/; then sudo /bin/umount $JOB_WORK/* 2>/dev/null; fi; sleep 1; rm -rf $JOB
_WORK $CRUNCH_TMP/opt']);
exit (1);
}
while (1)
exit (1);
}
while (1)
@@
-544,7
+549,8
@@
for (my $todo_ptr = 0; $todo_ptr <= $#jobstep_todo; $todo_ptr ++)
}
$ENV{"TASK_SLOT_NODE"} = $slot[$childslot]->{node}->{name};
$ENV{"TASK_SLOT_NUMBER"} = $slot[$childslot]->{cpu};
}
$ENV{"TASK_SLOT_NODE"} = $slot[$childslot]->{node}->{name};
$ENV{"TASK_SLOT_NUMBER"} = $slot[$childslot]->{cpu};
- $ENV{"TASK_TMPDIR"} = $ENV{"CRUNCH_WORK"}.$slot[$childslot]->{cpu};
+ $ENV{"TASK_WORK"} = $ENV{"JOB_WORK"}."/".$slot[$childslot]->{cpu};
+ $ENV{"TASK_TMPDIR"} = $ENV{"TASK_WORK"}; # deprecated
$ENV{"CRUNCH_NODE_SLOTS"} = $slot[$childslot]->{node}->{ncpus};
$ENV{"GZIP"} = "-n";
$ENV{"CRUNCH_NODE_SLOTS"} = $slot[$childslot]->{node}->{ncpus};
$ENV{"GZIP"} = "-n";
@@
-558,7
+564,7
@@
for (my $todo_ptr = 0; $todo_ptr <= $#jobstep_todo; $todo_ptr ++)
my @execargs = qw(sh);
my $build_script_to_send = "";
my $command =
my @execargs = qw(sh);
my $build_script_to_send = "";
my $command =
- "mkdir -p $ENV{
CRUNCH_WORK} $ENV{CRUNCH_TMP
} "
+ "mkdir -p $ENV{
JOB_WORK} $ENV{CRUNCH_TMP} $ENV{TASK_WORK
} "
."&& cd $ENV{CRUNCH_TMP} ";
if ($build_script)
{
."&& cd $ENV{CRUNCH_TMP} ";
if ($build_script)
{
@@
-566,7
+572,9
@@
for (my $todo_ptr = 0; $todo_ptr <= $#jobstep_todo; $todo_ptr ++)
$command .=
"&& perl -";
}
$command .=
"&& perl -";
}
- $ENV{"PYTHONPATH"} = "$ENV{CRUNCH_SRC}/sdk/python"; # xxx hack
+ $ENV{"PYTHONPATH"} =~ s{^}{:} if $ENV{"PYTHONPATH"};
+ $ENV{"PYTHONPATH"} =~ s{^}{$ENV{CRUNCH_SRC}/sdk/python}; # xxx hack
+ $ENV{"PYTHONPATH"} =~ s{$}{:/usr/local/arvados/src/sdk/python}; # xxx hack
$command .=
"&& exec $ENV{CRUNCH_SRC}/crunch_scripts/" . $Job->{"script"};
my @execargs = ('bash', '-c', $command);
$command .=
"&& exec $ENV{CRUNCH_SRC}/crunch_scripts/" . $Job->{"script"};
my @execargs = ('bash', '-c', $command);
@@
-706,8
+714,11
@@
goto ONELEVEL if !defined $success;
release_allocation();
freeze();
release_allocation();
freeze();
+$Job->reload;
$Job->{'output'} = &collate_output();
$Job->{'output'} = &collate_output();
+$Job->{'running'} = 0;
$Job->{'success'} = $Job->{'output'} && $success;
$Job->{'success'} = $Job->{'output'} && $success;
+$Job->{'finished_at'} = gmtime;
$Job->save if $job_has_uuid;
if ($Job->{'output'})
$Job->save if $job_has_uuid;
if ($Job->{'output'})
@@
-826,7
+837,7
@@
sub reapchildren
# Load new tasks
my $newtask_list = $arv->{'job_tasks'}->{'list'}->execute(
'where' => {
# Load new tasks
my $newtask_list = $arv->{'job_tasks'}->{'list'}->execute(
'where' => {
- 'created_by_job_task' => $Jobstep->{'arvados_task'}->{uuid}
+ 'created_by_job_task
_uuid
' => $Jobstep->{'arvados_task'}->{uuid}
},
'order' => 'qsequence'
);
},
'order' => 'qsequence'
);
@@
-1108,11
+1119,11
@@
sub croak
sub cleanup
{
return if !$job_has_uuid;
sub cleanup
{
return if !$job_has_uuid;
- $Job->reload
if $job_has_uuid
;
+ $Job->reload;
$Job->{'running'} = 0;
$Job->{'success'} = 0;
$Job->{'finished_at'} = gmtime;
$Job->{'running'} = 0;
$Job->{'success'} = 0;
$Job->{'finished_at'} = gmtime;
- $Job->save
if $job_has_uuid
;
+ $Job->save;
}
}
@@
-1319,7
+1330,9
@@
my $pwd;
chomp ($pwd = `pwd`);
my $install_dir = $ENV{"CRUNCH_INSTALL"} || "$pwd/opt";
mkdir $install_dir;
chomp ($pwd = `pwd`);
my $install_dir = $ENV{"CRUNCH_INSTALL"} || "$pwd/opt";
mkdir $install_dir;
-if (!-e "./install.sh" && -e "./tests/autotests.sh") {
+if (-e "$destdir/crunch_scripts/install") {
+ shell_or_die ("$destdir/crunch_scripts/install", $install_dir);
+} elsif (!-e "./install.sh" && -e "./tests/autotests.sh") {
# Old version
shell_or_die ("./tests/autotests.sh", $install_dir);
} elsif (-e "./install.sh") {
# Old version
shell_or_die ("./tests/autotests.sh", $install_dir);
} elsif (-e "./install.sh") {