feat: restart the host (reboot_host) #13

Merged
christianmanivong merged 1 commits from feat/reboot-host into master 2026-10-06 11:05:44 +00:00
Owner

netOrk asks a driver for reboot_host (napalm-device-types' HostRebootMixin) before it offers a restart. The Linux driver had none, so netOrk could not restart a Linux host at all (netOrk #637). The same goes for OpenMediaVault and QTS, which inherit this driver.

Change

reboot_host runs /sbin/reboot through _run_privileged, detached and two seconds late:

  • the launcher's exit status comes back before the host goes down;
  • closing the session cannot take the restart with it.

A refusal, such as sudo without a password, raises RuntimeError with what the host said and the sudo-password hint.

Verification

  • pytest tests/: 122 tests pass, including TestRebootHost:
    • the method exists on the class;
    • the command is detached and privileged, with the exit marker;
    • a refusal raises;
    • output with no exit status is not a success.
  • ruff: 0 findings before and after. mypy: the same 47 pre-existing errors before and after.
  • Gate test on searxng-01 (netOrk api container, this module injected, /sbin/reboot replaced by touch /tmp/netork-reboot-gate):
    • netOrk's can_reboot says True for the new class;
    • reboot_host returned;
    • the file appeared, owned by root, after 2 s;
    • it was removed afterwards.
netOrk asks a driver for `reboot_host` (napalm-device-types' `HostRebootMixin`) before it offers a restart. The Linux driver had none, so netOrk could not restart a Linux host at all (netOrk #637). The same goes for OpenMediaVault and QTS, which inherit this driver. ## Change `reboot_host` runs `/sbin/reboot` through `_run_privileged`, detached and two seconds late: - the launcher's exit status comes back before the host goes down; - closing the session cannot take the restart with it. A refusal, such as sudo without a password, raises `RuntimeError` with what the host said and the sudo-password hint. ## Verification - `pytest tests/`: 122 tests pass, including `TestRebootHost`: - the method exists on the class; - the command is detached and privileged, with the exit marker; - a refusal raises; - output with no exit status is not a success. - ruff: 0 findings before and after. mypy: the same 47 pre-existing errors before and after. - **Gate test on searxng-01** (netOrk api container, this module injected, `/sbin/reboot` replaced by `touch /tmp/netork-reboot-gate`): - netOrk's `can_reboot` says True for the new class; - `reboot_host` returned; - the file appeared, owned by root, after 2 s; - it was removed afterwards.
christianmanivong added 1 commit 2026-10-06 11:05:38 +00:00
netOrk asks a driver for reboot_host before it offers a restart, and the
Linux driver had none, so a Linux host -- and OpenMediaVault and QTS, which
inherit this driver -- could not be restarted from netOrk at all (netOrk
#637). reboot_host runs /sbin/reboot detached and two seconds late through
_run_privileged: the launcher's exit status comes back before the host goes
down, and closing the session cannot take the restart with it. A refusal
(sudo without a password) raises with what the host said.
christianmanivong merged commit 3571149639 into master 2026-10-06 11:05:44 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: NAPALM/napalm-linux#13