I've discovered a bug in the Install Monitor process which causes extra iterations of the call to getNodeDomains.
The issue is that gethostbyaddr returns an array containing ($name,$aliases,$addrtype,$length,@addrs) which all get put into the @clients array.
This is what ends up in the @clients array:
$VAR1 =
'c101n69.xyz.com',
'',
2,
4,
'¬e'
;
Only the 1st array element from gethostbyaddr should be added to the @clients array.
And actually, for this call, there will only ever be 1 client in the array since this chunk of code is ran on a per connection basis.
An quick fix would be:
@clients = gethostbyaddr($conn->peeraddr,AF_INET6);
@clients = ( $clients[0] );
Attached is the TRACE output of a node connecting with updateflag.awk $SERVICENODE 3002 "installstatus booted"
Here is the chunk of code from xcatd (with TRACE_LINE comments):
:::perl
# until ($quit) {
# $SIG{ALRM} = sub { xCAT::MsgUtils->message("S","XCATTIMEOUT"); die; };
# my $conn;
# next unless $conn = $socket->accept;
### TRACE_LINE print "Install Montior: Got a connection!\n";
### TRACE_LINE print Dumper(\$conn);
#my @clients;
#if ($inet6support) {
# @clients = gethostbyaddr($conn->peeraddr,AF_INET6);
# unless (@clients) { @clients = gethostbyaddr($conn->peeraddr,AF_INET); }
#} else {
### TRACE_LINE print "PeerAddr: ",$conn->peeraddr,AF_INET,"\n";
### TRACE_LINE print "Getting \@clients\n";
# ## TRACE_LINE print Dumper(\@clients);
# @clients = gethostbyaddr($conn->peeraddr,AF_INET);
### TRACE_LINE print "Done geting \@clients : \n";
### TRACE_LINE print Dumper(\@clients);
#}
#
# my $validclient=0;
# my $node;
# my $domain;
#
# ## TRACE_LINE print "Calling xCAT::NetworkUtils->getNodeDomains..\n";
# my $nd = xCAT::NetworkUtils->getNodeDomains(\@clients);
# ## TRACE_LINE print "Returned from xCAT::NetworkUtils->getNodeDomains..\n";
# my %nodedomains = %{$nd};
# foreach my $client (@clients) {
# ## TRACE_LINE print "Forloop client=$client\n";
# $domain = $nodedomains{$client};
# $client =~ s/\..*//;
# if ($domain) {
# $client =~ s/\.$domain//;
# } else {
# $client =~ s/\..*//;
# }
# #ensure this is coming from a node IP at least
# ($node) = noderange($client);
# if ($node) { #Means the source isn't valid
# $validclient=1;
# last;
# }
# }
It may also be a good idea to verify this bug doesn't exists in any other functions calling gethostbyaddr
For small xcat deployments, this bug has very little impact, but with larger deployments the extra overhead can add up quickly when site.nodestatus=1 and a large number of nodes are booted at once.
What level of xCAT are your running?
This is on xCat 2.8.3
Linda could you look into this
Diff:
I've taken a closer look at this code. My guess is that the @clients array was originally implemented to also handle aliases, but even that is not coded correctly if there is more than one alias defined for the node. I will fix this.
Also, I did grep the rest of xCAT for uses of gethostbyaddr, and this is the only place that an array is used to capture the results.
Fix checked in.
xCAT 2.8.4 a3b09614f651e71dbcf03bb26635d1ae415151b2
xCAT 2.9 (master) a698e1757d6f77eb8df224ac3f780f6df42342a9