Skip to content

Commit

Permalink
PTP Events Generating Redundant Noise for Repeated FREERUN State Tran…
Browse files Browse the repository at this point in the history
…sitions

Signed-off-by: Aneesh Puttur <[email protected]>
  • Loading branch information
aneeshkp committed Oct 21, 2024
1 parent 8f61fa8 commit cb85807
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion plugins/ptp_operator/metrics/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ func (p *PTPEventManager) GenPTPEvent(ptpProfileName string, oStats *stats.Stats
case ptp.HOLDOVER:
return // do nothing for holdover
case ptp.FREERUN:
if lastClockState != ptp.HOLDOVER {
if lastClockState != ptp.FREERUN && lastClockState != ptp.HOLDOVER {
// within range
log.Infof(" publishing event for (profile %s) %s with last state %s and current clock state %s and offset %d for ( Max/Min Threshold %d/%d )",
ptpProfileName, eventResourceName, oStats.LastSyncState(), clockState, ptpOffset, threshold.MaxOffsetThreshold, threshold.MinOffsetThreshold)
Expand Down
5 changes: 5 additions & 0 deletions plugins/ptp_operator/stats/stats_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,8 @@ func TestStats_SetPtpDependentEventState(t *testing.T) {
}, nil, nil)
assert.Equal(t, ptp.FREERUN, s.PtpDependentEventState().CurrentPTPStateEvent)
}

func TestNewStats_EmptyState(t *testing.T) {
s := stats.NewStats("testCfg")
assert.NotEqual(t, ptp.FREERUN, s.LastSyncState())
}

0 comments on commit cb85807

Please sign in to comment.