install_package / uninstall_package decide success by keywords instead of the exit status #28

Closed
opened 2026-11-01 21:44:46 +00:00 by christianmanivong · 0 comments
Owner

What happens

install_package and uninstall_package (napalm_openwrt/packages_mixin.py 203-229) run apk add|del / opkg install|remove and decide success by searching the cleaned output (lines 214 and 228):

success = not any(kw in low for kw in ("error:", "failed", "not found", "unknown package"))

The exit status is never looked at. Failures whose text contains none of the four words read as success — e.g. opkg's dependency failure (Collected errors: / Cannot satisfy the following dependencies for … / Cannot install package …: "errors:" is not "error:"). The reverse also happens: a successful install whose output mentions a file or package containing "failed" reads as a failure.

Same pattern as #3 (manage_service) and #11 (apply_updates), and as NAPALM/napalm-linux#4.

Expected

Append ; echo __RC=$? (the _RC_MARKER the file already uses) and decide by the status alone; keep the output for the message. Test-first: an opkg output with Cannot install package and status 255 is a failure; a status 0 output containing "failed" in a file name is a success.

Priority: P3 — a failed package install (e.g. ensure_package("lldpd")) is reported as done.

Found during the bug sweep of 2026-11-01.

## What happens `install_package` and `uninstall_package` (`napalm_openwrt/packages_mixin.py` 203-229) run `apk add|del` / `opkg install|remove` and decide success by searching the cleaned output (lines 214 and 228): ```python success = not any(kw in low for kw in ("error:", "failed", "not found", "unknown package")) ``` The exit status is never looked at. Failures whose text contains none of the four words read as success — e.g. opkg's dependency failure (`Collected errors:` / `Cannot satisfy the following dependencies for …` / `Cannot install package …`: "errors:" is not "error:"). The reverse also happens: a successful install whose output mentions a file or package containing "failed" reads as a failure. Same pattern as #3 (`manage_service`) and #11 (`apply_updates`), and as NAPALM/napalm-linux#4. ## Expected Append `; echo __RC=$?` (the `_RC_MARKER` the file already uses) and decide by the status alone; keep the output for the message. Test-first: an opkg output with `Cannot install package` and status 255 is a failure; a status 0 output containing "failed" in a file name is a success. Priority: P3 — a failed package install (e.g. `ensure_package("lldpd")`) is reported as done. Found during the bug sweep of 2026-11-01.
christianmanivong added the
prio
P3
bug
labels 2026-11-01 21:44:46 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: NAPALM/napalm-openwrt#28