4fc8c96c41
The SNMP plugin ships in the image but logged "pysnmp not installed — SNMP polling disabled" on every poll, so polling never worked. Two coupled defects: 1. The Dockerfile installed only `.[ansible]`, so the `snmp` extra (pysnmp) was never bundled even though the plugin is first-party and shipped. 2. poller.py used the synchronous pysnmp HLAPI (`next(getCmd(...))`), which pysnmp-lextudio 6.x removed — it's asyncio-only now — so even with the dep present, polling would have thrown and silently returned nothing. The 5.x line that still has the sync API isn't safe on the image's Python 3.13. Fix: - Dockerfile: install `.[ansible,snmp]`. - poller.py: `poll_device_sync` → `async def poll_device` on the asyncio HLAPI, with a dual-version import (pysnmp 7.x `pysnmp.hlapi.v3arch.asyncio`/`get_cmd` + async `UdpTransportTarget.create`; pysnmp-lextudio 6.2.x `pysnmp.hlapi.asyncio`/`getCmd` + direct `UdpTransportTarget`) so a dependency bump can't silently re-break it. - scheduler.py: await poll_device directly; drop the run_in_executor wrapper and the now-unused asyncio import. - Add tests/plugins/snmp/test_poller.py covering the version→mpModel mapping, that the poller is a coroutine, and the graceful no-pysnmp path. Note: CI confirms import/load and the no-pysnmp path, but has no SNMP target — live polling against real devices is verified after deploy. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016Jg27rgypiW2efULXJDtMC
46 lines
1.7 KiB
Docker
46 lines
1.7 KiB
Docker
FROM python:3.13-slim
|
|
|
|
RUN DEBIAN_FRONTEND=noninteractive apt-get update \
|
|
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
|
|
iputils-ping \
|
|
# gosu — minimal privilege-drop tool used by entrypoint.sh
|
|
gosu \
|
|
# openssh-client — ansible-playbook reaches remote hosts over ssh
|
|
openssh-client \
|
|
# sshpass — Ansible shells out to it for first-contact password SSH
|
|
# (provisioning a fresh host before the managed key is installed)
|
|
sshpass \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Upgrade pip to suppress the version notice
|
|
RUN pip install --upgrade pip
|
|
|
|
WORKDIR /app
|
|
|
|
COPY pyproject.toml .
|
|
COPY steward/ steward/
|
|
# Bundle the extras whose first-party plugins ship in the image: [ansible] for
|
|
# the playbook runner, [snmp] (pysnmp) for the SNMP poller. Without them those
|
|
# bundled plugins load but silently no-op for want of their runtime dependency.
|
|
RUN pip install --no-cache-dir '.[ansible,snmp]'
|
|
|
|
COPY alembic.ini .
|
|
# First-party plugins ship inside the image (bundled root at /app/plugins).
|
|
# Third-party plugins are mounted at runtime into the external root
|
|
# (STEWARD_PLUGIN_DIR, default /data/plugins).
|
|
COPY plugins/ plugins/
|
|
COPY entrypoint.sh /entrypoint.sh
|
|
RUN chmod +x /entrypoint.sh
|
|
|
|
# Runtime directories — owned by app user. The container starts as root
|
|
# so the entrypoint can fix up /data permissions if needed, then drops to
|
|
# 'app' (uid 1000) via gosu before launching steward.
|
|
RUN useradd -m -u 1000 app \
|
|
&& mkdir -p /data/playbook_cache /data/plugins \
|
|
&& chown -R app:app /data /app
|
|
|
|
EXPOSE 5000
|
|
|
|
ENTRYPOINT ["/entrypoint.sh"]
|
|
CMD ["steward", "--host", "0.0.0.0", "--port", "5000"]
|