From 9d77725bc33b230bcc22478fa11f076655461cd1 Mon Sep 17 00:00:00 2001 From: afeigin Date: Mon, 23 Jan 2023 11:15:15 +0000 Subject: [PATCH 1/6] Update restart_waiter_ut --- tests/restart_waiter_ut.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/restart_waiter_ut.cpp b/tests/restart_waiter_ut.cpp index 47e619e48..555fdd81f 100644 --- a/tests/restart_waiter_ut.cpp +++ b/tests/restart_waiter_ut.cpp @@ -31,12 +31,12 @@ class FastBootHelper public: FastBootHelper(): db("STATE_DB", 0) { - db.set(FAST_REBOOT_KEY, "1"); + db.set(FAST_REBOOT_KEY, "enable"); } ~FastBootHelper() { - db.del({FAST_REBOOT_KEY}); + db.set(FAST_REBOOT_KEY, "disable"); } private: DBConnector db; From e962bbff50fdd0f9b28bddded993082d70f8fc2a Mon Sep 17 00:00:00 2001 From: afeigin Date: Tue, 14 Feb 2023 14:28:31 +0000 Subject: [PATCH 2/6] Rename FAST_REBOOT table --- common/restart_waiter.cpp | 2 +- tests/restart_waiter_ut.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/common/restart_waiter.cpp b/common/restart_waiter.cpp index aca1c305b..d19abeaa3 100644 --- a/common/restart_waiter.cpp +++ b/common/restart_waiter.cpp @@ -11,7 +11,7 @@ static const std::string STATE_DB_NAME = "STATE_DB"; static const std::string STATE_DB_SEPARATOR = "|"; static const std::string RESTART_KEY = "system"; static const std::string RESTART_ENABLE_FIELD = "enable"; -static const std::string FAST_REBOOT_TABLE_NAME = "FAST_REBOOT"; +static const std::string FAST_REBOOT_TABLE_NAME = "FAST_RESTART_ENABLE_TABLE"; // waitAdvancedBootDone bool RestartWaiter::waitAdvancedBootDone( diff --git a/tests/restart_waiter_ut.cpp b/tests/restart_waiter_ut.cpp index 555fdd81f..b0a4312c7 100644 --- a/tests/restart_waiter_ut.cpp +++ b/tests/restart_waiter_ut.cpp @@ -12,7 +12,7 @@ using namespace swss; using namespace std; -static const string FAST_REBOOT_KEY = "FAST_REBOOT|system"; +static const string FAST_REBOOT_KEY = "FAST_RESTART_ENABLE_TABLE|system"; static void set_reboot_status(string status, int delay = 0) { From 2b4951a61d5b44208fb2b34543d8d4eb311c8b69 Mon Sep 17 00:00:00 2001 From: afeigin Date: Tue, 28 Feb 2023 19:25:28 +0000 Subject: [PATCH 3/6] update fast-reboot check --- common/restart_waiter.cpp | 12 +++++++++--- common/restart_waiter.h | 4 +++- tests/restart_waiter_ut.cpp | 4 ++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/common/restart_waiter.cpp b/common/restart_waiter.cpp index d19abeaa3..dda53e1d3 100644 --- a/common/restart_waiter.cpp +++ b/common/restart_waiter.cpp @@ -71,7 +71,14 @@ bool RestartWaiter::doWait(DBConnector &stateDb, bool RestartWaiter::isAdvancedBootInProgress(DBConnector &stateDb) { - auto ret = stateDb.hget(STATE_WARM_RESTART_ENABLE_TABLE_NAME + STATE_DB_SEPARATOR + RESTART_KEY, RESTART_ENABLE_FIELD); + return isAdvancedBootInProgress(stateDb); +} + +bool RestartWaiter::isAdvancedBootInProgressHelper(DBConnector &stateDb, + bool checkFastBoot) +{ + string table_name = checkFastBoot ? FAST_REBOOT_TABLE_NAME : STATE_WARM_RESTART_ENABLE_TABLE_NAME; + auto ret = stateDb.hget(table_name + STATE_DB_SEPARATOR + RESTART_KEY, RESTART_ENABLE_FIELD); if (ret) { std::string value = *ret.get(); boost::to_lower(value); @@ -82,8 +89,7 @@ bool RestartWaiter::isAdvancedBootInProgress(DBConnector &stateDb) bool RestartWaiter::isFastBootInProgress(DBConnector &stateDb) { - auto ret = stateDb.get(FAST_REBOOT_TABLE_NAME + STATE_DB_SEPARATOR + RESTART_KEY); - return ret.get() != nullptr; + return isAdvancedBootInProgressHelper(stateDb, true); } bool RestartWaiter::isWarmBootInProgress(swss::DBConnector &stateDb) diff --git a/common/restart_waiter.h b/common/restart_waiter.h index ea9eec7b6..4db8eeec2 100644 --- a/common/restart_waiter.h +++ b/common/restart_waiter.h @@ -20,7 +20,9 @@ class RestartWaiter static bool waitFastBootDone(unsigned int maxWaitSec = 180, unsigned int dbTimeout = 0, bool isTcpConn = false); - + + static bool isAdvancedBootInProgressHelper(swss::DBConnector &stateDb, + bool checkFastBoot = false) static bool isAdvancedBootInProgress(swss::DBConnector &stateDb); static bool isFastBootInProgress(swss::DBConnector &stateDb); static bool isWarmBootInProgress(swss::DBConnector &stateDb); diff --git a/tests/restart_waiter_ut.cpp b/tests/restart_waiter_ut.cpp index b0a4312c7..111ecb5b7 100644 --- a/tests/restart_waiter_ut.cpp +++ b/tests/restart_waiter_ut.cpp @@ -31,12 +31,12 @@ class FastBootHelper public: FastBootHelper(): db("STATE_DB", 0) { - db.set(FAST_REBOOT_KEY, "enable"); + db.hset(FAST_REBOOT_KEY, "enable", "true"); } ~FastBootHelper() { - db.set(FAST_REBOOT_KEY, "disable"); + db.hset(FAST_REBOOT_KEY, "enable", "false"); } private: DBConnector db; From 92c16a72c8b5dd3e6b85cc74822f93a8750ac5ca Mon Sep 17 00:00:00 2001 From: Aryeh Feigin <101218333+arfeigin@users.noreply.github.com> Date: Wed, 1 Mar 2023 00:18:07 +0200 Subject: [PATCH 4/6] Update restart_waiter.cpp --- common/restart_waiter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/restart_waiter.cpp b/common/restart_waiter.cpp index dda53e1d3..95c13c9c1 100644 --- a/common/restart_waiter.cpp +++ b/common/restart_waiter.cpp @@ -77,7 +77,7 @@ bool RestartWaiter::isAdvancedBootInProgress(DBConnector &stateDb) bool RestartWaiter::isAdvancedBootInProgressHelper(DBConnector &stateDb, bool checkFastBoot) { - string table_name = checkFastBoot ? FAST_REBOOT_TABLE_NAME : STATE_WARM_RESTART_ENABLE_TABLE_NAME; + std::string table_name = checkFastBoot ? FAST_REBOOT_TABLE_NAME : STATE_WARM_RESTART_ENABLE_TABLE_NAME; auto ret = stateDb.hget(table_name + STATE_DB_SEPARATOR + RESTART_KEY, RESTART_ENABLE_FIELD); if (ret) { std::string value = *ret.get(); From e82d50b0e853ae1eaf4efc5a63a5902e47b7a77a Mon Sep 17 00:00:00 2001 From: Aryeh Feigin <101218333+arfeigin@users.noreply.github.com> Date: Wed, 1 Mar 2023 11:27:23 +0200 Subject: [PATCH 5/6] Update restart_waiter.h --- common/restart_waiter.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/restart_waiter.h b/common/restart_waiter.h index 4db8eeec2..79268bfbc 100644 --- a/common/restart_waiter.h +++ b/common/restart_waiter.h @@ -22,7 +22,7 @@ class RestartWaiter bool isTcpConn = false); static bool isAdvancedBootInProgressHelper(swss::DBConnector &stateDb, - bool checkFastBoot = false) + bool checkFastBoot = false); static bool isAdvancedBootInProgress(swss::DBConnector &stateDb); static bool isFastBootInProgress(swss::DBConnector &stateDb); static bool isWarmBootInProgress(swss::DBConnector &stateDb); From d658e15ff948240873a5b608545155fbdb8f8a9b Mon Sep 17 00:00:00 2001 From: Aryeh Feigin <101218333+arfeigin@users.noreply.github.com> Date: Wed, 1 Mar 2023 12:03:34 +0200 Subject: [PATCH 6/6] Update restart_waiter.cpp --- common/restart_waiter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/restart_waiter.cpp b/common/restart_waiter.cpp index 95c13c9c1..2fea3b5e0 100644 --- a/common/restart_waiter.cpp +++ b/common/restart_waiter.cpp @@ -71,7 +71,7 @@ bool RestartWaiter::doWait(DBConnector &stateDb, bool RestartWaiter::isAdvancedBootInProgress(DBConnector &stateDb) { - return isAdvancedBootInProgress(stateDb); + return isAdvancedBootInProgressHelper(stateDb); } bool RestartWaiter::isAdvancedBootInProgressHelper(DBConnector &stateDb,