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

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