Skip to content

Commit

Permalink
Disable command line flags for module reloading (elastic#5381)
Browse files Browse the repository at this point in the history
Command line flags were taken into account during module reloading which lead to the issue the modules were loaded on startup and when loading from the files.

Closes elastic#5376
  • Loading branch information
ruflin authored and exekias committed Oct 16, 2017
1 parent 2888525 commit aebd47b
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Expand Up @@ -45,6 +45,7 @@ https://github.com/elastic/beats/compare/v6.0.0-beta2...master[Check the HEAD di
*Filebeat*

- Fix default paths for redis 4.0.1 logs on macOS {pull}5173[5173]
- Fix Filebeat not starting if command line and modules configs are used together. {issue}5376[5376]

*Heartbeat*

Expand Down
2 changes: 1 addition & 1 deletion filebeat/beater/filebeat.go
Expand Up @@ -51,7 +51,7 @@ func New(b *beat.Beat, rawConfig *common.Config) (beat.Beater, error) {
return nil, err
}

moduleRegistry, err := fileset.NewModuleRegistry(config.Modules, b.Info.Version)
moduleRegistry, err := fileset.NewModuleRegistry(config.Modules, b.Info.Version, true)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion filebeat/fileset/factory.go
Expand Up @@ -44,7 +44,7 @@ func NewFactory(outlet channel.Factory, registrar *registrar.Registrar, beatVers
// Create creates a module based on a config
func (f *Factory) Create(c *common.Config) (cfgfile.Runner, error) {
// Start a registry of one module:
m, err := NewModuleRegistry([]*common.Config{c}, f.beatVersion)
m, err := NewModuleRegistry([]*common.Config{c}, f.beatVersion, false)
if err != nil {
return nil, err
}
Expand Down
14 changes: 10 additions & 4 deletions filebeat/fileset/modules.go
Expand Up @@ -87,7 +87,7 @@ func newModuleRegistry(modulesPath string,
}

// NewModuleRegistry reads and loads the configured module into the registry.
func NewModuleRegistry(moduleConfigs []*common.Config, beatVersion string) (*ModuleRegistry, error) {
func NewModuleRegistry(moduleConfigs []*common.Config, beatVersion string, init bool) (*ModuleRegistry, error) {
modulesPath := paths.Resolve(paths.Home, "module")

stat, err := os.Stat(modulesPath)
Expand All @@ -96,9 +96,13 @@ func NewModuleRegistry(moduleConfigs []*common.Config, beatVersion string) (*Mod
return &ModuleRegistry{}, nil // empty registry, no error
}

modulesCLIList, modulesOverrides, err := getModulesCLIConfig()
if err != nil {
return nil, err
var modulesCLIList []string
var modulesOverrides *ModuleOverrides
if init {
modulesCLIList, modulesOverrides, err = getModulesCLIConfig()
if err != nil {
return nil, err
}
}
mcfgs := []*ModuleConfig{}
for _, moduleConfig := range moduleConfigs {
Expand All @@ -108,7 +112,9 @@ func NewModuleRegistry(moduleConfigs []*common.Config, beatVersion string) (*Mod
}
mcfgs = append(mcfgs, mcfg)
}

mcfgs, err = appendWithoutDuplicates(mcfgs, modulesCLIList)

if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion filebeat/fileset/modules_test.go
Expand Up @@ -346,7 +346,7 @@ func TestMissingModuleFolder(t *testing.T) {
load(t, map[string]interface{}{"module": "nginx"}),
}

reg, err := NewModuleRegistry(configs, "5.2.0")
reg, err := NewModuleRegistry(configs, "5.2.0", true)
assert.NoError(t, err)
assert.NotNil(t, reg)

Expand Down

0 comments on commit aebd47b

Please sign in to comment.