Skip to content

Commit 0c257c3

Browse files
rkavitha-hclKAVITHA RAMALINGAM
authored and
KAVITHA RAMALINGAM
committed
gNOI Warm Reboot - rebootbackend changes
1 parent 2a61fcb commit 0c257c3

File tree

6 files changed

+38
-209
lines changed

6 files changed

+38
-209
lines changed

src/sonic-framework/rebootbackend/gnoi_reboot_dbus.h

-72
This file was deleted.

src/sonic-framework/rebootbackend/init_thread.h

-136
This file was deleted.

src/sonic-framework/rebootbackend/reboot_thread.cpp

+29
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,24 @@ 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+
169189
void RebootThread::reboot_thread(void) {
170190
SWSS_LOG_ENTER();
171191

@@ -187,6 +207,15 @@ bool RebootThread::check_start_preconditions(const RebootRequest &request,
187207
request.method() != RebootMethod::WARM) {
188208
response.json_string = "RebootThread: Start rx'd unsupported method";
189209
response.status = swss::StatusCode::SWSS_RC_INVALID_PARAM;
210+
} else if (request.method() == RebootMethod::WARM) {
211+
if (m_status.get_last_reboot_status() ==
212+
RebootStatus_Status::RebootStatus_Status_STATUS_FAILURE) {
213+
// If the last reboot failed with a non-retriable failure, don't retry.
214+
// But, we will allow a cold boot to recover.
215+
response.json_string =
216+
"RebootThread: last WARM reboot failed with non-retriable failure";
217+
response.status = swss::StatusCode::SWSS_RC_FAILED_PRECONDITION;
218+
}
190219
} else if (request.delay() != 0) {
191220
response.json_string = "RebootThread: delayed start not supported";
192221
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
@@ -1,4 +1,5 @@
11
#include "rebootbe.h"
2+
23
#include <google/protobuf/util/json_util.h>
34
#include <unistd.h>
45

@@ -13,6 +14,7 @@
1314
#include "reboot_interfaces.h"
1415
#include "select.h"
1516
#include "status_code_util.h"
17+
#include "warm_restart.h"
1618

1719
namespace rebootbackend {
1820

@@ -46,6 +48,12 @@ void RebootBE::Start() {
4648
s.addSelectable(&m_Done);
4749
s.addSelectable(&m_RebootThreadFinished);
4850

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;

src/sonic-framework/tests/rebootbe_test.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,6 @@ class RebootBEAutoStartTest : public RebootBETest,
201201
public ::testing::WithParamInterface<bool> {
202202
protected:
203203
RebootBEAutoStartTest() {
204-
205204
start_rebootbe();
206205

207206
std::this_thread::sleep_for(std::chrono::milliseconds(50));

0 commit comments

Comments
 (0)