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

Add fast-reboot check for warm-restart common-helper #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions common/schema.h
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ namespace swss {
#define STATE_FDB_TABLE_NAME "FDB_TABLE"
#define STATE_WARM_RESTART_TABLE_NAME "WARM_RESTART_TABLE"
#define STATE_WARM_RESTART_ENABLE_TABLE_NAME "WARM_RESTART_ENABLE_TABLE"
#define STATE_FAST_RESTART_ENABLE_TABLE_NAME "FAST_RESTART_ENABLE_TABLE"
#define STATE_VRF_TABLE_NAME "VRF_TABLE"
#define STATE_VRF_OBJECT_TABLE_NAME "VRF_OBJECT_TABLE"
#define STATE_MGMT_PORT_TABLE_NAME "MGMT_PORT_TABLE"
Expand Down
16 changes: 16 additions & 0 deletions common/warm_restart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ void WarmStart::initialize(const std::string &app_name,
std::unique_ptr<Table>(new Table(warmStart.m_stateDb.get(), STATE_WARM_RESTART_TABLE_NAME));
warmStart.m_cfgWarmRestartTable =
std::unique_ptr<Table>(new Table(warmStart.m_cfgDb.get(), CFG_WARM_RESTART_TABLE_NAME));
warmStart.m_stateFastRestartEnableTable =
std::unique_ptr<Table>(new Table(warmStart.m_stateDb.get(), STATE_FAST_RESTART_ENABLE_TABLE_NAME));

warmStart.m_initialized = true;
}
Expand Down Expand Up @@ -139,6 +141,20 @@ bool WarmStart::checkWarmStart(const std::string &app_name,
return true;
}

/*
* Checks if fast reboot is in progress
*/
bool WarmStart::checkFastReboot()
{
std::string value;

auto& warmStart = getInstance();

// Check system level warm-restart config first
warmStart.m_stateFastRestartEnableTable->hget("system", "enable", value);
Copy link

Choose a reason for hiding this comment

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

@arfeigin what is the behaviour when record is not present in DB? Will it throw an exception?

Copy link
Owner Author

Choose a reason for hiding this comment

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

According to table.cpp implementation it will return false in not present. It might throw an exception if entry exists but value is not a string. I used the same logic used for checkWarmStart.

if (reply->type == REDIS_REPLY_NIL)

return (value == "true");
}

/*
* Obtain the time-interval defined by a warm-restart-capable application
* corresponding to the amount of time required to complete a full-restart cycle.
Expand Down
3 changes: 3 additions & 0 deletions common/warm_restart.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ class WarmStart
const std::string &docker_name,
const bool incr_restore_cnt = true);

static bool checkFastReboot();

static bool isWarmStart(void);

static bool isSystemWarmRebootEnabled(void);
Expand All @@ -78,6 +80,7 @@ class WarmStart
std::unique_ptr<Table> m_stateWarmRestartEnableTable;
std::unique_ptr<Table> m_stateWarmRestartTable;
std::unique_ptr<Table> m_cfgWarmRestartTable;
std::unique_ptr<Table> m_stateFastRestartEnableTable;
bool m_initialized;
bool m_enabled;
bool m_systemWarmRebootEnabled;
Expand Down