Skip to content

Commit

Permalink
Report faulting file when config reload fails (#11304)
Browse files Browse the repository at this point in the history
* fixed error format to include faulting file,some go lint issues

* changelog updated

* review round 1

* not breaking
  • Loading branch information
michalpristas authored Mar 22, 2019
1 parent 98e0dbe commit 5de8ebb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Include ip and boolean type when generating index pattern. {pull}10995[10995]
- Cancelling enrollment of a beat will not enroll the beat. {issue}10150[10150]
- Add missing fields and test cases for libbeat add_kubernetes_metadata processor. {issue}11133[11133], {pull}11134[11134]
- Report faulting file when config reload fails. {pull}[11304]11304

*Auditbeat*

Expand Down
7 changes: 6 additions & 1 deletion libbeat/cfgfile/reload.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
)

var (
// DefaultDynamicConfig provides default behavior for a Runner.
DefaultDynamicConfig = DynamicConfig{
Reload: Reload{
Period: 10 * time.Second,
Expand All @@ -58,16 +59,20 @@ type DynamicConfig struct {
Reload Reload `config:"reload"`
}

// Reload defines reload behavior and frequency
type Reload struct {
Period time.Duration `config:"period"`
Enabled bool `config:"enabled"`
}

// RunnerFactory is used for creating of new Runners
type RunnerFactory interface {
Create(p beat.Pipeline, config *common.Config, meta *common.MapStrPointer) (Runner, error)
CheckConfig(config *common.Config) error
}

// Runner is a simple interface providing a simple way to
// Start and Stop Reloader
type Runner interface {
// We include fmt.Stringer here because we do log debug messages that must print
// something for the given Runner. We need Runner implementers to consciously implement a
Expand Down Expand Up @@ -220,7 +225,7 @@ func (rl *Reloader) loadConfigs(files []string) ([]*reload.ConfigWithMeta, error
configs, err := LoadList(file)
if err != nil {
errs = append(errs, err)
logp.Err("Error loading config: %s", err)
logp.Err("Error loading config from file '%s', error %v", file, err)
continue
}

Expand Down
4 changes: 3 additions & 1 deletion libbeat/template/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@ import (
"github.com/elastic/beats/libbeat/paths"
)

// TemplateLoader is a subset of the Elasticsearch client API capable of
// ESClient is a subset of the Elasticsearch client API capable of
// loading the template.
type ESClient interface {
Request(method, path string, pipeline string, params map[string]string, body interface{}) (int, []byte, error)
GetVersion() common.Version
}

// Loader is a template loader capable of loading the template using
// Elasticsearch Client API
type Loader struct {
config TemplateConfig
client ESClient
Expand Down

0 comments on commit 5de8ebb

Please sign in to comment.