Skip to content

Commit

Permalink
fix cpu usage and leap
Browse files Browse the repository at this point in the history
Signed-off-by: Aneesh Puttur <[email protected]>
  • Loading branch information
aneeshkp authored and josephdrichard committed Jun 15, 2024
1 parent c729a88 commit 35b92a3
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 17 deletions.
5 changes: 2 additions & 3 deletions addons/intel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ spec:
reportOutput: true
- args:
- "-p"
- "NAV-TIMELS"
- "CFG-MSG,1,38,300"
reportOutput: true
ts2phcOpts: " "
ts2phcConf: |
Expand All @@ -107,8 +107,7 @@ spec:
verbose 1
logging_level 7
ts2phc.pulsewidth 100000000
ts2phc.nmea_serialport /dev/ttyGNSS_1700_0
leapfile /usr/share/zoneinfo/leap-seconds.list
ts2phc.nmea_serialport /dev/gnss0
[ens2f0]
ts2phc.extts_polarity rising
ts2phc.extts_correction 0
Expand Down
1 change: 1 addition & 0 deletions addons/intel/e810.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ func getDefaultUblxCmds() []E810UblxCmds {
ReportOutput: false,
Args: []string{"-p", "CFG-MSG,1,3,1"},
}

// Ublx command to save configuration to storage
cfgSave := E810UblxCmds{
ReportOutput: false,
Expand Down
11 changes: 3 additions & 8 deletions pkg/daemon/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,9 @@ func (dn *Daemon) applyNodePtpProfile(runID int, nodeProfile *ptpv1.PtpProfile)
output.gnss_serial_port = strings.TrimSpace(gnssSerialPort)
section.options["ts2phc.nmea_serialport"] = GPSPIPE_SERIALPORT
}
if _, ok := section.options["leapfile"]; ok || pProcess == ts2phcProcessName { // not required to check process if leapfile is always included
section.options["leapfile"] = fmt.Sprintf("%s/%s", config.DefaultLeapConfigPath, os.Getenv("NODE_NAME"))
}
output.sections[index] = section
}
}
Expand Down Expand Up @@ -524,14 +527,6 @@ func (dn *Daemon) applyNodePtpProfile(runID int, nodeProfile *ptpv1.PtpProfile)
glog.Errorf("Error creating named pipe, GNSS monitoring will not work as expected %s", e.Error())
}

for _, section := range output.sections {
if section.sectionName == "[global]" {
section.options["leapfile"] = fmt.Sprintf("%s/%s", config.DefaultLeapConfigPath, os.Getenv("NODE_NAME"))
break
}
}
// Write ts2phc.x.conf with leap-file path per node name
configOutput, _ = output.renderPtp4lConf()
gpsDaemon := &GPSD{
name: GPSD_PROCESSNAME,
execMutex: sync.Mutex{},
Expand Down
17 changes: 13 additions & 4 deletions pkg/daemon/daemon/gpsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,12 @@ retry:
nStatus := int64(0)
nOffset := int64(99999999)
missedTickers := 0
var timeLs *ublox.TimeLs
for {
select {
case <-ticker.C:
emptyCount := 0
timeLs = nil
for {
//UbloxPollInit only initializes if not running
ublx.UbloxPollInit()
Expand All @@ -249,13 +251,12 @@ retry:
} else if strings.Contains(output, "UBX-NAV-TIMELS") {
emptyCount = 0
missedTickers = 0
lines := []string{}
var lines []string
for i := 0; i < timeLsResultLines; i++ {
line := ublx.UbloxPollPull()
lines = append(lines, line)
}
timeLs := ublox.ExtractLeapSec(lines)
g.leapManager.UbloxLsInd <- *timeLs
timeLs = ublox.ExtractLeapSec(lines)
} else if len(output) == 0 {
emptyCount++
}
Expand All @@ -267,9 +268,17 @@ retry:
}
break
}
}
} // loop ends
g.offset = nOffset
g.sourceLost = false
if timeLs != nil {
select {
case g.leapManager.UbloxLsInd <- *timeLs:
case <-time.After(100 * time.Millisecond):
glog.Infof("failied to send leap event updates")
}
}

switch nStatus >= 3 {
case true:
g.state = event.PTP_LOCKED
Expand Down
2 changes: 1 addition & 1 deletion pkg/daemon/leap/leap-file.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ type LeapFile struct {

func New(kubeclient *kubernetes.Clientset, namespace string) (*LeapManager, error) {
lm := &LeapManager{
UbloxLsInd: make(chan ublox.TimeLs),
UbloxLsInd: make(chan ublox.TimeLs, 2),
Close: make(chan bool),
client: kubeclient,
namespace: namespace,
Expand Down
4 changes: 3 additions & 1 deletion pkg/daemon/ublox/ublox.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ func (u *UBlox) UbloxPollPushThread() {
output, err := u.reader.ReadString('\n')
if err != nil {
u.active = false
glog.Errorf("ublox poll thread error %s", err)
return
} else if len(output) > 0 {
u.buffermutex.Lock()
Expand All @@ -262,7 +263,8 @@ func (u *UBlox) UbloxPollPushThread() {
}

func (u *UBlox) UbloxPollReset() {
u.cmd.Process.Kill()
glog.Info("stopping ublox poll process.")
_ = u.cmd.Process.Kill()
}

// DisableBinary ... disable binary
Expand Down

0 comments on commit 35b92a3

Please sign in to comment.