Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for HALT reboot method #1

Open
wants to merge 1 commit into
base: patch1_branch
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/sonic-framework/rebootbackend/reboot_thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ void RebootThread::do_reboot(void) {

if (m_request.method() == RebootMethod::COLD) {
do_cold_reboot(s);
} else if (m_request.method() == RebootMethod::HALT) {
do_halt_reboot(s);
} else {
// This shouldn't be possible. Reference check_start_preconditions()
SWSS_LOG_ERROR("Received unrecognized method type = %s",
Expand Down Expand Up @@ -163,6 +165,27 @@ void RebootThread::do_cold_reboot(swss::Select &s) {
return;
}

void RebootThread::do_halt_reboot(swss::Select &s) {
SWSS_LOG_ENTER();
SWSS_LOG_NOTICE("Sending halt reboot request to platform");
if (send_dbus_reboot_request() == Progress::EXIT_EARLY) {
return;
}

// Wait for platform to reboot. If we return, reboot failed.
// Logging, error status and monitoring for critical state are handled within.
if (wait_for_platform_reboot(s) == Progress::EXIT_EARLY) {
return;
}

// We shouldn't be here. Platform reboot should've killed us.
log_error_and_set_non_retry_failure("platform failed to reboot");

// Set critical state
m_critical_interface.report_critical_state("platform failed to reboot");
return;
}

void RebootThread::reboot_thread(void) {
SWSS_LOG_ENTER();

Expand Down
3 changes: 2 additions & 1 deletion src/sonic-framework/rebootbackend/reboot_thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class ThreadStatus {
// Number of reboots since active.
m_proto_status.set_count(0);

// RebootMethod is type of of reboot: cold, nsf, warm, fast from a
// RebootMethod is type of of reboot: cold, halt, nsf, warm, fast from a
// RebootRequest
m_proto_status.set_method(gnoi::system::RebootMethod::UNKNOWN);

Expand Down Expand Up @@ -165,6 +165,7 @@ class RebootThread {
void do_reboot(void);
Progress send_dbus_reboot_request();
void do_cold_reboot(swss::Select &s);
void do_halt_reboot(swss::Select &s);

// Inner loop select handler to wait for platform reboot.
// wait for timeout
Expand Down
3 changes: 3 additions & 0 deletions src/sonic-framework/rebootbackend/rebootbe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ NotificationResponse RebootBE::handle_reboot_request(
if (response.status == swss::StatusCode::SWSS_RC_SUCCESS) {
if (request.method() == gnoi::system::RebootMethod::COLD) {
SetCurrentStatus(NsfManagerStatus::COLD_REBOOT_IN_PROGRESS);
} else if (request.method() == gnoi::system::RebootMethod::HALT) {
SetCurrentStatus(NsfManagerStatus::HALT_REBOOT_IN_PROGRESS);
} else if (request.method() == gnoi::system::RebootMethod::NSF) {
SetCurrentStatus(NsfManagerStatus::NSF_REBOOT_IN_PROGRESS);
}
Expand All @@ -191,6 +193,7 @@ bool RebootBE::reboot_allowed(const gnoi::system::RebootMethod reboot_method) {
NsfManagerStatus current_status = GetCurrentStatus();
switch (current_status) {
case NsfManagerStatus::COLD_REBOOT_IN_PROGRESS:
case NsfManagerStatus::HALT_REBOOT_IN_PROGRESS:
case NsfManagerStatus::NSF_REBOOT_IN_PROGRESS: {
return false;
}
Expand Down
1 change: 1 addition & 0 deletions src/sonic-framework/rebootbackend/rebootbe.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class RebootBE {
NSF_INIT_WAIT,
IDLE,
COLD_REBOOT_IN_PROGRESS,
HALT_REBOOT_IN_PROGRESS,
NSF_REBOOT_IN_PROGRESS
};

Expand Down