From 45eeacd6cb9d95b64bce0a935bfd7208a586db31 Mon Sep 17 00:00:00 2001 From: "Leigh B. Stoller" <stoller@flux.utah.edu> Date: Thu, 20 Sep 2007 16:02:46 +0000 Subject: [PATCH] Minor bug fixes. --- tbsetup/template_swapin.in | 19 ++++++++++++------- tbsetup/template_swapout.in | 9 +++++++-- www/swapexp.php3 | 20 ++++++++++---------- 3 files changed, 29 insertions(+), 19 deletions(-) diff --git a/tbsetup/template_swapin.in b/tbsetup/template_swapin.in index 18aa3dd02e..9a6cffa7bb 100644 --- a/tbsetup/template_swapin.in +++ b/tbsetup/template_swapin.in @@ -209,14 +209,18 @@ $SIG{TERM} = \&sighandler; # # Use the logonly option to audit so that we get a record mailed. # -if (! ($foreground || $experiment->batchmode())) { +if (! $foreground) { # Cleanup $experiment->CleanLogFiles() == 0 or fatal(-1, "Could not clean up logfiles!"); $logname = TBExptCreateLogFile($pid, $eid, "swapin"); - TBExptSetLogFile($pid, $eid, $logname); - TBExptOpenLogFile($pid, $eid); + + # The batch daemon is going to set the current log file, so do not do it. + if (! $experiment->batchmode()) { + TBExptSetLogFile($pid, $eid, $logname); + TBExptOpenLogFile($pid, $eid); + } if (my $childpid = AuditStart(LIBAUDIT_DAEMON, $logname, LIBAUDIT_LOGONLY|LIBAUDIT_NODELETE|LIBAUDIT_FANCY)) { @@ -360,8 +364,6 @@ if ($experiment->batchmode()) { if (! @ExptStates); foreach my $state (@ExptStates) { - print "$state\n"; - if ($state eq EXPTSTATE_ACTIVATING()) { print "Experiment is starting a swapin attempt ...\n"; } @@ -383,10 +385,13 @@ if ($experiment->batchmode()) { # Dumped out of the batch system for some reason. print "Experiment has been removed from the batch queue.\n"; + $instance->DeleteCurrentRun() == 0 + or exit(-1); + # - # We are done; remove record of this attempt and exit. + # We are done. User has to requeue batched instance. # - fatal(1, "Experiment has been removed from the batch queue"); + exit(0); } } } diff --git a/tbsetup/template_swapout.in b/tbsetup/template_swapout.in index 1abdb6a7ad..cff72abf14 100644 --- a/tbsetup/template_swapout.in +++ b/tbsetup/template_swapout.in @@ -164,13 +164,18 @@ if (!defined($experiment)) { fatal(-1, "Experiment $pid/$eid object could not be found!"); } -# Check for cancel. +# Check for cancel and dequeue. if (! $batchmode) { if ($experiment->state() eq EXPTSTATE_ACTIVATING) { system("$swapexp -x -s out $pid $eid"); exit($? >> 8); } - # Check for a pre-loaded instance (never active). + elsif ($experiment->batchmode() && + $experiment->state() eq EXPTSTATE_QUEUED) { + # User wants to dequeue a batch experiment that is waiting to go. + system("$swapexp -x -s pause $pid $eid"); + exit($? >> 8); + } } # diff --git a/www/swapexp.php3 b/www/swapexp.php3 index d688192b22..c67fb2ff1a 100644 --- a/www/swapexp.php3 +++ b/www/swapexp.php3 @@ -90,9 +90,6 @@ $lockdown = $experiment->lockdown(); # Template Instance Experiments get special treatment in this page. $instance = TemplateInstance::LookupByExptidx($exptidx); -if ($instance && ($inout != "out" && $inout != "in")) { - PAGEARGERROR("Invalid action for template instance"); -} # Convert inout to informative text. if (!strcmp($inout, "in")) { @@ -119,6 +116,8 @@ elseif (!strcmp($inout, "pause")) { $action = "dequeue"; } elseif (!strcmp($inout, "restart")) { + if ($instance) + PAGEARGERROR("Invalid action for template instance"); $action = "restart"; } @@ -219,8 +218,9 @@ if ($instance) { $guid = $instance->guid(); $version = $instance->vers(); - STARTBUSY(($inout == "out" ? "Terminating" : "Starting") . - " template instance!"); + STARTBUSY("Template Instance is"); + if ($inout == "pause") + $inout = "out"; } # @@ -269,10 +269,7 @@ if ($retval) { echo "<blockquote><pre>$suexec_output<pre></blockquote>"; } else { - if ($instance) { - STARTLOG($experiment); - } - elseif ($isbatch) { + if ($isbatch) { if (strcmp($inout, "in") == 0) { echo "Batch Mode experiments will be run when enough resources become available. This might happen immediately, or it @@ -293,11 +290,14 @@ else { please contact $TBMAILADDR.\n"; } elseif (strcmp($inout, "pause") == 0) { - echo "Your experiment has been dequeued. You may requeue your + echo "Your experiment has been dequeued. experiment at any time.\n"; } STARTWATCHER($experiment); } + elseif ($instance) { + STARTLOG($experiment); + } else { echo "<div>"; if (strcmp($inout, "out") == 0 && -- GitLab