Skip to content

Commit 383cb08

Browse files
rkavitha-hclBibhuprasad Singh
authored and
Bibhuprasad Singh
committed
gNOI Warm Reboot - rebootbackend changes
1 parent c6fddf0 commit 383cb08

File tree

4 files changed

+40
-3
lines changed

4 files changed

+40
-3
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

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

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

src/sonic-framework/tests/rebootbe_test.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ class RebootBETestWithoutStop : public ::testing::Test {
7474
}
7575
virtual ~RebootBETestWithoutStop() = default;
7676

77-
7877
void start_rebootbe() {
7978
m_rebootbe_thread =
8079
std::make_unique<std::thread>(&RebootBE::Start, &m_rebootbe);

0 commit comments

Comments
 (0)