$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_TMP"} = $ENV{"JOB_WORK"}; # deprecated
+mkdir ($ENV{"JOB_WORK"});
my $force_unlock;
my $git_dir;
{
$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");
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);
{
# 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;
'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");
}
}
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)
}
$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";
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)
{
$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);
# 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'
);