Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor: Small fixes for add_kubernetes_metadata #7466

Merged
merged 4 commits into from
Jun 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ https://github.com/elastic/beats/compare/v6.2.3...master[Check the HEAD diff]
- Allow index-pattern only setup when setup.dashboards.only_index=true. {pull}7285[7285]
- Fix duplicating dynamic_fields in template when overwriting the template. {pull}7352[7352]
- Fix a panic on the Dissect processor when we have data remaining after the last delimiter. {pull}7449[7449]
- When we fail to build a Kubernetes' indexer or matcher we produce a warning but we don't add them to the execution. {pull}7466[7466]

*Auditbeat*

Expand Down
5 changes: 4 additions & 1 deletion libbeat/processors/add_kubernetes_metadata/indexers.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ type Indexers struct {
// IndexerConstructor builds a new indexer from its settings
type IndexerConstructor func(config common.Config, metaGen kubernetes.MetaGenerator) (Indexer, error)

// NewIndexers builds indexers object
// NewIndexers builds indexers object
func NewIndexers(configs PluginConfig, metaGen kubernetes.MetaGenerator) *Indexers {
indexers := []Indexer{}
for _, pluginConfigs := range configs {
Expand All @@ -74,6 +74,7 @@ func NewIndexers(configs PluginConfig, metaGen kubernetes.MetaGenerator) *Indexe
indexer, err := indexFunc(pluginConfig, metaGen)
if err != nil {
logp.Warn("Unable to initialize indexing plugin %s due to error %v", name, err)
continue
}

indexers = append(indexers, indexer)
Expand Down Expand Up @@ -113,6 +114,8 @@ func (i *Indexers) GetMetadata(pod *kubernetes.Pod) []MetadataIndex {

// Empty returns true if indexers list is empty
func (i *Indexers) Empty() bool {
i.RLock()
defer i.RUnlock()
if len(i.indexers) == 0 {
return true
}
Expand Down
3 changes: 3 additions & 0 deletions libbeat/processors/add_kubernetes_metadata/matchers.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ func NewMatchers(configs PluginConfig) *Matchers {
matcher, err := matchFunc(pluginConfig)
if err != nil {
logp.Warn("Unable to initialize matcher plugin %s due to error %v", name, err)
continue
}

matchers = append(matchers, matcher)
Expand Down Expand Up @@ -89,6 +90,8 @@ func (m *Matchers) MetadataIndex(event common.MapStr) string {
}

func (m *Matchers) Empty() bool {
m.RLock()
defer m.RUnlock()
if len(m.matchers) == 0 {
return true
}
Expand Down