From 8e2d58d66a7ff1e241314c495a4e8aab7797cd25 Mon Sep 17 00:00:00 2001 From: Rajesh Sankaran Date: Wed, 10 Jun 2020 06:53:48 -0700 Subject: [PATCH 1/3] [warm reboot] Warm Reboot Support for EVPN VXLAN 1. Added new enums to WarmStartState 2. Added a new function to get the warm start state. Refer to HLD: https://github.com/Azure/SONiC/pull/437 --- common/warm_restart.cpp | 35 +++++++++++++++++++++++++++++++++++ common/warm_restart.h | 6 ++++++ 2 files changed, 41 insertions(+) diff --git a/common/warm_restart.cpp b/common/warm_restart.cpp index 62aa846c1..9724fc513 100644 --- a/common/warm_restart.cpp +++ b/common/warm_restart.cpp @@ -181,6 +181,41 @@ bool WarmStart::isSystemWarmRebootEnabled(void) return warmStart.m_systemWarmRebootEnabled; } +void WarmStart::getWarmStartState(const std::string &app_name, WarmStartState &state) +{ + //WarmStartStateNameMap::iterator it; + std::string statestr; + + auto& warmStart = getInstance(); + + state = RECONCILED; + + if(!isWarmStart()) + return; + + warmStart.m_stateWarmRestartTable->hget(app_name, "state", statestr); + + /* If warm-start is enabled, state cannot be assumed as Reconciled + * It should be set to unknown + */ + state = WSUNKNOWN; + + for(std::map::const_iterator it = warmStartStateNameMap.begin(); it != warmStartStateNameMap.end(); it++) + { + if(it->second == statestr) + { + state = it->first; + break; + } + } + + SWSS_LOG_INFO("%s warm start state get %s(%d)", + app_name.c_str(), statestr.c_str(), state); + + return; +} + + // Set the WarmStart FSM state for a particular application. void WarmStart::setWarmStartState(const std::string &app_name, WarmStartState state) { diff --git a/common/warm_restart.h b/common/warm_restart.h index dd6bf7c42..f3facaf4f 100644 --- a/common/warm_restart.h +++ b/common/warm_restart.h @@ -16,7 +16,10 @@ class WarmStart { INITIALIZED, RESTORED, + REPLAYED, RECONCILED, + WSDISABLED, + WSUNKNOWN, }; enum DataCheckState @@ -53,6 +56,9 @@ class WarmStart static bool isSystemWarmRebootEnabled(void); + static void getWarmStartState(const std::string &app_name, + WarmStartState &state); + static void setWarmStartState(const std::string &app_name, WarmStartState state); From bb5f793369153b7bf9b6fe380a8855357055e201 Mon Sep 17 00:00:00 2001 From: Nikhil Kelapure Date: Thu, 1 Oct 2020 02:58:55 -0700 Subject: [PATCH 2/3] [warm reboot] Warm Reboot Support for EVPN VXLAN Addressed review comments --- common/warm_restart.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/common/warm_restart.cpp b/common/warm_restart.cpp index 9724fc513..8131a8972 100644 --- a/common/warm_restart.cpp +++ b/common/warm_restart.cpp @@ -10,7 +10,10 @@ const WarmStart::WarmStartStateNameMap WarmStart::warmStartStateNameMap = { {INITIALIZED, "initialized"}, {RESTORED, "restored"}, - {RECONCILED, "reconciled"} + {REPLAYED, "replayed"}, + {RECONCILED, "reconciled"}, + {WSDISABLED, "disabled"}, + {WSUNKNOWN, "unknown"} }; const WarmStart::DataCheckStateNameMap WarmStart::dataCheckStateNameMap = @@ -183,7 +186,6 @@ bool WarmStart::isSystemWarmRebootEnabled(void) void WarmStart::getWarmStartState(const std::string &app_name, WarmStartState &state) { - //WarmStartStateNameMap::iterator it; std::string statestr; auto& warmStart = getInstance(); @@ -200,22 +202,21 @@ void WarmStart::getWarmStartState(const std::string &app_name, WarmStartState &s */ state = WSUNKNOWN; - for(std::map::const_iterator it = warmStartStateNameMap.begin(); it != warmStartStateNameMap.end(); it++) + for(auto it = warmStartStateNameMap.begin(); it != warmStartStateNameMap.end(); it++) { - if(it->second == statestr) - { - state = it->first; - break; - } + if(it->second == statestr) + { + state = it->first; + break; + } } - + SWSS_LOG_INFO("%s warm start state get %s(%d)", app_name.c_str(), statestr.c_str(), state); return; } - // Set the WarmStart FSM state for a particular application. void WarmStart::setWarmStartState(const std::string &app_name, WarmStartState state) { From c009f376c16afb559350380fa38bd5de2dcc4b61 Mon Sep 17 00:00:00 2001 From: Nikhil Kelapure Date: Fri, 9 Oct 2020 04:25:10 -0700 Subject: [PATCH 3/3] [warm reboot] Warm Reboot Support for EVPN VXLAN Addressed review comments --- common/warm_restart.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/common/warm_restart.cpp b/common/warm_restart.cpp index 8131a8972..34da10667 100644 --- a/common/warm_restart.cpp +++ b/common/warm_restart.cpp @@ -192,8 +192,10 @@ void WarmStart::getWarmStartState(const std::string &app_name, WarmStartState &s state = RECONCILED; - if(!isWarmStart()) - return; + if (!isWarmStart()) + { + return; + } warmStart.m_stateWarmRestartTable->hget(app_name, "state", statestr); @@ -202,9 +204,9 @@ void WarmStart::getWarmStartState(const std::string &app_name, WarmStartState &s */ state = WSUNKNOWN; - for(auto it = warmStartStateNameMap.begin(); it != warmStartStateNameMap.end(); it++) + for (auto it = warmStartStateNameMap.begin(); it != warmStartStateNameMap.end(); it++) { - if(it->second == statestr) + if (it->second == statestr) { state = it->first; break;