getters report a failed read as no data: LLDP returns {}, get_environment returns 0 % CPU and 0 bytes RAM #27

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

What happens

The driver standard says a read that fails raises instead of returning empty data (NetOrk ARCHITECTURE, "Getters read"). Two getters do not:

  1. get_lldp_neighbors / get_lldp_neighbors_detail. _get_lldp_table sends lldpctl -f keyvalue (napalm_openwrt/lldp_mixin.py:78) and keeps only lines containing = (line 85). If lldpd is missing or not running, or lldpctl cannot reach its socket, the error text has no =, and the getter returns {} — the same answer as "no neighbours".
  2. get_environment (napalm_openwrt/system_mixin.py 41-82). If the awk over /proc/stat or cat /proc/meminfo fails or prints something else, the parse errors are swallowed and the defaults are returned:
    cpu_pct = 0.0
    ...
    except (ValueError, AttributeError):
    ...
    mem_total = 0
    
    The result says 0 % CPU and 0 bytes used/available, a plausible-looking value instead of a failure.

Expected

Both raise when the command fails or its output cannot be parsed; {} only when lldpctl ran and listed no neighbour. Test-first: lldpctl answering sh: lldpctl: not found raises; get_environment with unparsable /proc/stat raises.

(The CPU figure being the since-boot average is #10; the getter changing lldpd's config is #8.)

Priority: P3 — wrong figures and silently empty topology on any OpenWrt device where a read fails.

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

## What happens The driver standard says a read that fails raises instead of returning empty data (NetOrk ARCHITECTURE, "Getters read"). Two getters do not: 1. **`get_lldp_neighbors` / `get_lldp_neighbors_detail`.** `_get_lldp_table` sends `lldpctl -f keyvalue` (`napalm_openwrt/lldp_mixin.py:78`) and keeps only lines containing `=` (line 85). If lldpd is missing or not running, or lldpctl cannot reach its socket, the error text has no `=`, and the getter returns `{}` — the same answer as "no neighbours". 2. **`get_environment`** (`napalm_openwrt/system_mixin.py` 41-82). If the `awk` over `/proc/stat` or `cat /proc/meminfo` fails or prints something else, the parse errors are swallowed and the defaults are returned: ```python cpu_pct = 0.0 ... except (ValueError, AttributeError): ... mem_total = 0 ``` The result says 0 % CPU and 0 bytes used/available, a plausible-looking value instead of a failure. ## Expected Both raise when the command fails or its output cannot be parsed; `{}` only when lldpctl ran and listed no neighbour. Test-first: `lldpctl` answering `sh: lldpctl: not found` raises; `get_environment` with unparsable `/proc/stat` raises. (The CPU figure being the since-boot average is #10; the getter changing lldpd's config is #8.) Priority: P3 — wrong figures and silently empty topology on any OpenWrt device where a read fails. 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#27