From 7d424ae7086603eb24a0be1d3eb896984414148f Mon Sep 17 00:00:00 2001 From: Nicolas Ruflin Date: Fri, 31 Mar 2017 15:35:23 +0200 Subject: [PATCH] Remove deprecated config options force_close_files and close_older (#3768) The new close_* options must be used instead. --- CHANGELOG.asciidoc | 1 + filebeat/harvester/config.go | 71 ++++++++------------ filebeat/harvester/config_test.go | 35 ---------- filebeat/tests/system/config/filebeat.yml.j2 | 1 - 4 files changed, 28 insertions(+), 80 deletions(-) delete mode 100644 filebeat/harvester/config_test.go diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index d611343d493..9278092d76a 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -23,6 +23,7 @@ https://github.com/elastic/beats/compare/v5.1.1...master[Check the HEAD diff] *Filebeat* - Always use absolute path for event and registry. This can lead to issues when relative paths were used before. {pull}3328[3328] - Remove code to convert states from 1.x. {pull}3767[3767] +- Remove deprecated config options force_close_files and close_older. {pull}3768[3768] *Heartbeat* diff --git a/filebeat/harvester/config.go b/filebeat/harvester/config.go index 255e0a85ad7..60b4b5de2f7 100644 --- a/filebeat/harvester/config.go +++ b/filebeat/harvester/config.go @@ -6,7 +6,6 @@ import ( cfg "github.com/elastic/beats/filebeat/config" "github.com/elastic/beats/filebeat/harvester/reader" - "github.com/elastic/beats/libbeat/logp" "github.com/dustin/go-humanize" "github.com/elastic/beats/libbeat/common/match" @@ -14,57 +13,41 @@ import ( var ( defaultConfig = harvesterConfig{ - BufferSize: 16 * humanize.KiByte, - InputType: cfg.DefaultInputType, - Backoff: 1 * time.Second, - BackoffFactor: 2, - MaxBackoff: 10 * time.Second, - CloseInactive: 5 * time.Minute, - MaxBytes: 10 * humanize.MiByte, - CloseRemoved: true, - CloseRenamed: false, - CloseEOF: false, - CloseTimeout: 0, - ForceCloseFiles: false, + BufferSize: 16 * humanize.KiByte, + InputType: cfg.DefaultInputType, + Backoff: 1 * time.Second, + BackoffFactor: 2, + MaxBackoff: 10 * time.Second, + CloseInactive: 5 * time.Minute, + MaxBytes: 10 * humanize.MiByte, + CloseRemoved: true, + CloseRenamed: false, + CloseEOF: false, + CloseTimeout: 0, } ) type harvesterConfig struct { - BufferSize int `config:"harvester_buffer_size"` - Encoding string `config:"encoding"` - InputType string `config:"input_type"` - Backoff time.Duration `config:"backoff" validate:"min=0,nonzero"` - BackoffFactor int `config:"backoff_factor" validate:"min=1"` - MaxBackoff time.Duration `config:"max_backoff" validate:"min=0,nonzero"` - CloseInactive time.Duration `config:"close_inactive"` - CloseOlder time.Duration `config:"close_older"` - CloseRemoved bool `config:"close_removed"` - CloseRenamed bool `config:"close_renamed"` - CloseEOF bool `config:"close_eof"` - CloseTimeout time.Duration `config:"close_timeout" validate:"min=0"` - ForceCloseFiles bool `config:"force_close_files"` - ExcludeLines []match.Matcher `config:"exclude_lines"` - IncludeLines []match.Matcher `config:"include_lines"` - MaxBytes int `config:"max_bytes" validate:"min=0,nonzero"` - Multiline *reader.MultilineConfig `config:"multiline"` - JSON *reader.JSONConfig `config:"json"` + BufferSize int `config:"harvester_buffer_size"` + Encoding string `config:"encoding"` + InputType string `config:"input_type"` + Backoff time.Duration `config:"backoff" validate:"min=0,nonzero"` + BackoffFactor int `config:"backoff_factor" validate:"min=1"` + MaxBackoff time.Duration `config:"max_backoff" validate:"min=0,nonzero"` + CloseInactive time.Duration `config:"close_inactive"` + CloseRemoved bool `config:"close_removed"` + CloseRenamed bool `config:"close_renamed"` + CloseEOF bool `config:"close_eof"` + CloseTimeout time.Duration `config:"close_timeout" validate:"min=0"` + ExcludeLines []match.Matcher `config:"exclude_lines"` + IncludeLines []match.Matcher `config:"include_lines"` + MaxBytes int `config:"max_bytes" validate:"min=0,nonzero"` + Multiline *reader.MultilineConfig `config:"multiline"` + JSON *reader.JSONConfig `config:"json"` } func (config *harvesterConfig) Validate() error { - // DEPRECATED: remove in 6.0 - if config.ForceCloseFiles { - config.CloseRemoved = true - config.CloseRenamed = true - logp.Warn("DEPRECATED: force_close_files was set to true. Use close_removed + close_rename") - } - - // DEPRECATED: remove in 6.0 - if config.CloseOlder > 0 { - config.CloseInactive = config.CloseOlder - logp.Warn("DEPRECATED: close_older is deprecated. Use close_inactive") - } - // Check input type if _, ok := cfg.ValidInputType[config.InputType]; !ok { return fmt.Errorf("Invalid input type: %v", config.InputType) diff --git a/filebeat/harvester/config_test.go b/filebeat/harvester/config_test.go deleted file mode 100644 index d7070690e18..00000000000 --- a/filebeat/harvester/config_test.go +++ /dev/null @@ -1,35 +0,0 @@ -package harvester - -import ( - "testing" - "time" - - "github.com/stretchr/testify/assert" -) - -func TestForceCloseFiles(t *testing.T) { - - config := defaultConfig - assert.False(t, config.ForceCloseFiles) - assert.True(t, config.CloseRemoved) - assert.False(t, config.CloseRenamed) - - config.ForceCloseFiles = true - config.Validate() - - assert.True(t, config.ForceCloseFiles) - assert.True(t, config.CloseRemoved) - assert.True(t, config.CloseRenamed) -} - -func TestCloseOlder(t *testing.T) { - - config := defaultConfig - assert.Equal(t, config.CloseOlder, 0*time.Hour) - assert.Equal(t, config.CloseInactive, defaultConfig.CloseInactive) - - config.CloseOlder = 5 * time.Hour - config.Validate() - - assert.Equal(t, config.CloseInactive, 5*time.Hour) -} diff --git a/filebeat/tests/system/config/filebeat.yml.j2 b/filebeat/tests/system/config/filebeat.yml.j2 index ce19ea2a534..778678c63ad 100644 --- a/filebeat/tests/system/config/filebeat.yml.j2 +++ b/filebeat/tests/system/config/filebeat.yml.j2 @@ -23,7 +23,6 @@ filebeat.prospectors: close_renamed: {{close_renamed}} close_eof: {{close_eof}} close_timeout: {{close_timeout}} - force_close_files: {{force_close_files}} clean_inactive: {{clean_inactive}} clean_removed: {{clean_removed}} harvester_limit: {{harvester_limit | default(0) }}