Skip to content

linuxptpdaemon: Lost PTP Port State Metrics After Sidecar Crash #25

@aneeshkp

Description

@aneeshkp

In the current setup with two containers:
The linuxptp-daemon writes PTP port state data via a Unix domain socket.
The cloud-event-proxy sidecar reads the data and exposes it as metrics.

If the sidecar container crashes and restarts, it loses previously received metrics until the next event is pushed. While most PTP events are regularly received, interface role/port state events (e.g., LISTENING, FAULTY, SLAVE, etc.) are not sent frequently, which means metrics may be missing for extended periods — potentially causing monitoring issues or inaccurate system state visibility.

This is critical because port state is required for accurate PTP status interpretation, and missing this can break functionality relying on accurate sync status reporting.

Solution : Enable the sidecar to recover the last known port state on startup without introducing polling or increased CPU usage.
Use a shared file-based state persistence approach:
The linuxptp-daemon writes the latest PTP port state to a file only when it changes.
The cloud-event-proxy sidecar reads this file on startup and uses it to restore metrics instantly.

This solution is:
Lightweight (write-on-change only)
Fast and reliable recovery for sidecar
Implementation Plan:
Mount an emptyDir volume shared between both containers.
The linuxptp-daemon writes to: /shared/ptp_port_state.json
The cloud-event-proxy reads this file during initialization.

Json file example.
{ "boundaryProfile": [ { "port": "ens7fx", "state": "MASTER", "timestamp": "2025-03-31T15:23:02Z" }, { "port": "ens7fx", "state": "LISTENING", "timestamp": "2025-03-31T15:23:02Z" } ], "OCProfile": [ { "port": "ens7fx", "state": "FAULTY", "timestamp": "2025-03-31T15:23:02Z" }, { "port": "ens7fx", "state": "SLAVE", "timestamp": "2025-03-31T15:23:02Z" } ] }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions