Skip to content

Commit

Permalink
Merge pull request #3661 from weaveworks/endpoint-tweaks
Browse files Browse the repository at this point in the history
Reduce leaks in probe endpoint reporter
  • Loading branch information
qiell authored Aug 16, 2019
2 parents c8c8dac + eba9f31 commit 55846db
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions probe/endpoint/connection_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ func (t *connectionTracker) ReportConnections(rpt *report.Report) {
ebpfLastFailureTime := t.ebpfLastFailureTime
t.ebpfLastFailureTime = time.Now()

if ebpfLastFailureTime.After(time.Now().Add(-5 * time.Minute)) {
// Multiple failures in the last 5 minutes, fall back to proc parsing
if ebpfLastFailureTime.After(time.Now().Add(-1 * time.Minute)) {
// Multiple failures in the last minute, fall back to proc parsing
log.Warnf("ebpf tracker died again, gently falling back to proc scanning")
t.useProcfs()
} else {
Expand Down
8 changes: 6 additions & 2 deletions probe/endpoint/conntrack.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,16 +135,20 @@ func (c *conntrackWalker) run() {
return
}

defer log.Infof("conntrack exiting")

periodicRestart := time.After(6 * time.Hour)
// Handle conntrack events from netlink socket
for {
select {
case <-periodicRestart:
log.Debugf("conntrack periodic restart")
return
case <-c.quit:
log.Infof("conntrack quit signal - exiting")
stop()
return
case f, ok := <-events:
if !ok {
log.Errorf("conntrack events read failed - exiting")
return
}
if f.Err != nil {
Expand Down
1 change: 1 addition & 0 deletions probe/endpoint/ebpf.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ func newEbpfTracker() (*EbpfTracker, error) {
debugBPF = true
}

tracer.TimestampOffset = 200000 // Delay events by 0.2ms to avoid out-of-order reporting
tracker := &EbpfTracker{
debugBPF: debugBPF,
}
Expand Down

0 comments on commit 55846db

Please sign in to comment.