Commit 61c9bb93 authored by Leigh B. Stoller's avatar Leigh B. Stoller

Some seriously bogus auto reloading code.

parent 249c62d9
......@@ -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"
......
......@@ -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 (<IN>) {
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;
......
......@@ -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";
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment