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

Changes to the allocstate machine to support swapmod on widearea nodes

in general, and plab nodes in particular.
parent 03ca8e04
......@@ -832,20 +832,25 @@ sub doSwapin($) {
#
# If user specified -reboot to update,
# and we are successfully performing the update,
# then mark all nodes in experiment
# so os_setup will reboot them.
# then mark all nodes in experiment so os_setup will reboot them.
#
if (($type == UPDATE) && $updateReboot) {
print STDERR "Marking nodes for reboot.\n";
$db_result =
DBQueryFatal("select rv.node_id ".
"from reserved as rv ".
"left join nodes as n on ".
"n.node_id = rv.node_id ".
"where rv.pid='$pid' and rv.eid='$eid'");
DBQueryFatal("select r.node_id,n.allocstate from reserved as r ".
"left join nodes as n on n.node_id=r.node_id ".
"where r.pid='$pid' and r.eid='$eid'");
while (my ($node) = $db_result->fetchrow_array) {
TBSetNodeAllocState( $node, TBDB_ALLOCSTATE_RES_INIT_DIRTY() );
while (my ($node,$allocstate) = $db_result->fetchrow_array) {
#
# If the node is INIT_CLEAN, leave it alone. It will still get
# rebooted, but will not falsely be tagged as dirty. This is
# important for vnodes too, where INIT_CLEAN indicated the vnode
# does not even exist yet (plab nodes).
#
if ($allocstate ne TBDB_ALLOCSTATE_RES_INIT_CLEAN()) {
TBSetNodeAllocState($node, TBDB_ALLOCSTATE_RES_INIT_DIRTY());
}
}
}
......
......@@ -46,7 +46,6 @@ my $debug = 0;
my $force = 0;
my $failed = 0;
my $killmode = 0;
my $mode = "setup";
my $dbuid;
my $MAX_CHILDREN = 8;
......@@ -84,7 +83,6 @@ if (defined($options{"d"})) {
}
if (defined($options{"k"})) {
$killmode = 1;
$mode = "teardown";
}
my $pid = shift(@ARGV);
my $eid = shift(@ARGV);
......@@ -157,6 +155,7 @@ foreach my $node (@nodes) {
my $jailed;
my $plab;
my $allocstate;
my $mode = ($killmode ? "teardown" : "setup");
if (! TBIsNodeVirtual($node, \$jailed, \$plab)) {
next;
......@@ -220,15 +219,25 @@ foreach my $node (@nodes) {
next;
}
}
elsif ($killmode) {
if ($allocstate eq TBDB_ALLOCSTATE_DOWN) {
print "$node failed to boot; skipping $mode.\n";
next;
else {
if ($killmode) {
if ($allocstate eq TBDB_ALLOCSTATE_DOWN) {
print "$node failed to boot; skipping $mode.\n";
next;
}
elsif ($allocstate eq TBDB_ALLOCSTATE_RES_INIT_CLEAN()) {
print "$node never booted; skipping $mode.\n";
next;
}
}
elsif ($allocstate eq TBDB_ALLOCSTATE_RES_INIT_CLEAN()) {
print "$node never booted; skipping $mode.\n";
elsif ($allocstate eq TBDB_ALLOCSTATE_RES_READY()) {
print "$node is already set up on remote node $pnode\n";
next;
}
elsif ($allocstate eq TBDB_ALLOCSTATE_RES_INIT_DIRTY()) {
print "$node only needs a reboot on remote node $pnode\n";
$mode = "reboot";
}
}
}
}
......@@ -237,7 +246,7 @@ foreach my $node (@nodes) {
# When setting up a vnode, force its event state into SHUTDOWN since
# no telling what its initial state is.
#
if (!$killmode) {
if ($mode eq "teardown" || $mode eq "reboot") {
TBSetNodeEventState($node, TBDB_NODESTATE_SHUTDOWN);
}
......@@ -288,7 +297,8 @@ while (1) {
[$vnode, $pnode, $mode, $jailed, $plab, time()];
$children++;
} else {
my $args = ($killmode ? "-k " : " ");
my $args = (($mode eq "teardown") ? "-k " :
($mode eq "reboot" ? "-r " : " "));
$args .= ($jailed ? "-j " : " ");
$args .= ($plab ? "-p " : " ");
$args .= "$vnode ";
......@@ -296,7 +306,7 @@ while (1) {
# Must change our real UID to root so that ssh will work.
$UID = 0;
if ($plab && !$killmode) {
if ($plab && $mode eq "setup") {
if (system("$TB/sbin/plabnode alloc $pid $eid $vnode")) {
die("*** $0:\n".
" Plab node allocation failed");
......
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