Skip to content

Commit fb77fb5

Browse files
rkavitha-hclKAVITHA RAMALINGAM
authored and
KAVITHA RAMALINGAM
committed
gNOI Warm Reboot - rebootbackend changes
1 parent c5e97c9 commit fb77fb5

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

src/sonic-framework/rebootbackend/reboot_thread.cpp

+30
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ void RebootThread::do_reboot(void) {
117117

118118
if (m_request.method() == RebootMethod::COLD) {
119119
do_cold_reboot(s);
120+
} else if (m_request.method() == RebootMethod::WARM) {
121+
do_warm_reboot(s);
120122
} else {
121123
// This shouldn't be possible. Reference check_start_preconditions()
122124
SWSS_LOG_ERROR("Received unrecognized method type = %s",
@@ -166,6 +168,25 @@ void RebootThread::do_cold_reboot(swss::Select &s) {
166168
return;
167169
}
168170

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

@@ -187,6 +208,15 @@ bool RebootThread::check_start_preconditions(const RebootRequest &request,
187208
request.method() != RebootMethod::WARM) {
188209
response.json_string = "RebootThread: Start rx'd unsupported method";
189210
response.status = swss::StatusCode::SWSS_RC_INVALID_PARAM;
211+
} else if (request.method() == RebootMethod::WARM) {
212+
if (m_status.get_last_reboot_status() ==
213+
RebootStatus_Status::RebootStatus_Status_STATUS_FAILURE) {
214+
// If the last reboot failed with a non-retriable failure, don't retry.
215+
// But, we will allow a cold boot to recover.
216+
response.json_string =
217+
"RebootThread: last WARM reboot failed with non-retriable failure";
218+
response.status = swss::StatusCode::SWSS_RC_FAILED_PRECONDITION;
219+
}
190220
} else if (request.delay() != 0) {
191221
response.json_string = "RebootThread: delayed start not supported";
192222
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

+8
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

@@ -46,6 +47,13 @@ void RebootBE::Start() {
4647
s.addSelectable(&m_Done);
4748
s.addSelectable(&m_RebootThreadFinished);
4849

50+
51+
if (swss::WarmStart::isWarmStart()) {
52+
SetCurrentStatus(RebManagerStatus::WARM_INIT_WAIT);
53+
} else {
54+
SWSS_LOG_NOTICE("Warm restart not enabled");
55+
}
56+
4957
SWSS_LOG_NOTICE("RebootBE entering operational loop");
5058
while (true) {
5159
swss::Selectable *sel;

0 commit comments

Comments
 (0)