diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index e5f6d4e5707..d88e55c1ed5 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -33,6 +33,7 @@ https://github.com/elastic/beats/compare/v6.2.2...6.2[Check the HEAD diff] *Affecting all Beats* - Avoid panic errors when processing nil Pod events in add_kubernetes_metadata. {issue}6372[6372] +- Fix infinite failure on Kubernetes watch {pull}6504[6504] *Auditbeat* diff --git a/libbeat/common/kubernetes/watcher.go b/libbeat/common/kubernetes/watcher.go index 9e900930a5c..c464b738b5b 100644 --- a/libbeat/common/kubernetes/watcher.go +++ b/libbeat/common/kubernetes/watcher.go @@ -152,17 +152,14 @@ func (p *podWatcher) watch() { _, apiPod, err := watcher.Next() if err != nil { logp.Err("kubernetes: Watching API error %v", err) + watcher.Close() - // In case of EOF, stop watching and restart the process - if err == io.EOF || err == io.ErrUnexpectedEOF { - watcher.Close() - backoff(failures) - failures++ - break + if !(err == io.EOF || err == io.ErrUnexpectedEOF) { + // This is an error event which can be recovered by moving to the latest resource verison + logp.Info("kubernetes: Ignoring event, moving to most recent resource version") + p.lastResourceVersion = "" } - - // Otherwise, this is probably an unknown event (unmarshal error), ignore it - continue + break } // Update last resource version and reset failure counter