diff --git a/db/nfree.in b/db/nfree.in index de0e5deebb41a852e799bb4955ef4ca3e6faf920..be409f5c3b9c133a920c25c59b70b3ddd59d2b1d 100755 --- a/db/nfree.in +++ b/db/nfree.in @@ -52,7 +52,7 @@ if ($sth->numrows < 1) { } $cmd = "lock tables nodes read, node_types read, reloads read, ". - "interfaces write, delays write, reserved write"; + "interfaces write, delays write, reserved write, last_reservation write"; $sth = $dbh->query($cmd) || die("Locking error:\n$cmd\nError string is:".$dbh->errstr."\n"); @@ -78,12 +78,17 @@ foreach my $n (@node_names) { push(@freed_nodes,$n); } + # This little sillyness is for disk reloading. Kill the last reservation. + $cmd = "delete from last_reservation where node_id='$n'"; + $dbh->query($cmd); + # If the node has a reloads entry, change the reservation and start it $cmd = "select node_id,partition,image_id,path from reloads where ". "node_id='$n'"; $sth = $dbh->query($cmd) || (print "Failed Command:\n$cmd\nError string is:".$dbh->errstr."\n" && $error++); + if ( ($sth->num_rows()) > 0) { my @reload; print "Adding reloads for $n to the list.\n"; @@ -102,10 +107,13 @@ foreach my $n (@node_names) { push(@list,$node); $reloads{"$image $part $path"} = \@list; } - } } else { # No reloads to be done, so really free the node + # This little sillyness is for disk reloading. Remember the last + # project a node was reserved into. + $cmd = "insert into last_reservation values ('$n', '$pid')"; + $dbh->query($cmd); print "Releasing node '$n'..."; $cmd = "delete from reserved where node_id='$n' and eid='$eid'"; $sth = $dbh->query($cmd) && print "Succeeded.\n" diff --git a/tbsetup/os_setup.in b/tbsetup/os_setup.in index e727188ff01e64be09e6c335f7349eac90f57ccb..e0815ad69becdf56bb12f3646238e72bd70fd969 100755 --- a/tbsetup/os_setup.in +++ b/tbsetup/os_setup.in @@ -40,6 +40,15 @@ my %pids = (); my $SAVEUID = $UID; my @row; +# +# This stuff is BOGUS! Quick hack for paper deadline to make Jay happy. +# +my $NETDISK = "/tftpboot/netdisk"; +my $PAPERADDR = "boss.emulab.net"; +my $IMAGE = "/usr/testbed/images/wd0-all.ndz"; +my $RELOADCMD = "${PAPERADDR}:${IMAGE} wd0"; +my %reload = (); + # un-taint path $ENV{'PATH'} = '/bin:/usr/bin:/usr/local/bin'; delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'}; @@ -161,6 +170,19 @@ while () { die("Node '$node' pid/eid mismatch: $pid/$eid ... $row[0]/$row[1]\n"); } + # + # BOGUS + # + $db_result = $DB->query("select pid from last_reservation ". + "where node_id='$node'"); + $reload{$node} = 0; + if ($db_result->numrows) { + @row = $db_result->fetchrow_array(); + if ($row[0] ne $pid) { + $reload{$node} = 1; + } + } + # # First see if the OS spec is a local one from the images table. We # leave it up to the user to make sure the OS is capable of running @@ -248,6 +270,16 @@ foreach my $node ( keys %nodeos ) { next; } + # + # BOGUS! + # + if ($reload{$pc}) { + $sth = $DB->query("update nodes set ". + "next_boot_path='$NETDISK',". + "next_boot_cmd_line='$RELOADCMD' ". + "where node_id='$pc'"); + } + # # Fire off a reboot process so that we can overlap them all. # We need the pid so we can wait for them all before preceeding. @@ -339,6 +371,11 @@ sub PowerCycle { sub WaitTillAlive { my ($pc) = @_; + my $maxwait = 150; + if ($reload{$pc}) { + $maxwait += 150; + } + print STDERR "Waiting for $pc to come alive\n" if $dbg; # # Sigh, a long ping results in the script waiting until all the @@ -363,8 +400,7 @@ sub WaitTillAlive { (int ($curtime/60))," min.\n"; } $lasttime = $curtime; - # If I wait more than 150 seconds (2.5 min) it must be dead... - if ($i > 3 && $curtime > 150) { last; } + if ($i > 3 && $curtime > $maxwait) { last; } } close(PING); print STDERR "$pc is not responding. Better check into it.\n" if $dbg; diff --git a/tbsetup/sched_reload.in b/tbsetup/sched_reload.in index 2fbc5acb9b7499dd76a28de544f2ad18f5d2d0c4..239d2d3bca7ef51e08fcb890107e407672ff18a4 100755 --- a/tbsetup/sched_reload.in +++ b/tbsetup/sched_reload.in @@ -194,6 +194,12 @@ foreach my $node (@nodes) { } else { push (@load_list,$pc); } + + # + # Kill the last_reservation so that whoever gets the node next + # won't be fooled into thinking a reload is required. + # + $sth = $DB->query("delete from last_reservation where node_id='$pc'"); } else { print STDERR "Reserved.\n"; }