Commit 13f56428 authored by Andrea Sgambelluri's avatar Andrea Sgambelluri
Browse files

telemetry: drop the gNMI mapping for OC optical devices, release stagger slots

Two corrections to the previous commit.

DEVICEDRIVER_OC is the NETCONF/ncclient driver, so registering
GNMIOpenConfigCollector against OPTICAL_ROADM and OPTICAL_TRANSPONDER
pointed a pygnmi client at a NETCONF endpoint. No collector served those
device types before, so nothing regresses by removing the entry; the
registry is left exactly as it is on develop.

_next_poll_offset_s() took a stagger slot per subscription and nothing
ever gave one back, so the offset handed out for a device grew for the
lifetime of the process: after a hundred subscribe/unsubscribe cycles a
new subscription waited five minutes for its first poll. UnsubscribeState
now returns the slots belonging to the jobs it removed.
parent 35489847
Loading
Loading
Loading
Loading
+0 −13
Changes for src/telemetry/backend/service/collectors/__init__.py: 0 added lines, 13 removed lines.
Original line number Diff line number Diff line
@@ -57,19 +57,6 @@ if LOAD_ALL_DEVICE_DRIVERS:
        ])
    )

if LOAD_ALL_DEVICE_DRIVERS:
    from .gnmi_oc.GnmiOpenConfigCollector import GNMIOpenConfigCollector # pylint: disable=wrong-import-position
    COLLECTORS.append(
        (GNMIOpenConfigCollector, [
            {
                FilterFieldEnum.DEVICE_TYPE: [
                    DeviceTypeEnum.OPTICAL_ROADM,
                    DeviceTypeEnum.OPTICAL_TRANSPONDER
                ],
                FilterFieldEnum.DRIVER     : DeviceDriverEnum.DEVICEDRIVER_OC,
            }
        ]))

if LOAD_ALL_DEVICE_DRIVERS:
    from .netconf_oc.NetconfOCCollector import NetconfOpenConfigCollector # pylint: disable=wrong-import-position
    COLLECTORS.append(
+15 −0
Changes for src/telemetry/backend/service/collectors/netconf_oc/NetconfOCCollector.py: 15 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -73,6 +73,17 @@ def _next_poll_offset_s(address: str, port: int) -> float:
    return slot * _DEVICE_POLL_STAGGER_S


def _release_poll_offsets(address: str, port: int, count: int = 1) -> None:
    """Hand back `count` stagger slots taken by _next_poll_offset_s()."""
    key = (address, port)
    with _device_poll_slot_lock:
        remaining = _device_poll_slot_count.get(key, 0) - count
        if remaining > 0:
            _device_poll_slot_count[key] = remaining
        else:
            _device_poll_slot_count.pop(key, None)


class NetconfOpenConfigCollector(_Collector):
    """
    NETCONF-over-SSH collector for pluggable optical-channel state metrics.
@@ -291,6 +302,10 @@ class NetconfOpenConfigCollector(_Collector):
                return False
            for job_id in job_ids:
                self._scheduler.remove_job(job_id)
            # Give the stagger slots back, or the offset handed to the next
            # subscription on this device grows for the lifetime of the
            # process and its first poll is delayed by that much.
            _release_poll_offsets(self._address, self._port, len(job_ids))
            LOGGER.info("UnsubscribeState: removed jobs %s for key '%s'", job_ids, resource_key)
            return True
        except Exception: