Tara Nath Subedi 17180131d1 PTP fix: read-function of plugin python.ptp failed.
After ptp4l instance stopped, collectd log shows: "read-function of
plugin python.ptp failed", with StopIteration exception on next(
iter(upstream_time_status)). PMC query on stopped ptp4l instance
results empty dictionary, causing StopIteration exception.

This commit handles exceptions in check_ptp_regular when upstream
ptp4l instance is down or returns empty responses with 'sending:'
lines.

Changes:
- Strip leading whitespace in query_pmc_indexed before parsing index
  to handle indented responses
- Add null check for upstream_identity to prevent StopIteration when
  query_pmc_indexed returns empty dict
- Add conditional check before accessing upstream_gm_identity to
  prevent KeyError
- Update clock_locked logic to verify upstream_identity exists before
  comparison

Unit tests has been added.
- test_with_upstream_instance_down
- test_with_upstream_instance_locked

Test-Plan: PASS
- test_with_upstream_instance_down: Verify nolock alarm raised when
  upstream instance is down
- test_with_upstream_instance_locked: Verify clock_locked=True and
  time drift check when upstream is locked to remote GM
- Deploy PTP T-BC with ptp4ls and phc2sys instances, with ts2phc
  generic and clock instances: upstream and downstream ptp instances
  - stopping ptp4l instances has no issue on collectd.log
  - stopping upstream ptp instance service, generates no-lock alarm on
    downstream ptp instance
  - starting upstream ptp service, clears no-lock alarm on downstream

Closes-Bug: 2142143

Change-Id: I8adb217c0331f3819f8e929bd34249dc2f9f7848
Signed-off-by: Tara Nath Subedi <tara.subedi@windriver.com>
2026-02-19 14:57:40 -05:00
2025-12-20 04:51:22 +00:00
2019-09-09 14:37:23 -05:00
2019-09-09 14:37:23 -05:00
2019-09-09 14:37:23 -05:00
Description
StarlingX system monitoring and repoting tools
4.9 MiB
Languages
Python 85.7%
Perl 13.1%
Makefile 1%
Shell 0.1%