Commit 6c34667c authored by Leigh Stoller's avatar Leigh Stoller

Fixes for bind vnodes to other pnodes; have to be careful that we do not

release the physical node before the virtnodes on it. This has not been
a problem before cause physical nodes are not an actual sliver, it is
allocated internally by libvtop.
parent 76dbfb25
......@@ -2271,7 +2271,8 @@ sub UnProvision($;$)
# first to avoid work when tearing down the nodes.
#
my @links = ();
my @nodes = ();
my %pnodes = ();
my %vnodes = ();
my @shared = ();
foreach my $sliver (@slivers) {
......@@ -2294,11 +2295,38 @@ sub UnProvision($;$)
print STDERR "Could not map $sliver to its a node\n";
next;
}
if ($node->isvirtnode() && $node->sharing_mode()) {
push(@shared, $sliver);
if ($node->isvirtnode()) {
my $pnode_id = $node->phys_nodeid();
my $pnode = Node->Lookup($pnode_id);
if (!defined($pnode)) {
print STDERR "Could not get pnode object for $pnode_id\n";
next;
}
if ($node->sharing_mode()) {
push(@shared, $sliver);
}
else {
#
# The physical host might be another node in the topo
# or it might a libvtop allocated node that is not a
# part of the topo (this in itself is a problem). The
# former can happen when the user allocates a phys node
# and assigns a virtnode to it.
#
# Anyway, if the physnode is actually in the topology,
# then we cannot delete it before the VMs, we want to
# be careful to delete the VMs first. But if we are
# going to unprovision the pnode, then no need to do
# the VMs, they will just get killed anyway.
#
}
if (!exists($vnodes{$pnode_id})) {
$vnodes{$pnode_id} = [];
}
push(@{ $vnodes{$pnode_id} }, $sliver);
}
else {
push(@nodes, $sliver);
$pnodes{$node->node_id()} = $sliver;
}
}
}
......@@ -2309,7 +2337,27 @@ sub UnProvision($;$)
next;
}
}
foreach my $sliver (@nodes) {
#
# Process the virtnodes first. If we are going to unprovision the
# physical node, then do not bother since they will all get zapped.
#
foreach my $pnode_id (keys(%vnodes)) {
my @sliverlist = @{ $vnodes{$pnode_id} };
next
if (exists($pnodes{$pnode_id}));
#
# Unprovision all of the vnodes.
#
foreach my $sliver (@sliverlist) {
if ($sliver->UnProvision($nophysfree) != 0) {
print STDERR "Could not unprovision $sliver in $self\n";
$sliver->SetStatus("broken");
next;
}
}
}
foreach my $sliver (values(%pnodes)) {
if ($sliver->UnProvision($nophysfree) != 0) {
print STDERR "Could not unprovision $sliver in $self\n";
$sliver->SetStatus("broken");
......
......@@ -709,6 +709,16 @@ use libdb qw(TBDB_ALLOCSTATE_RES_INIT_DIRTY TBDB_NODESTATE_SHUTDOWN
TBResolveNextOSID TBDB_NODESTATE_ISUP TBDB_NODESTATE_TBFAILED
TBDB_NODESTATE_RELOADFAILED TBDB_NODESTATE_PXEWAIT);
# Little helper and debug function.
sub mysystem($)
{
my ($command) = @_;
print STDERR "Running '$command'\n"
if (0);
return system($command);
}
# Error log for local physical node. This overrides the default method above,
# since it is stored in the node.
sub ErrorLog($)
......@@ -1072,14 +1082,14 @@ sub UnProvision($;$)
#
if ($self->status() ne "stopped") {
if ($node->isremotenode() && $node->isvirtnode()) {
system("$VNODESETUP -p -q -m -k $pid $eid $node_id");
mysystem("$VNODESETUP -p -q -m -k $pid $eid $node_id");
if ($?) {
print STDERR "$VNODESETUP -k failed on $node_id\n";
return -1;
}
}
elsif ($node->sharing_mode()) {
system("$VNODESETUP -j -q -m -k $pid $eid $node_id");
mysystem("$VNODESETUP -j -q -m -k $pid $eid $node_id");
if ($?) {
print STDERR "$VNODESETUP -k failed on $node_id\n";
return -1;
......@@ -1113,13 +1123,13 @@ sub UnProvision($;$)
}
if (scalar(@vnodes) > 1 || $nophysfree) {
system("$NFREE -q $pid $eid $node_id");
mysystem("$NFREE -q $pid $eid $node_id");
# Unincorporate the node. Bogus, needs fixing.
$pnode->ModifyReservation({"genisliver_idx" => 0})
if (! ($pnode->sharing_mode() || scalar(@vnodes) > 1));
}
else {
system("$NFREE -x -q $pid $eid $pnode_id");
mysystem("$NFREE -x -q $pid $eid $pnode_id");
$pnode->Refresh();
}
}
......@@ -1129,6 +1139,8 @@ sub UnProvision($;$)
$node->ModifyReservation({"genisliver_idx" => 0});
goto skip;
}
my $opt = "";
#
# Look to see if local physical node was stopped (powered off).
#
......@@ -1137,7 +1149,13 @@ sub UnProvision($;$)
$self->state() eq "stopped") {
system("$POWER on $node_id");
}
system("$NFREE -q $pid $eid $node_id");
# Kill vnodes on pnode if we are deallocating a pnode.
if (!$node->isvirtnode() &&
!$node->isremotenode() &&
!$node->sharing_mode()) {
$opt = "-x";
}
mysystem("$NFREE $opt -q $pid $eid $node_id");
}
if ($?) {
print STDERR "Could not deallocate $node from $self\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