From be0bcf7451f64ab64043a9be6edb951f69e08e46 Mon Sep 17 00:00:00 2001 From: Casandra Qiu Date: Fri, 26 Feb 2016 13:23:20 -0500 Subject: [PATCH 1/2] For issue #712 Detect Error case in the xcatd and avoid loop in the updateflag.awk --- xCAT-server/sbin/xcatd | 7 +++++++ xCAT/postscripts/updateflag.awk | 30 +++++++++++++++++------------- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/xCAT-server/sbin/xcatd b/xCAT-server/sbin/xcatd index 74da551d6..08c9bce3f 100644 --- a/xCAT-server/sbin/xcatd +++ b/xCAT-server/sbin/xcatd @@ -377,6 +377,9 @@ sub do_installm_service { } else { ($client_name,$client_aliases) = gethostbyaddr($conn->peeraddr,AF_INET); } + unless ($client_name) { + xCAT::MsgUtils->message("S","xcatd unable to gethostbyaddr"); + } $clients[0] = $client_name; if ($client_aliases) { @@ -403,7 +406,11 @@ sub do_installm_service { if ($node) { # Means the source isn't valid $validclient=1; last; + } else { + xCAT::MsgUtils->message("S","Invalid client $client, please check nodels and it's name resolution"); + } + } unless ($validclient) { diff --git a/xCAT/postscripts/updateflag.awk b/xCAT/postscripts/updateflag.awk index 66fbc9ebf..9bdf970bf 100755 --- a/xCAT/postscripts/updateflag.awk +++ b/xCAT/postscripts/updateflag.awk @@ -6,27 +6,31 @@ BEGIN { xcatdport = ARGV[2] flag = ARGV[3] - if (!flag) flag = "next" + if (!flag) flag = "next" - ns = "/inet/tcp/0/" ARGV[1] "/" xcatdport + ns = "/inet/tcp/0/" ARGV[1] "/" xcatdport - while(1) { - if((ns |& getline) > 0) - print $0 | "logger -t xcat -p local4.info" + loop = 0 + while(1) { + if((ns |& getline) > 0) + print $0 | "logger -t xcat -p local4.info" else { print "Retrying flag update" | "logger -t xcat -p local4.info" close(ns) system("sleep 10") - } + loop = loop + 1 + } - if($0 == "ready") - print flag |& ns - if($0 == "done") - break - } + if($0 == "ready") + print flag |& ns + if($0 == "done") + break + if(loop > 10) + break + } - close(ns) + close(ns) - exit 0 + exit 0 } From b07e26864252b2ccb2f94c39b43e618d48d90dbd Mon Sep 17 00:00:00 2001 From: Casandra Qiu Date: Thu, 3 Mar 2016 14:50:25 -0500 Subject: [PATCH 2/2] modify error messages --- xCAT-server/sbin/xcatd | 8 +++++--- xCAT/postscripts/updateflag.awk | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/xCAT-server/sbin/xcatd b/xCAT-server/sbin/xcatd index 08c9bce3f..ca1dfd611 100644 --- a/xCAT-server/sbin/xcatd +++ b/xCAT-server/sbin/xcatd @@ -378,7 +378,9 @@ sub do_installm_service { ($client_name,$client_aliases) = gethostbyaddr($conn->peeraddr,AF_INET); } unless ($client_name) { - xCAT::MsgUtils->message("S","xcatd unable to gethostbyaddr"); + my $myaddr = inet_ntoa($conn->peeraddr); + xCAT::MsgUtils->message("S","xcatd received a connection request from unknown host with ip address $myaddr, please check whether the reverse name resolution works correctly. The connection request will be ignored"); + print "xcatd received a connection request from unknown host with ip address $myaddr, please check whether the reverse name resolution works correctly. The connection request will be ignored\n"; } $clients[0] = $client_name; @@ -407,8 +409,8 @@ sub do_installm_service { $validclient=1; last; } else { - xCAT::MsgUtils->message("S","Invalid client $client, please check nodels and it's name resolution"); - + xCAT::MsgUtils->message("S","xcatd received a connection request from $client, which can not be found in xCAT nodelist table. The connection request will be ignored"); + print "xcatd received a connection request from $client, which can not be found in xCAT nodelist table. The connection request will be ignored\n"; } } diff --git a/xCAT/postscripts/updateflag.awk b/xCAT/postscripts/updateflag.awk index 9bdf970bf..035a73e2c 100755 --- a/xCAT/postscripts/updateflag.awk +++ b/xCAT/postscripts/updateflag.awk @@ -26,6 +26,7 @@ BEGIN { if($0 == "done") break if(loop > 10) + print "flag update failed" | "logger -t xcat -p local4.info" break }