Skip to content

Commit

Permalink
Fix NewContainerMetadataEnricher to use default config for kubernetes…
Browse files Browse the repository at this point in the history
… module. (elastic#16857)

* Fix code to use default config for resource metadata.

* Add changelog entry.

(cherry picked from commit 5c38912)
  • Loading branch information
blakerouse committed Mar 6, 2020
1 parent 071ff16 commit d5e18af
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 8 deletions.
19 changes: 19 additions & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,25 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d

*Affecting all Beats*

- Fix `add_cloud_metadata` to better support modifying sub-fields with other processors. {pull}13808[13808]
- TLS or Beats that accept connections over TLS and validate client certificates. {pull}14146[14146]
- Fix panics that could result from invalid TLS certificates. This can affect Beats that connect over TLS, or Beats that accept connections over TLS and validate client certificates. {pull}14146[14146]
- Fix panic in the Logstash output when trying to send events to closed connection. {pull}15568[15568]
- Fix missing output in dockerlogbeat {pull}15719[15719]
- Fix logging target settings being ignored when Beats are started via systemd or docker. {issue}12024[12024] {pull}15422[15442]
- Do not load dashboards where not available. {pull}15802[15802]
- Fix issue where TLS settings would be ignored when a forward proxy was in use. {pull}15516{15516}
- Update replicaset group to apps/v1 {pull}15854[15802]
- Fix issue where default go logger is not discarded when either * or stdout is selected. {issue}10251[10251] {pull}15708[15708]
- Upgrade go-ucfg to latest v0.8.1. {pull}15937{15937}
- Fix index names for indexing not always guaranteed to be lower case. {pull}16081[16081]
- Add `ssl.ca_sha256` option to the supported TLS option, this allow to check that a specific certificate is used as part of the verified chain. {issue}15717[15717]
- Fix loading processors from annotation hints. {pull}16348[16348]
- Fix an issue that could cause redundant configuration reloads. {pull}16440[16440]
- Fix k8s pods labels broken schema. {pull}16480[16480]
- Fix k8s pods annotations broken schema. {pull}16554[16554]
- Upgrade go-ucfg to latest v0.8.3. {pull}16450{16450}
- Fix `NewContainerMetadataEnricher` to use default config for kubernetes module. {pull}16857[16857]

*Auditbeat*

Expand Down
11 changes: 5 additions & 6 deletions libbeat/common/kubernetes/metadata/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,11 @@ type AddResourceMetadataConfig struct {
Namespace *common.Config `config:"namespace"`
}

func defaultConfig() Config {
return Config{
IncludeCreatorMetadata: true,
LabelsDedot: true,
AnnotationsDedot: true,
}
// InitDefaults initializes the defaults for the config.
func (c *Config) InitDefaults() {
c.IncludeCreatorMetadata = true
c.LabelsDedot = true
c.AnnotationsDedot = true
}

// Unmarshal unpacks a Config into the metagen Config
Expand Down
2 changes: 1 addition & 1 deletion libbeat/common/kubernetes/metadata/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type Resource struct {

// NewResourceMetadataGenerator creates a metadata generator for a generic resource
func NewResourceMetadataGenerator(cfg *common.Config) *Resource {
config := defaultConfig()
var config Config
config.Unmarshal(cfg)

return &Resource{
Expand Down
5 changes: 4 additions & 1 deletion libbeat/common/kubernetes/metadata/resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"

"github.com/elastic/go-ucfg"

"github.com/elastic/beats/libbeat/common"
"github.com/elastic/beats/libbeat/common/kubernetes"
)
Expand Down Expand Up @@ -109,7 +111,8 @@ func TestResource_Generate(t *testing.T) {
},
}

cfg := defaultConfig()
var cfg Config
ucfg.New().Unpack(&cfg)
metagen := &Resource{
config: &cfg,
}
Expand Down

0 comments on commit d5e18af

Please sign in to comment.