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) { ...@@ -52,7 +52,7 @@ if ($sth->numrows < 1) {
} }
$cmd = "lock tables nodes read, node_types read, reloads read, ". $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) $sth = $dbh->query($cmd)
|| die("Locking error:\n$cmd\nError string is:".$dbh->errstr."\n"); || die("Locking error:\n$cmd\nError string is:".$dbh->errstr."\n");
...@@ -78,12 +78,17 @@ foreach my $n (@node_names) { ...@@ -78,12 +78,17 @@ foreach my $n (@node_names) {
push(@freed_nodes,$n); 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 # If the node has a reloads entry, change the reservation and start it
$cmd = "select node_id,partition,image_id,path from reloads where ". $cmd = "select node_id,partition,image_id,path from reloads where ".
"node_id='$n'"; "node_id='$n'";
$sth = $dbh->query($cmd) $sth = $dbh->query($cmd)
|| (print "Failed Command:\n$cmd\nError string is:".$dbh->errstr."\n" || (print "Failed Command:\n$cmd\nError string is:".$dbh->errstr."\n"
&& $error++); && $error++);
if ( ($sth->num_rows()) > 0) { if ( ($sth->num_rows()) > 0) {
my @reload; my @reload;
print "Adding reloads for $n to the list.\n"; print "Adding reloads for $n to the list.\n";
...@@ -102,10 +107,13 @@ foreach my $n (@node_names) { ...@@ -102,10 +107,13 @@ foreach my $n (@node_names) {
push(@list,$node); push(@list,$node);
$reloads{"$image $part $path"} = \@list; $reloads{"$image $part $path"} = \@list;
} }
} }
} else { } else {
# No reloads to be done, so really free the node # 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'..."; print "Releasing node '$n'...";
$cmd = "delete from reserved where node_id='$n' and eid='$eid'"; $cmd = "delete from reserved where node_id='$n' and eid='$eid'";
$sth = $dbh->query($cmd) && print "Succeeded.\n" $sth = $dbh->query($cmd) && print "Succeeded.\n"
......
...@@ -40,6 +40,15 @@ my %pids = (); ...@@ -40,6 +40,15 @@ my %pids = ();
my $SAVEUID = $UID; my $SAVEUID = $UID;
my @row; 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 # un-taint path
$ENV{'PATH'} = '/bin:/usr/bin:/usr/local/bin'; $ENV{'PATH'} = '/bin:/usr/bin:/usr/local/bin';
delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'}; delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
...@@ -161,6 +170,19 @@ while (<IN>) { ...@@ -161,6 +170,19 @@ while (<IN>) {
die("Node '$node' pid/eid mismatch: $pid/$eid ... $row[0]/$row[1]\n"); 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 # 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 # leave it up to the user to make sure the OS is capable of running
...@@ -248,6 +270,16 @@ foreach my $node ( keys %nodeos ) { ...@@ -248,6 +270,16 @@ foreach my $node ( keys %nodeos ) {
next; 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. # 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. # We need the pid so we can wait for them all before preceeding.
...@@ -339,6 +371,11 @@ sub PowerCycle { ...@@ -339,6 +371,11 @@ sub PowerCycle {
sub WaitTillAlive { sub WaitTillAlive {
my ($pc) = @_; my ($pc) = @_;
my $maxwait = 150;
if ($reload{$pc}) {
$maxwait += 150;
}
print STDERR "Waiting for $pc to come alive\n" if $dbg; print STDERR "Waiting for $pc to come alive\n" if $dbg;
# #
# Sigh, a long ping results in the script waiting until all the # Sigh, a long ping results in the script waiting until all the
...@@ -363,8 +400,7 @@ sub WaitTillAlive { ...@@ -363,8 +400,7 @@ sub WaitTillAlive {
(int ($curtime/60))," min.\n"; (int ($curtime/60))," min.\n";
} }
$lasttime = $curtime; $lasttime = $curtime;
# If I wait more than 150 seconds (2.5 min) it must be dead... if ($i > 3 && $curtime > $maxwait) { last; }
if ($i > 3 && $curtime > 150) { last; }
} }
close(PING); close(PING);
print STDERR "$pc is not responding. Better check into it.\n" if $dbg; print STDERR "$pc is not responding. Better check into it.\n" if $dbg;
......
...@@ -194,6 +194,12 @@ foreach my $node (@nodes) { ...@@ -194,6 +194,12 @@ foreach my $node (@nodes) {
} else { } else {
push (@load_list,$pc); 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 { } else {
print STDERR "Reserved.\n"; 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