From fe2653760b29e24072853440b6488dc656cd02f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9mi=20V=C3=A1nyi?= Date: Tue, 2 Mar 2021 16:09:12 +0100 Subject: [PATCH 1/2] Use `timed.Periodic` when running the periodic scans of filestream (#24248) --- filebeat/input/filestream/fswatch.go | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/filebeat/input/filestream/fswatch.go b/filebeat/input/filestream/fswatch.go index 2db95427cadb..0b1e5df46f45 100644 --- a/filebeat/input/filestream/fswatch.go +++ b/filebeat/input/filestream/fswatch.go @@ -28,6 +28,7 @@ import ( "github.com/elastic/beats/v7/libbeat/common" "github.com/elastic/beats/v7/libbeat/common/match" "github.com/elastic/beats/v7/libbeat/logp" + "github.com/elastic/go-concert/timed" "github.com/elastic/go-concert/unison" ) @@ -118,16 +119,11 @@ func (w *fileWatcher) Run(ctx unison.Canceler) { // run initial scan before starting regular w.watch(ctx) - ticker := time.NewTicker(w.interval) - defer ticker.Stop() - for { - select { - case <-ctx.Done(): - return - case <-ticker.C: - w.watch(ctx) - } - } + timed.Periodic(ctx, w.interval, func() error { + w.watch(ctx) + + return nil + }) } func (w *fileWatcher) watch(ctx unison.Canceler) { From f4b6a49b527509dfe4286f6c34012418bd526558 Mon Sep 17 00:00:00 2001 From: Michal Pristas Date: Tue, 2 Mar 2021 16:25:44 +0100 Subject: [PATCH 2/2] [Ingest Manager] Uninstall do not fail on state not present (#24290) [Ingest Manager] Uninstall do not fail on state not present (#24290) --- x-pack/elastic-agent/pkg/config/operations/inspector.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/x-pack/elastic-agent/pkg/config/operations/inspector.go b/x-pack/elastic-agent/pkg/config/operations/inspector.go index 6a0697e06846..35164ba649ee 100644 --- a/x-pack/elastic-agent/pkg/config/operations/inspector.go +++ b/x-pack/elastic-agent/pkg/config/operations/inspector.go @@ -39,7 +39,8 @@ func LoadFullAgentConfig(cfgPath string) (*config.Config, error) { if err != nil { return nil, err } else if fleetConfig == nil { - return nil, fmt.Errorf("no fleet config retrieved yet") + // resolving fleet config but not fleet config retrieved yet, returning last applied config + return rawConfig, nil } return config.NewConfigFrom(fleetConfig)