Skip to content

Commit c07b6ce

Browse files
rkavitha-hclKAVITHA RAMALINGAM
authored and
KAVITHA RAMALINGAM
committed
gNOI Warm Reboot - rebootbackend changes
1 parent 4281b25 commit c07b6ce

File tree

7 files changed

+40
-165
lines changed

7 files changed

+40
-165
lines changed

src/sonic-framework/rebootbackend/reboot_thread.cpp

+30-2
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ void RebootThread::do_reboot(void) {
114114

115115
if (m_request.method() == RebootMethod::COLD) {
116116
do_cold_reboot(s);
117+
} else if (m_request.method() == RebootMethod::WARM) {
118+
do_warm_reboot(s);
117119
} else {
118120
// This shouldn't be possible. Reference check_start_preconditions()
119121
SWSS_LOG_ERROR("Received unrecognized method type = %s",
@@ -160,11 +162,28 @@ void RebootThread::do_cold_reboot(swss::Select &s) {
160162
// We shouldn't be here. Platform reboot should've killed us.
161163
log_error_and_set_non_retry_failure("platform failed to reboot");
162164

163-
// Set critical state
164-
//m_critical_interface.report_critical_state("platform failed to reboot");
165165
return;
166166
}
167167

168+
void RebootThread::do_warm_reboot(swss::Select &s) {
169+
SWSS_LOG_ENTER();
170+
SWSS_LOG_NOTICE("Sending warm reboot request to platform");
171+
if (send_dbus_reboot_request() == Progress::EXIT_EARLY) {
172+
return;
173+
}
174+
175+
// Wait for warm reboot. If we return, reboot failed.
176+
if (wait_for_platform_reboot(s) == Progress::EXIT_EARLY) {
177+
return;
178+
}
179+
180+
// We shouldn't be here. Platform reboot should've killed us.
181+
log_error_and_set_non_retry_failure("failed to warm reboot");
182+
183+
return;
184+
}
185+
186+
168187
void RebootThread::reboot_thread(void) {
169188
SWSS_LOG_ENTER();
170189

@@ -187,6 +206,15 @@ bool RebootThread::check_start_preconditions(const RebootRequest &request,
187206
request.method() != RebootMethod::WARM) {
188207
response.json_string = "RebootThread: Start rx'd unsupported method";
189208
response.status = swss::StatusCode::SWSS_RC_INVALID_PARAM;
209+
} else if (request.method() == RebootMethod::WARM) {
210+
if (m_status.get_last_reboot_status() ==
211+
RebootStatus_Status::RebootStatus_Status_STATUS_FAILURE) {
212+
// If the last reboot failed with a non-retriable failure, don't retry.
213+
// But, we will allow a cold boot to recover.
214+
response.json_string =
215+
"RebootThread: last WARM reboot failed with non-retriable failure";
216+
response.status = swss::StatusCode::SWSS_RC_FAILED_PRECONDITION;
217+
}
190218
} else if (request.delay() != 0) {
191219
response.json_string = "RebootThread: delayed start not supported";
192220
response.status = swss::StatusCode::SWSS_RC_INVALID_PARAM;

src/sonic-framework/rebootbackend/reboot_thread.h

+1
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ class RebootThread {
161161
void do_reboot(void);
162162
Progress send_dbus_reboot_request();
163163
void do_cold_reboot(swss::Select &s);
164+
void do_warm_reboot(swss::Select &s);
164165

165166
// Inner loop select handler to wait for platform reboot.
166167
// wait for timeout

src/sonic-framework/rebootbackend/rebootbe.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "reboot_interfaces.h"
1414
#include "select.h"
1515
#include "status_code_util.h"
16+
#include "warm_restart.h"
1617

1718
namespace rebootbackend {
1819

@@ -47,6 +48,14 @@ void RebootBE::Start() {
4748
s.addSelectable(&m_Done);
4849
s.addSelectable(&m_RebootThreadFinished);
4950

51+
52+
if (swss::WarmStart::isWarmStart()) {
53+
SWSS_LOG_NOTICE("Launching init thread for warm start");
54+
SetCurrentStatus(RebManagerStatus::WARM_INIT_WAIT);
55+
} else {
56+
SWSS_LOG_NOTICE("Warm restart not enabled");
57+
}
58+
5059
SWSS_LOG_NOTICE("RebootBE entering operational loop");
5160
while (true) {
5261
swss::Selectable *sel;

src/sonic-framework/rebootbackend/redis_utils.cpp

-80
This file was deleted.

src/sonic-framework/rebootbackend/redis_utils.h

-40
This file was deleted.

src/sonic-framework/tests/rebootbe_test.cpp

-20
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ class RebootBETestWithoutStop : public ::testing::Test {
6464
m_rebootbeReponseChannel(&m_db, REBOOT_RESPONSE_NOTIFICATION_CHANNEL),
6565
m_rebootbe(m_dbus_interface) {
6666
sigterm_requested = false;
67-
// TestUtils::clear_tables(m_db);
6867

6968

7069
m_s.addSelectable(&m_rebootbeReponseChannel);
@@ -76,7 +75,6 @@ class RebootBETestWithoutStop : public ::testing::Test {
7675
}
7776
virtual ~RebootBETestWithoutStop() = default;
7877

79-
8078
void start_rebootbe() {
8179
m_rebootbe_thread =
8280
std::make_unique<std::thread>(&RebootBE::Start, &m_rebootbe);
@@ -214,26 +212,8 @@ class RebootBEAutoStartTest : public RebootBETest,
214212
RebootBEAutoStartTest() {
215213
//force_warm_start_state(GetParam());
216214

217-
/* if (GetParam()) {
218-
EXPECT_CALL(*m_init_thread, Start())
219-
.WillOnce(Return(swss::StatusCode::SWSS_RC_SUCCESS));
220-
EXPECT_CALL(*m_init_thread, Join()).WillOnce(Return(true));
221-
EXPECT_CALL(*m_init_thread, GetResponse())
222-
.WillOnce(Return(default_running_status()))
223-
.WillRepeatedly(Return(default_done_status()));
224-
} else {
225-
EXPECT_CALL(*m_init_thread, GetResponse())
226-
.WillRepeatedly(Return(default_not_started_status()));
227-
} */
228-
229215
start_rebootbe();
230216

231-
/* if (GetParam()) {
232-
get_stack_unfrozen_select().notify();
233-
std::this_thread::sleep_for(std::chrono::milliseconds(50));
234-
get_init_done_select().notify();
235-
} */
236-
237217
std::this_thread::sleep_for(std::chrono::milliseconds(50));
238218
EXPECT_EQ(m_rebootbe.GetCurrentStatus(), RebootBE::RebManagerStatus::IDLE);
239219
}

src/sonic-framework/tests/redis_utils_test.cpp

-23
This file was deleted.

0 commit comments

Comments
 (0)