summaryrefslogtreecommitdiffstats
path: root/src/go/plugin/go.d/agent
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-11-09 08:26:49 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-11-09 08:26:49 +0000
commit557d39be2a575c8a340ead48af2fc6e709d52a00 (patch)
tree5f0b3a62a1a0ff8eedf21d5f06ffab03dfac2785 /src/go/plugin/go.d/agent
parentReleasing debian version 1.47.2-1. (diff)
downloadnetdata-557d39be2a575c8a340ead48af2fc6e709d52a00.tar.xz
netdata-557d39be2a575c8a340ead48af2fc6e709d52a00.zip
Merging upstream version 1.47.5.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/go/plugin/go.d/agent')
-rw-r--r--src/go/plugin/go.d/agent/discovery/sd/discoverer/netlisteners/netlisteners.go15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/go/plugin/go.d/agent/discovery/sd/discoverer/netlisteners/netlisteners.go b/src/go/plugin/go.d/agent/discovery/sd/discoverer/netlisteners/netlisteners.go
index 6f536c49e..60dd92cb4 100644
--- a/src/go/plugin/go.d/agent/discovery/sd/discoverer/netlisteners/netlisteners.go
+++ b/src/go/plugin/go.d/agent/discovery/sd/discoverer/netlisteners/netlisteners.go
@@ -84,6 +84,9 @@ type (
cache map[uint64]*cacheItem // [target.Hash]
started chan struct{}
+
+ successRuns int64
+ timeoutRuns int64
}
cacheItem struct {
lastSeenTime time.Time
@@ -118,7 +121,7 @@ func (d *Discoverer) Discover(ctx context.Context, in chan<- []model.TargetGroup
return
case <-tk.C:
if err := d.discoverLocalListeners(ctx, in); err != nil {
- d.Warning(err)
+ d.Error(err)
return
}
}
@@ -128,12 +131,20 @@ func (d *Discoverer) Discover(ctx context.Context, in chan<- []model.TargetGroup
func (d *Discoverer) discoverLocalListeners(ctx context.Context, in chan<- []model.TargetGroup) error {
bs, err := d.ll.discover(ctx)
if err != nil {
- if errors.Is(err, context.Canceled) {
+ if errors.Is(err, context.DeadlineExceeded) {
+ // there is no point in continuing pointless attempts/use cpu
+ // https://github.com/netdata/netdata/discussions/18751#discussioncomment-10908472
+ if d.timeoutRuns++; d.timeoutRuns > 5 && d.successRuns == 0 {
+ return err
+ }
+ d.Warning(err)
return nil
}
return err
}
+ d.successRuns++
+
tgts, err := d.parseLocalListeners(bs)
if err != nil {
return err