feat(scheduled-jobs): scheduled jobs through PosixScheduledJobsMixin (#32)
driver / lint (pull_request) Successful in 14s
driver / standard (pull_request) Successful in 16s
driver / types (pull_request) Failing after 26s
driver / test (3.13) (pull_request) Failing after 15s
driver / test (3.12) (pull_request) Failing after 17s
driver / lowest (pull_request) Failing after 16s
driver / build (pull_request) Successful in 28s
driver / security (pull_request) Failing after 35s
CI / driver (pull_request) Failing after 1m6s
driver / publish (pull_request) Skipped

get_scheduled_jobs reads every crontab in /etc/crontabs in one round trip
as root, with the time zone from UCI and each crontab's package from opkg;
manage_scheduled_job enables, disables or runs one now; put_ and
delete_scheduled_job write and remove an application's own job as marked
lines in the user's crontab. BusyBox crond has no /etc/crontab, cron.d,
run-parts, anacron or systemd, so none is read.

OpenWrt's BusyBox differs from what the POSIX mixin assumes, so a few
steps are the driver's own:
- crontab -l says only "can't open" for a missing crontab, as for an
  unreadable one: the file is read directly, a missing one is empty, and
  one that cannot be read is never written.
- crontab FILE exits 0 when it could not write: every write is read back.
- cron is enabled and restarted after each write; OpenWrt does not start
  crond while /etc/crontabs is empty.
- crond has no special times: aliases are written as five fields and
  @reboot is refused.
- crond hands the whole command to sh and takes only SHELL and PATH from
  the crontab, so a run now does the same (% is no stdin).
- there is no su and no timeout before 25.x: another user's job runs
  through start-stop-daemon -c, and the run is bounded by timeout only
  where the router has it.

Every write changes only the job's own line, so the reboot failback line
in /etc/crontabs/root stays as it is.

Requires napalm-device-types 4.26.0.

Closes #32
This commit is contained in:
Christian Manivong committed 2026-11-03 05:45:56 +01:00
1 parent 0380350a4c
commit eeeb46121f
6 files changed
+630 -3

No files matched your search

+15 -2
View File
@@ -8,6 +8,19 @@ recorded here; their history is the git log.
## [Unreleased]
### Added
- Scheduled jobs (NetOrk/netork#1933, #32), through napalm-device-types'
`PosixScheduledJobsMixin`: `get_scheduled_jobs()` reads every crontab in
`/etc/crontabs` -- BusyBox crond has no `/etc/crontab`, `cron.d`, run-parts, anacron
or systemd -- with the time zone from UCI and each crontab's package from `opkg`;
`manage_scheduled_job()` enables, disables or runs one now; `put_scheduled_job()`
and `delete_scheduled_job()` write and remove an application's own job as marked
lines in the user's crontab. Every write changes only the job's own line, is read
back (BusyBox `crontab` exits 0 when it could not write) and leaves cron enabled
and restarted. A run is the command as BusyBox crond runs it (`%` is no stdin),
bounded by `timeout` where the router has it (OpenWrt 25.x); another user's job
runs through `start-stop-daemon -c`, as OpenWrt's BusyBox has no `su`. `@daily` and
the other aliases are written as five fields; `@reboot` is refused, as OpenWrt's
crond has no special times.
- `configure_lldp_agent(interfaces)` (napalm-device-types `LldpAgentMixin`): installs
lldpd where it is missing, writes the interfaces given as lldpd's interface list in
UCI, enables lldpd at boot and restarts it. A VLAN device (`br-ap.10`) is written as
@@ -15,8 +28,8 @@ recorded here; their history is the git log.
to do on every poll (#8). Needs napalm-device-types with `LldpAgentMixin`.
### Changed
- The floor on napalm-device-types is 4.24.0, the first release with what this driver
uses (its shared `lldpctl` parser).
- The floor on napalm-device-types is 4.26.0, the first release with `PosixScheduledJobsMixin`
(it was 4.24.0, for the shared `lldpctl` parser).
- Python 3.12 is the floor (`requires-python = ">=3.12"`): netOrk runs every driver
on 3.12, so 3.10 and 3.11 are no longer tested (NAPALM/driver-standard#6).
- The floor on napalm is 5.1: older releases import `pkg_resources`, which a Python