Commit d820506a authored by Leigh B. Stoller's avatar Leigh B. Stoller

Add vnode_setup call for nodes that are marked as virtual (might be

remote, be local someday).

BIG CHANGE: Start using the last_reservation table to auto reload
nodes that are reallocated before they are reloaded by the reload
daemon.
parent 143c78bb
......@@ -38,10 +38,12 @@ use libtestbed;
my $nodereboot = "$TB/bin/node_reboot";
my $os_load = "$TB/bin/os_load";
my $vnode_setup = "$TB/sbin/vnode_setup";
my $ping = "/sbin/ping";
my $dbg = 0;
my $failed = 0;
my @nodes = ();
my @vnodes = ();
my %osids = ();
my %waitfor = ();
my %canfail = ();
......@@ -56,6 +58,7 @@ my @row;
my %reloads = ();
my %reboots = ();
my $doautoload = 1;
my $dolastload = 1;
# un-taint path
$ENV{'PATH'} = '/bin:/usr/bin:/usr/local/bin';
......@@ -116,9 +119,10 @@ if ($UID && !TBAdmin($UID)) {
# Get the set of nodes, as well as the nodes table information for them.
#
$db_result =
DBQueryFatal("select * from nodes left join reserved on ".
"nodes.node_id=reserved.node_id ".
"where reserved.pid='$pid' and reserved.eid='$eid'");
DBQueryFatal("select n.*,l.pid from nodes as n ".
"left join reserved as r on n.node_id=r.node_id ".
"left join last_reservation as l on n.node_id=l.node_id ".
"where r.pid='$pid' and r.eid='$eid'");
if ($db_result->numrows < 1) {
die("There are no nodes assigned to experiment '$eid' in project '$pid'.");
......@@ -131,10 +135,10 @@ while (my %row = $db_result->fetchhash()) {
my $bootpath = 0;
#
# VIRTNODE HACK: Virtual nodes are special. No setup.
# VIRTNODE HACK: Virtual nodes are special.
#
if (TBIsNodeVirtual($node)) {
print "*** Skipping setup on virtual node $node ...\n";
push(@vnodes, $node);
next;
}
......@@ -296,31 +300,34 @@ while (my %row = $db_result->fetchhash()) {
my $n_osid = $o_row{'osid'};
print "Mapping $osid on $node to $n_osid.\n";
DBQueryFatal("update nodes ".
"set def_boot_osid='$n_osid' ".
"where node_id='$node'");
if ($dolastload &&
defined($row{'pid'}) && $row{'pid'} ne $pid) {
SetupReload($node, $n_osid, $type);
}
else {
DBQueryFatal("update nodes ".
"set def_boot_osid='$n_osid' ".
"where node_id='$node'");
}
$osids{$node} = $n_osid;
}
}
else {
#
# User wants a specific version of an OS, but its not
# loaded on the machine. Issue a load if we can find
# an image. This goo constructs a hashed array of lists.
# loaded on the machine.
#
if ((my $imageid = TBMapOSIDtoImageID($osid, $type))) {
if (! defined($reloads{$imageid})) {
$reloads{$imageid} = [ $node ];
}
else {
push(@{ $reloads{$imageid} }, $node);
}
delete $reboots{$node};
}
else {
die("*** $0:\n".
" No image can be found for $osid on $node!\n");
}
SetupReload($node, $osid, $type);
}
}
else {
#
# OSID is loaded, but might need to be cleaned.
#
if ($dolastload &&
defined($row{'pid'}) && $row{'pid'} ne $pid) {
SetupReload($node, $osid, $type);
}
}
}
......@@ -470,6 +477,21 @@ while ( @nodes ) {
print "*** Experiment will be terminated automatically.\n";
}
#
# Now deal with virtual nodes.
#
# We do this in a sub script since nodes are not owned by the user
# and so must be setuid root so that ssh will work.
#
if ( @vnodes ) {
system("$vnode_setup $pid $eid");
if ($?) {
$failed++;
print STDERR "*** Vnode setup failed!\n";
}
}
print STDOUT "OS Setup Done!\n";
exit $failed;
......@@ -544,6 +566,29 @@ sub TBMapOSIDtoImageID($$)
return $imageid;
}
#
# Setup a reload of a node if we can find an image.
# This goo constructs a hashed array of lists.
#
sub SetupReload($$$)
{
my ($node, $osid, $type) = @_;
if ((my $imageid = TBMapOSIDtoImageID($osid, $type))) {
if (! defined($reloads{$imageid})) {
$reloads{$imageid} = [ $node ];
}
else {
push(@{ $reloads{$imageid} }, $node);
}
delete $reboots{$node};
}
else {
die("*** $0:\n".
" No image can be found for $osid on $node!\n");
}
}
#
# Fork a process to exec a command. Return the pid to wait on.
#
......
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