From 55e1dde86faeebdb8372e8852f0703c401c02a9b Mon Sep 17 00:00:00 2001 From: yangsong Date: Thu, 28 Sep 2017 01:18:45 -0500 Subject: [PATCH] fix issue Switch-based node discovery failed on cumulus switch #4007 (#4022) --- perl-xCAT/xCAT/MacMap.pm | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/perl-xCAT/xCAT/MacMap.pm b/perl-xCAT/xCAT/MacMap.pm index fe58b585e..7c3d8fe13 100644 --- a/perl-xCAT/xCAT/MacMap.pm +++ b/perl-xCAT/xCAT/MacMap.pm @@ -543,11 +543,19 @@ sub refresh_table { pipe my $child, my $parent; $child->autoflush(1); $parent->autoflush(1); + $children++; my $cpid = xCAT::Utils->xfork; - unless (defined $cpid) { die "Cannot fork" } + unless (defined $cpid) { + $children--; + close($child); + close($parent); + xCAT::MsgUtils->message("S", "refresh_table: failed to fork refresh_switch process for $entry->{switch},skip..."); + next; + } if ($cpid == 0) { + $SIG{CHLD} = 'DEFAULT'; close($child); my $runstart = time; $self->refresh_switch($parent, $community, $entry->{switch}); @@ -556,6 +564,7 @@ sub refresh_table { xCAT::MsgUtils->message("S", "refresh_switch $entry->{switch} ElapsedTime:$diffduration sec"); exit(0); } + close($parent); $inputs->add($child); } @@ -719,7 +728,7 @@ sub refresh_switch { my $myport; my @res=xCAT::Utils->runcmd("ssh -o StrictHostKeyChecking=no -o PasswordAuthentication=no $switch 'bridge fdb show|grep -i -v permanent|tr A-Z a-z 2>/dev/null' 2>/dev/null",-1); - unless (@res) { + if ($::RUNCMD_RC) { xCAT::MsgUtils->message("S", "Failed to get mac table with ssh to $switch, fall back to snmp! To obtain mac table with ssh, please make sure the passwordless root ssh to $switch is available"); }else{ foreach (@res){