Skip to content

Commit

Permalink
Add process down indicator for ts2phc
Browse files Browse the repository at this point in the history
Signed-off-by: Aneesh Puttur <[email protected]>
  • Loading branch information
aneeshkp authored and openshift-cherrypick-robot committed Jul 23, 2024
1 parent ad98a17 commit e169019
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
12 changes: 12 additions & 0 deletions pkg/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -871,6 +871,7 @@ func (p *ptpProcess) cmdRun(stdoutToSocket bool) {
} else {
processStatus(nil, p.name, p.messageTag, PtpProcessDown)
}
p.updateGMStatusOnProcessDown(p.name)

time.Sleep(connectionRetryInterval) // Delay to prevent flooding restarts if startup fails
// Don't restart after termination
Expand Down Expand Up @@ -1153,3 +1154,14 @@ func (p *ptpProcess) replaceClockID(input string) (output string) {
output = clockIDRegEx.ReplaceAllString(input, iface)
return output
}

// updateGMStatusOnProcessDown send events when ts2phc process is down by
// send event to EventHandler
func (p *ptpProcess) updateGMStatusOnProcessDown(process string) {
// need to update GM status for following process kill for ts2phc
if process == ts2phcProcessName {
// ts2phc process dead should update GM-STATUS
iface := p.ifaces.GetGMInterface().Name
p.ProcessTs2PhcEvents(faultyOffset, ts2phcProcessName, iface, map[event.ValueType]interface{}{event.PROCESS_STATUS: int64(0)})
}
}
2 changes: 1 addition & 1 deletion pkg/daemon/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ func extractRegularMetrics(configName, processName, output string, ifaces config
}

output = strings.Replace(output, "path", "", 1)
replacer := strings.NewReplacer("[", " ", "]", " ", ":", " ", " phc ", " ", " sys ", "")
replacer := strings.NewReplacer("[", " ", "]", " ", ":", " ", " phc ", " ", " sys ", " ")
output = replacer.Replace(output)

index := strings.Index(output, configName)
Expand Down
1 change: 1 addition & 0 deletions pkg/event/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const (
PHASE_STATUS ValueType = "phase_status"
FREQUENCY_STATUS ValueType = "frequency_status"
NMEA_STATUS ValueType = "nmea_status"
PROCESS_STATUS ValueType = "process_status"
PPS_STATUS ValueType = "pps_status"
GM_INTERFACE_UNKNOWN string = "unknown"
)
Expand Down

0 comments on commit e169019

Please sign in to comment.