From 50ab684551d48aa496018425645d28b87a0b074f Mon Sep 17 00:00:00 2001 From: Jaime Soriano Pastor Date: Tue, 5 Mar 2019 13:33:18 +0100 Subject: [PATCH] Log EOFs found on Kubernetes watcher at debug level (#10988) EOFs received when watching Kubernetes events can be recovered by reconnecting, and they don't need to be harmful. So log them at the debug level. --- CHANGELOG.next.asciidoc | 1 + libbeat/common/kubernetes/watcher.go | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index 758919d6fcc5..12e436b71bb2 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -135,6 +135,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d - Allow to configure Kafka fetching strategy for the topic metadata. {pull}10682[10682] - Using an environment variable for the password when enrolling a beat will now raise an error if the variable doesn't exist. {pull}10936[10936] - Add missing `host.containerized` and `host.os.build` to fields.ecs.yml. {pull}11016[11016] +- Reconnections of Kubernetes watchers are now logged at debug level when they are harmless. {pull}10988[10988] *Auditbeat* diff --git a/libbeat/common/kubernetes/watcher.go b/libbeat/common/kubernetes/watcher.go index 6bcad2f226fc..32e2340c8205 100644 --- a/libbeat/common/kubernetes/watcher.go +++ b/libbeat/common/kubernetes/watcher.go @@ -255,12 +255,17 @@ func (w *watcher) watch() { r := w.k8sResourceFactory() eventType, err := watcher.Next(r) if err != nil { - logp.Err("kubernetes: Watching API error %v", err) watcher.Close() - if !(err == io.EOF || err == io.ErrUnexpectedEOF) { + switch err { + case io.EOF: + logp.Debug("kubernetes", "EOF while watching API") + case io.ErrUnexpectedEOF: + logp.Info("kubernetes: Unexpected EOF while watching API") + default: // This is an error event which can be recovered by moving to the latest resource version - logp.Info("kubernetes: Ignoring event, moving to most recent resource version") + logp.Err("kubernetes: Watching API error %v, ignoring event and moving to most recent resource version", err) w.lastResourceVersion = "" + } break }