Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[warm reboot] Warm Reboot Support for EVPN VXLAN #350

Merged
merged 3 commits into from
Oct 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 39 additions & 1 deletion common/warm_restart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -181,6 +184,41 @@ bool WarmStart::isSystemWarmRebootEnabled(void)
return warmStart.m_systemWarmRebootEnabled;
}

void WarmStart::getWarmStartState(const std::string &app_name, WarmStartState &state)
Copy link
Contributor

@qiluo-msft qiluo-msft Sep 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WarmStartState [](start = 63, length = 14)

Why not just return this state? #WontFix

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't see any issue with pass by reference. Will consider that while updating other files where this api is used.

{
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;
Copy link
Contributor

@qiluo-msft qiluo-msft Sep 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

state = WSUNKNOWN; [](start = 4, length = 18)

Is it expected state in runtime? If not, just throw an exception. #Closed

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is expected. When Module A check for the status of Module B, module B may not have reached/initialised to any state yet. Hence module A needs to know that Module B is not ready yet an act accordingly.


for (auto 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)
{
Expand Down
6 changes: 6 additions & 0 deletions common/warm_restart.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ class WarmStart
{
INITIALIZED,
RESTORED,
REPLAYED,
RECONCILED,
WSDISABLED,
WSUNKNOWN,
};

enum DataCheckState
Expand Down Expand Up @@ -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);

Expand Down