From 804b132605248c803e69ef0571b305d0015e2cce Mon Sep 17 00:00:00 2001 From: Bin Xu Date: Tue, 6 Mar 2018 16:13:02 +0800 Subject: [PATCH] clear cache for IP change case in node discovery(#4890) (#4891) --- perl-xCAT/xCAT/NetworkUtils.pm | 20 ++++++++++++++++++++ xCAT-server/lib/xcat/plugins/aaadiscovery.pm | 3 +++ 2 files changed, 23 insertions(+) diff --git a/perl-xCAT/xCAT/NetworkUtils.pm b/perl-xCAT/xCAT/NetworkUtils.pm index cb01ca93e..e3871e3f4 100755 --- a/perl-xCAT/xCAT/NetworkUtils.pm +++ b/perl-xCAT/xCAT/NetworkUtils.pm @@ -388,6 +388,26 @@ sub getipaddr #------------------------------------------------------------------------------- +=head3 clearcache + Workaround: Clear the IP address cache in case that the long running process + (discovery/install monitor) could work as normal when the node's IP address + is changed. + Globals: + cache: %::hostiphash + Error: + none + Example: + xCAT::NetworkUtils->clearcache(); +=cut + +#------------------------------------------------------------------------------- +sub clearcache +{ + undef %::hostiphash; +} + +#------------------------------------------------------------------------------- + =head3 linklocaladdr Only for IPv6. Takes a mac address, calculate the IPv6 link local address diff --git a/xCAT-server/lib/xcat/plugins/aaadiscovery.pm b/xCAT-server/lib/xcat/plugins/aaadiscovery.pm index e52123d80..55f44162e 100644 --- a/xCAT-server/lib/xcat/plugins/aaadiscovery.pm +++ b/xCAT-server/lib/xcat/plugins/aaadiscovery.pm @@ -8,6 +8,7 @@ BEGIN } use lib "$::XCATROOT/lib/perl"; use xCAT::DiscoveryUtils; +use xCAT::NetworkUtils; sub handled_commands { return { @@ -51,6 +52,8 @@ sub process_request { xCAT::MsgUtils->message("S", "xcat.discovery.aaadiscovery: ($mac) Got a discovery request, attempting to discover the node..."); $req->{discoverymethod}->[0] = 'undef'; $req->{_xcat_clientmac}->[0] = $mac; + #Workaround (#4890) for IP changed cases. + xCAT::NetworkUtils->clearcache(); xCAT::DiscoveryUtils->update_discovery_data($req); return; }