snmp: the config write ends the shell, so configure_snmp_agent always fails #30

Open
opened 2026-10-22 17:05:18 +00:00 by christianmanivong · 0 comments
Owner

configure_snmp_agent stops at its "configure" step on every Proxmox VE node and reports a failure, although /etc/snmp/snmpd.conf was written. The firewall and start steps never run, so the SNMP fix never completes.

Cause. _write_snmp_agent_config (system_mixin.py:557) hands _step a command that ends in exit $s. _rc wraps every command as { <command>; } 2>&1; echo __PVE_RC=$?. An exit inside { } ends the shell (the API exec path pipes the command into sh, as does the SSH fallback), so __PVE_RC= is never printed. _rc then returns status -1, and _step reports ok: False with an empty output.

Reproduced (2026-10-22) by running the exact command _write_snmp_agent_config produces through sh -c, with install -o root replaced by cp and the target by a scratch file: the file is written, and the output is '', with no __PVE_RC=.

Fix. End the command with [ "$s" -eq 0 ] instead of exit $s, as _write_apt_file does in the branch for NetOrk/netork#1397. Add a test that runs the wrapped command through a real sh, because the existing _Node fake answers __PVE_RC=0 on its own and so hides the bug.

Found while adding apt's proxy to the driver (NetOrk/netork#1397).

Prio: P2 (important and urgent): the SNMP fix fails on every Proxmox node.

`configure_snmp_agent` stops at its "configure" step on every Proxmox VE node and reports a failure, although `/etc/snmp/snmpd.conf` was written. The firewall and start steps never run, so the SNMP fix never completes. **Cause.** `_write_snmp_agent_config` ([system_mixin.py:557](https://git.netork.io/NAPALM/napalm-proxmox/src/commit/03c7cdf/napalm_proxmox/system_mixin.py#L557)) hands `_step` a command that ends in `exit $s`. `_rc` wraps every command as `{ <command>; } 2>&1; echo __PVE_RC=$?`. An `exit` inside `{ }` ends the shell (the API exec path pipes the command into `sh`, as does the SSH fallback), so `__PVE_RC=` is never printed. `_rc` then returns status `-1`, and `_step` reports `ok: False` with an empty output. **Reproduced** (2026-10-22) by running the exact command `_write_snmp_agent_config` produces through `sh -c`, with `install -o root` replaced by `cp` and the target by a scratch file: the file is written, and the output is `''`, with no `__PVE_RC=`. **Fix.** End the command with `[ "$s" -eq 0 ]` instead of `exit $s`, as `_write_apt_file` does in the branch for NetOrk/netork#1397. Add a test that runs the wrapped command through a real `sh`, because the existing `_Node` fake answers `__PVE_RC=0` on its own and so hides the bug. Found while adding apt's proxy to the driver (NetOrk/netork#1397). Prio: P2 (important and urgent): the SNMP fix fails on every Proxmox node.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: NAPALM/napalm-proxmox#30