2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-05-29 17:23:08 +00:00

fix issue If multiple IP addresses used in xcatmaster field, updatenode will not work leaving node in bad state #3688 (#4932)

This commit is contained in:
yangsong 2018-03-15 16:14:41 +08:00 committed by Bin Xu
parent 36146ce0dd
commit 38e547c493
3 changed files with 47 additions and 3 deletions

View File

@ -716,7 +716,8 @@ sub getOSnodes
Determines the server node names as known by a lists of nodes.
Arguments:
A list of node names.
$nodes: A list of node names.
$skipfacing: do not get facing ip when noderes.xcatmaster is not set
Returns:
A hash ref of arrays, the key is the service node pointing to
@ -736,6 +737,7 @@ sub get_server_nodes
my $class = shift;
my $callback = shift;
my $nodes = shift;
my $skipfacing=shift;
my @nodelist;
if ($nodes)
@ -760,12 +762,15 @@ sub get_server_nodes
my $xcatmaster = $xcatmasters->{$node}->[0]->{xcatmaster};
$serv = xCAT::NetworkUtils->getipaddr($xcatmaster);
}
else
elsif (!$skipfacing)
{
# get ip facing node
my @servd = xCAT::NetworkUtils->my_ip_facing($node);
unless ($servd[0]) { $serv = $servd[1]; }
}
else{
continue;
}
chomp $serv;
if (xCAT::NetworkUtils->validate_ip($serv)) {

View File

@ -573,6 +573,13 @@ sub makescript {
$master_ip = "$ipaddr";
}
unless($master_ip){
my $rsp;
$rsp->{data}->[0] = "makescript failed: unable to resolve xcatmaster \"$master\" for $node";
xCAT::MsgUtils->message("SE", $rsp, $callback, 1);
return;
}
#ok, now do everything else..
#$inc =~ s/#XCATVAR:([^#]+)#/envvar($1)/eg;
#$inc =~ s/#ENV:([^#]+)#/xCAT::Template::envvar($1)/eg;

View File

@ -306,6 +306,37 @@ sub preprocess_updatenode
return;
}
# get server names as known by the nodes
my %servernodes =
%{ xCAT::InstUtils->get_server_nodes($callback, $request->{node}) };
# it's possible that the nodes could have diff server names
# do all the nodes for a particular server at once
my @invalidnodes;
if($servernodes{undef}){
push @invalidnodes,@{$servernodes{undef}};
}
if ($servernodes{""}){
push @invalidnodes,@{$servernodes{""}};
}
if (@invalidnodes){
my %allnodes=map {$_,1} @{$request->{node}};
foreach my $node (@invalidnodes){
xCAT::MsgUtils->report_node_error($callback,$node,"Could not determine or resolve xcatmaster for $node. Will skip this node.")
delete $allnodes{$node};
}
$request->{node}=[];
push $request->{node}, map $_ ,keys %allnodes;
}
unless (scalar @{$request->{node}}){
return;
}
# preprocess generate mypostscripts files (-g) for hierarchy
# if no sharedtftp then we need to broadcast this updatenode -g to all service nodes inorder
# to be able to support service node pools
@ -1524,7 +1555,7 @@ sub updatenoderunps
# get server names as known by the nodes
my %servernodes =
%{ xCAT::InstUtils->get_server_nodes($callback, \@$nodes) };
%{ xCAT::InstUtils->get_server_nodes($callback, \@$nodes,1) };
# it's possible that the nodes could have diff server names
# do all the nodes for a particular server at once
@ -1534,6 +1565,7 @@ sub updatenoderunps
if ((!defined($snkey)) or ($snkey eq "")) { # if we could not find the xcatmaster
my $rsp = {};
$rsp->{errorcode}->[0]=1;
$rsp->{error}->[0] = "Could not find xcatmaster for @{$servernodes{$snkey}}. Will skip this node. ";
$callback->($rsp);
next;