-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
gNOI Warm Reboot - rebootbackend changes #20786
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
fe023ea
gNOI Cold Reboot - Adding the framework docker in the sonic-buildimage
rkavitha-hcl 0af2d5e
gNOI Cold Reboot - Integrated Rebootbackend changes
rkavitha-hcl ab3ffbe
Integrated tests for cold and warm reboot in rebootbackend
rkavitha-hcl e576e3e
gNOI Cold Reboot - Integrated gNOI repository
rkavitha-hcl 9fc0c1e
Enabling warm reboot and HALT method support in sonic-buildimage in r…
rkavitha-hcl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{% from "dockers/dockerfile-macros.j2" import install_debian_packages, install_python_wheels, copy_files %} | ||
FROM docker-config-engine-bookworm-{{DOCKER_USERNAME}}:{{DOCKER_USERTAG}} | ||
|
||
ARG docker_container_name | ||
RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf | ||
|
||
## Make apt-get non-interactive | ||
ENV DEBIAN_FRONTEND=noninteractive | ||
|
||
RUN apt-get update && \ | ||
apt-get install -f -y \ | ||
libdbus-1-3 \ | ||
libdbus-c++-1-0v5 | ||
|
||
{% if docker_framework_debs.strip() -%} | ||
# Copy locally-built Debian package dependencies | ||
{{ copy_files("debs/", docker_framework_debs.split(' '), "/debs/") }} | ||
|
||
# Install locally-built Debian packages and implicitly install their dependencies | ||
{{ install_debian_packages(docker_framework_debs.split(' ')) }} | ||
{%- endif %} | ||
|
||
RUN apt-get clean -y && \ | ||
apt-get autoclean - && \ | ||
apt-get autoremove -y && \ | ||
rm -rf /debs /var/lib/apt/lists/* /tmp/* ~/.cache/ | ||
|
||
# creating sonic conig_status file. | ||
RUN mkdir -p /var/sonic | ||
RUN echo "# Config files managed by sonic-config-engine" > /var/sonic/config_status | ||
|
||
COPY ["supervisord.conf", "/etc/supervisor/conf.d/"] | ||
COPY ["files/supervisor-proc-exit-listener", "/usr/bin"] | ||
COPY ["critical_processes", "/etc/supervisor"] | ||
|
||
ENTRYPOINT ["/usr/local/bin/supervisord"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
program:rebootbackend |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env bash | ||
|
||
|
||
exec /usr/local/bin/framework --logtostderr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
[supervisord] | ||
logfile_maxbytes=1MB | ||
logfile_backups=2 | ||
loglevel=warn | ||
nodaemon=true | ||
|
||
[eventlistener:dependent-startup] | ||
command=python3 -m supervisord_dependent_startup --log-level warn | ||
autostart=true | ||
autorestart=unexpected | ||
stdout_logfile=syslog | ||
stderr_logfile=syslog | ||
startretries=0 | ||
exitcodes=0,3 | ||
events=PROCESS_STATE | ||
buffer_size=50 | ||
|
||
[eventlistener:supervisor-proc-exit-listener] | ||
command=/usr/bin/supervisor-proc-exit-listener --container-name framework | ||
events=PROCESS_STATE_EXITED | ||
autostart=true | ||
autorestart=unexpected | ||
stdout_logfile=syslog | ||
stderr_logfile=syslog | ||
|
||
[program:rsyslogd] | ||
command=/usr/sbin/rsyslogd -n -iNONE | ||
priority=1 | ||
autostart=false | ||
autorestart=unexpected | ||
stdout_logfile=syslog | ||
stderr_logfile=syslog | ||
dependent_startup=true | ||
|
||
[program:rebootbackend] | ||
command=/usr/bin/rebootbackend | ||
priority=2 | ||
autostart=false | ||
autorestart=true | ||
stdout_logfile=syslog | ||
stderr_logfile=syslog | ||
dependent_startup=true | ||
dependent_startup_wait_for=start:exited |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#include "interfaces.h" | ||
|
||
#include <dbus-c++/dbus.h> // DBus | ||
|
||
#include "reboot_interfaces.h" | ||
|
||
constexpr char kRebootBusName[] = "org.SONiC.HostService.reboot"; | ||
constexpr char kRebootPath[] = "/org/SONiC/HostService/reboot"; | ||
|
||
constexpr char kContainerShutdownBusName[] = | ||
"org.SONiC.HostService.container_shutdown"; | ||
constexpr char kContainerShutdownPath[] = | ||
"/org/SONiC/HostService/container_shutdown"; | ||
|
||
DBus::Connection& HostServiceDbus::getConnection(void) { | ||
static DBus::Connection* connPtr = nullptr; | ||
if (connPtr == nullptr) { | ||
static DBus::BusDispatcher dispatcher; | ||
DBus::default_dispatcher = &dispatcher; | ||
|
||
static DBus::Connection conn = DBus::Connection::SystemBus(); | ||
connPtr = &conn; | ||
} | ||
return *connPtr; | ||
} | ||
|
||
DbusInterface::DbusResponse HostServiceDbus::Reboot( | ||
const std::string& jsonRebootRequest) { | ||
int32_t status; | ||
|
||
DbusReboot reboot_client(getConnection(), kRebootBusName, kRebootPath); | ||
std::string retString; | ||
std::vector<std::string> options; | ||
options.push_back(jsonRebootRequest); | ||
try { | ||
reboot_client.issue_reboot(options, status, retString); | ||
} catch (DBus::Error& ex) { | ||
return DbusResponse{ | ||
DbusStatus::DBUS_FAIL, | ||
"HostServiceDbus::Reboot: failed to call reboot host service"}; | ||
} | ||
|
||
// reboot.py returns 0 for success, 1 for failure | ||
if (status == 0) { | ||
// Successful reboot response is an empty string. | ||
return DbusResponse{DbusStatus::DBUS_SUCCESS, ""}; | ||
} | ||
return DbusResponse{DbusStatus::DBUS_FAIL, retString}; | ||
} | ||
|
||
DbusInterface::DbusResponse HostServiceDbus::RebootStatus( | ||
const std::string& jsonStatusRequest) { | ||
DbusReboot reboot_client(getConnection(), kRebootBusName, kRebootPath); | ||
int32_t status; | ||
std::string retString; | ||
|
||
try { | ||
reboot_client.get_reboot_status(status, retString); | ||
} catch (DBus::Error& ex) { | ||
return DbusResponse{ | ||
DbusStatus::DBUS_FAIL, | ||
"HostServiceDbus::RebootStatus: failed to call reboot status " | ||
"host service"}; | ||
} | ||
|
||
// reboot.py returns 0 for success, 1 for failure | ||
if (status == 0) { | ||
return DbusResponse{DbusStatus::DBUS_SUCCESS, retString}; | ||
} | ||
return DbusResponse{DbusStatus::DBUS_FAIL, retString}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#pragma once | ||
#include <dbus-c++/dbus.h> | ||
|
||
#include <string> | ||
|
||
#include "reboot_dbus.h" // auto generated reboot_proxy | ||
#include "reboot_interfaces.h" | ||
|
||
class DbusReboot : public org::SONiC::HostService::reboot_proxy, | ||
public DBus::IntrospectableProxy, | ||
public DBus::ObjectProxy { | ||
public: | ||
DbusReboot(DBus::Connection& connection, const char* dbus_bus_name_p, | ||
const char* dbus_obj_name_p) | ||
: DBus::ObjectProxy(connection, dbus_obj_name_p, dbus_bus_name_p) {} | ||
}; | ||
|
||
class HostServiceDbus : public DbusInterface { | ||
public: | ||
DbusInterface::DbusResponse Reboot( | ||
const std::string& json_reboot_request) override; | ||
DbusInterface::DbusResponse RebootStatus( | ||
const std::string& json_status_request) override; | ||
|
||
private: | ||
static DBus::Connection& getConnection(void); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?ignore | ||
XML representation of dbus interface created by: sonic-host-services/host_modules/reboot.py | ||
|
||
XML generated on switch by executing: | ||
dbus-send --system --type=method_call --print-reply --dest=org.SONiC.HostService.reboot /org/SONiC/HostService/reboot org.freedesktop.DBus.Introspectable.Introspect | ||
|
||
C++ header file generated by: | ||
sudo apt-get install libdbus-c++-dev | ||
dbusxx-xml2cpp ./reboot.xml --proxy=reboot_dbus.h | ||
?> | ||
|
||
<node name="/org/SONiC/HostService/reboot"> | ||
<interface name="org.freedesktop.DBus.Introspectable"> | ||
<method name="Introspect"> | ||
<arg direction="out" type="s" /> | ||
</method> | ||
</interface> | ||
<interface name="org.SONiC.HostService.reboot"> | ||
<method name="issue_reboot"> | ||
<arg direction="in" type="as" name="options" /> | ||
<arg direction="out" type="i" /> | ||
<arg direction="out" type="s" /> | ||
</method> | ||
<method name="get_reboot_status"> | ||
<arg direction="out" type="i" /> | ||
<arg direction="out" type="s" /> | ||
</method> | ||
</interface> | ||
</node> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#pragma once | ||
|
||
#include <time.h> | ||
|
||
#include "status_code_util.h" | ||
|
||
namespace rebootbackend { | ||
|
||
extern bool sigterm_requested; | ||
struct NotificationResponse { | ||
swss::StatusCode status; | ||
std::string json_string; | ||
}; | ||
|
||
} // namespace rebootbackend |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
|
||
class DbusInterface { | ||
public: | ||
enum class DbusStatus { | ||
DBUS_SUCCESS, | ||
DBUS_FAIL, | ||
}; | ||
|
||
struct DbusResponse { | ||
DbusStatus status; | ||
std::string json_string; | ||
}; | ||
|
||
virtual ~DbusInterface() = default; | ||
virtual DbusResponse Reboot(const std::string& jsonRebootRequest) = 0; | ||
virtual DbusResponse RebootStatus(const std::string& jsonStatusRequest) = 0; | ||
}; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My concern is the name "sonic-framework" too general. Please fix in future PR.