From e191fa47745ebabec7e5444f945339cbdfd044b7 Mon Sep 17 00:00:00 2001 From: Chris Mark Date: Wed, 2 Sep 2020 17:29:46 +0300 Subject: [PATCH] [Autodiscover] Handle input-not-finished errors in config reload (#20915) (cherry picked from commit 35e6b60fa64830bae8fcc7f417441166ae89f3e2) --- CHANGELOG.next.asciidoc | 2 ++ filebeat/input/log/input.go | 2 +- filebeat/input/runnerfactory.go | 2 +- libbeat/cfgfile/list.go | 7 ++++++- {filebeat/input => libbeat/common}/errors.go | 2 +- 5 files changed, 11 insertions(+), 4 deletions(-) rename {filebeat/input => libbeat/common}/errors.go (98%) diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index 4d24881b951..8a8df10ca5e 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -184,6 +184,8 @@ field. You can revert this change by configuring tags for the module and omittin - [Metricbeat][Kubernetes] Change cluster_ip field from ip to keyword. {pull}20571[20571] - Rename cloud.provider `az` value to `azure` inside the add_cloud_metadata processor. {pull}20689[20689] - Add missing country_name geo field in `add_host_metadata` and `add_observer_metadata` processors. {issue}20796[20796] {pull}20811[20811] +- [Autodiscover] Handle input-not-finished errors in config reload. {pull}20915[20915] +- Explicitly detect missing variables in autodiscover configuration, log them at the debug level. {issue}20568[20568] {pull}20898[20898] *Auditbeat* diff --git a/filebeat/input/log/input.go b/filebeat/input/log/input.go index a1837bbd471..365da416ed3 100644 --- a/filebeat/input/log/input.go +++ b/filebeat/input/log/input.go @@ -175,7 +175,7 @@ func (p *Input) loadStates(states []file.State) error { // In case a input is tried to be started with an unfinished state matching the glob pattern if !state.Finished { - return &input.ErrInputNotFinished{State: state.String()} + return &common.ErrInputNotFinished{State: state.String()} } // Convert state to current identifier if different diff --git a/filebeat/input/runnerfactory.go b/filebeat/input/runnerfactory.go index afd67d4e08a..f4973e47948 100644 --- a/filebeat/input/runnerfactory.go +++ b/filebeat/input/runnerfactory.go @@ -59,7 +59,7 @@ func (r *RunnerFactory) Create( func (r *RunnerFactory) CheckConfig(cfg *common.Config) error { _, err := r.Create(pipeline.NewNilPipeline(), cfg) - if _, ok := err.(*ErrInputNotFinished); ok { + if _, ok := err.(*common.ErrInputNotFinished); ok { // error is related to state, and hence config can be considered valid return nil } diff --git a/libbeat/cfgfile/list.go b/libbeat/cfgfile/list.go index fc50baa3345..9b62d95f6a9 100644 --- a/libbeat/cfgfile/list.go +++ b/libbeat/cfgfile/list.go @@ -92,7 +92,12 @@ func (r *RunnerList) Reload(configs []*reload.ConfigWithMeta) error { for hash, config := range startList { runner, err := createRunner(r.factory, r.pipeline, config) if err != nil { - r.logger.Errorf("Error creating runner from config: %s", err) + if _, ok := err.(*common.ErrInputNotFinished); ok { + // error is related to state, we should not log at error level + r.logger.Debugf("Error creating runner from config: %s", err) + } else { + r.logger.Errorf("Error creating runner from config: %s", err) + } errs = append(errs, errors.Wrap(err, "Error creating runner from config")) continue } diff --git a/filebeat/input/errors.go b/libbeat/common/errors.go similarity index 98% rename from filebeat/input/errors.go rename to libbeat/common/errors.go index 098156abf91..68fecb8f550 100644 --- a/filebeat/input/errors.go +++ b/libbeat/common/errors.go @@ -15,7 +15,7 @@ // specific language governing permissions and limitations // under the License. -package input +package common import ( "fmt"