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

Remove deprecated --template and --index-policy flags #28870

Merged
merged 4 commits into from
Nov 23, 2021
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.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- add_process_metadata processor: Replace usage of deprecated `process.ppid` field with `process.parent.pid`. {pull}28620[28620]
- add_docker_metadata processor: Replace usage of deprecated `process.ppid` field with `process.parent.pid`. {pull}28620[28620]
- Index template's default_fields setting is only populated with ECS fields. {pull}28596[28596] {issue}28215[28215]
- Remove deprecated `--template` and `--ilm-policy` flags. Use `--index-management` instead. {pull}28870[28870]
- Remove options `logging.files.suffix` and default to datetime endings. {pull}28927[28927]

*Auditbeat*
Expand Down
6 changes: 3 additions & 3 deletions auditbeat/tests/system/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ def test_start_stop(self):
assert self.log_contains("auditbeat stopped")

@unittest.skipUnless(INTEGRATION_TESTS, "integration test")
def test_template(self):
def test_index_management(self):
"""
Test that the template can be loaded with `setup --template`
Test that the template can be loaded with `setup --index-management`
"""
dirs = [self.temp_dir("auditbeat_test")]
with PathCleanup(dirs):
Expand All @@ -51,7 +51,7 @@ def test_template(self):
}
}],
elasticsearch={"host": self.get_elasticsearch_url()})
self.run_beat(extra_args=["setup", "--template"], exit_code=0)
self.run_beat(extra_args=["setup", "--index-management"], exit_code=0)

assert self.log_contains('Loaded index template')
assert len(es.cat.templates(name='auditbeat-*', h='name')) > 0
Expand Down
22 changes: 3 additions & 19 deletions filebeat/tests/system/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,31 +28,15 @@ def test_base(self):
assert "input.type" in output

@unittest.skipUnless(INTEGRATION_TESTS, "integration test")
def test_template(self):
def test_index_management(self):
"""
Test that the template can be loaded with `setup --template`
Test that the template can be loaded with `setup --index-management`
"""
es = Elasticsearch([self.get_elasticsearch_url()])
self.render_config_template(
elasticsearch={"host": self.get_elasticsearch_url()},
)
exit_code = self.run_beat(extra_args=["setup", "--template"])

assert exit_code == 0
assert self.log_contains('Loaded index template')
assert len(es.cat.templates(name='filebeat-*', h='name')) > 0

@unittest.skipUnless(INTEGRATION_TESTS, "integration test")
def test_template_migration(self):
"""
Test that the template can be loaded with `setup --template`
"""
es = Elasticsearch([self.get_elasticsearch_url()])
self.render_config_template(
elasticsearch={"host": self.get_elasticsearch_url()},
)
exit_code = self.run_beat(extra_args=["setup", "--template",
"-E", "setup.template.overwrite=true", "-E", "migration.6_to_7.enabled=true"])
exit_code = self.run_beat(extra_args=["setup", "--index-management"])

assert exit_code == 0
assert self.log_contains('Loaded index template')
Expand Down
5 changes: 0 additions & 5 deletions heartbeat/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package cmd

import (
"fmt"

// include all heartbeat specific autodiscovery builders
_ "github.com/elastic/beats/v7/heartbeat/autodiscover/builder/hints"
Expand Down Expand Up @@ -80,10 +79,6 @@ func Initialize(settings instance.Settings) *cmd.BeatsRootCmd {
`
setup.ResetFlags()
setup.Flags().Bool(cmd.IndexManagementKey, false, "Setup all components related to Elasticsearch index management, including template, ilm policy and rollover alias")
setup.Flags().MarkDeprecated(cmd.TemplateKey, fmt.Sprintf("use --%s instead", cmd.IndexManagementKey))
setup.Flags().MarkDeprecated(cmd.ILMPolicyKey, fmt.Sprintf("use --%s instead", cmd.IndexManagementKey))
setup.Flags().Bool(cmd.TemplateKey, false, "Setup index template")
setup.Flags().Bool(cmd.ILMPolicyKey, false, "Setup ILM policy")

return rootCmd
}
Expand Down
6 changes: 3 additions & 3 deletions heartbeat/tests/system/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,9 @@ def run_fields(self, expected, local=None, top=None):
return doc

@unittest.skipUnless(INTEGRATION_TESTS, "integration test")
def test_template(self):
def test_index_management(self):
"""
Test that the template can be loaded with `setup --template`
Test that the template can be loaded with `setup --index-management`
"""
es = Elasticsearch([self.get_elasticsearch_url()])
self.render_config_template(
Expand All @@ -206,7 +206,7 @@ def test_template(self):
}],
elasticsearch={"host": self.get_elasticsearch_url()},
)
exit_code = self.run_beat(extra_args=["setup", "--template"])
exit_code = self.run_beat(extra_args=["setup", "--index-management"])

assert exit_code == 0
assert self.log_contains('Loaded index template')
Expand Down
20 changes: 0 additions & 20 deletions libbeat/cmd/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,6 @@ const (
PipelineKey = "pipelines"
//IndexManagementKey used for loading all components related to ES index management in setup cmd
IndexManagementKey = "index-management"

//TemplateKey used for loading template in setup cmd
//
//Deprecated: use IndexManagementKey instead
TemplateKey = "template"

//ILMPolicyKey used for loading ilm in setup cmd
//
//Deprecated: use IndexManagementKey instead
ILMPolicyKey = "ilm-policy"
)

func genSetupCmd(settings instance.Settings, beatCreator beat.Creator) *cobra.Command {
Expand All @@ -68,8 +58,6 @@ func genSetupCmd(settings instance.Settings, beatCreator beat.Creator) *cobra.Co
DashboardKey: false,
PipelineKey: false,
IndexManagementKey: false,
TemplateKey: false,
ILMPolicyKey: false,
}
var setupAll = true

Expand Down Expand Up @@ -100,10 +88,6 @@ func genSetupCmd(settings instance.Settings, beatCreator beat.Creator) *cobra.Co
s.Pipeline = true
case IndexManagementKey:
s.IndexManagement = true
case ILMPolicyKey:
s.ILMPolicy = true
case TemplateKey:
s.Template = true
}
}
}
Expand All @@ -118,10 +102,6 @@ func genSetupCmd(settings instance.Settings, beatCreator beat.Creator) *cobra.Co
setup.Flags().Bool(PipelineKey, false, "Setup Ingest pipelines")
setup.Flags().Bool(IndexManagementKey, false,
"Setup all components related to Elasticsearch index management, including template, ilm policy and rollover alias")
setup.Flags().Bool(TemplateKey, false, "Setup index template")
setup.Flags().MarkDeprecated(TemplateKey, fmt.Sprintf("please use --%s instead", IndexManagementKey))
setup.Flags().Bool(ILMPolicyKey, false, "Setup ILM policy")
setup.Flags().MarkDeprecated(ILMPolicyKey, fmt.Sprintf("please use --%s instead", IndexManagementKey))

return &setup
}
10 changes: 0 additions & 10 deletions libbeat/docs/command-reference.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -802,16 +802,6 @@ ifdef::apm-server[]
Registers the <<configuring-ingest-node,pipeline>> definitions set in `ingest/pipeline/definition.json`.
endif::apm-server[]

*`--template`*::
deprecated:[7.2]
Sets up the index template only.
It is recommended to use `--index-management` instead.

*`--ilm-policy`*::
deprecated:[7.2]
Sets up the index lifecycle management policy.
It is recommended to use `--index-management` instead.

{global-flags}

*EXAMPLES*
Expand Down
17 changes: 0 additions & 17 deletions libbeat/tests/system/test_ilm.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,23 +191,6 @@ def render_config(self, **kwargs):
**kwargs
)

@unittest.skipUnless(INTEGRATION_TESTS, "integration test")
@pytest.mark.tag('integration')
def test_setup_ilm_policy_and_template(self):
"""
Test combination of ilm policy and template setup
"""
self.render_config()

# NOTE: --template is deprecated for 8.0.0./
exit_code = self.run_beat(logging_args=["-v", "-d", "*"],
extra_args=["setup", self.setupCmd, "--template"])

assert exit_code == 0
self.idxmgmt.assert_ilm_template_loaded(self.alias_name, self.policy_name, self.alias_name)
self.idxmgmt.assert_alias_created(self.alias_name)
self.idxmgmt.assert_policy_created(self.policy_name)

@unittest.skipUnless(INTEGRATION_TESTS, "integration test")
@pytest.mark.tag('integration')
def test_setup_ilm_default(self):
Expand Down
8 changes: 2 additions & 6 deletions libbeat/tests/system/test_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def setUp(self):
super(TestCommandSetupTemplate, self).setUp()

# auto-derived default settings, if nothing else is set
self.setupCmd = "--template"
self.setupCmd = "--index-management"
self.index_name = self.beat_name + "-9.9.9"
self.custom_alias = self.beat_name + "_foo"
self.policy_name = self.beat_name
Expand Down Expand Up @@ -209,7 +209,7 @@ def test_setup(self):
"""
self.render_config()
exit_code = self.run_beat(logging_args=["-v", "-d", "*"],
extra_args=["setup", self.setupCmd, "--ilm-policy"])
extra_args=["setup", self.setupCmd])

assert exit_code == 0
self.idxmgmt.assert_ilm_template_loaded(self.index_name, self.policy_name, self.index_name)
Expand All @@ -230,8 +230,6 @@ def test_setup_template_default(self):
self.idxmgmt.assert_ilm_template_loaded(self.index_name, self.policy_name, self.index_name)
self.idxmgmt.assert_index_template_index_pattern(self.index_name, [self.index_name + "-*"])

# when running `setup --template`
# write_alias and rollover_policy related to ILM are also created
self.idxmgmt.assert_alias_created(self.index_name)
self.idxmgmt.assert_policy_created(self.policy_name)

Expand All @@ -249,8 +247,6 @@ def test_setup_template_disabled(self):
assert exit_code == 0
self.idxmgmt.assert_index_template_not_loaded(self.index_name)

# when running `setup --template` and `setup.template.enabled=false`
# write_alias and rollover_policy related to ILM are still created
self.idxmgmt.assert_alias_created(self.index_name)
self.idxmgmt.assert_policy_created(self.policy_name)

Expand Down
8 changes: 4 additions & 4 deletions metricbeat/tests/system/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ def test_start_stop(self):
assert self.log_contains("metricbeat stopped")

@unittest.skipUnless(INTEGRATION_TESTS, "integration test")
def test_template(self):
def test_index_management(self):
"""
Test that the template can be loaded with `setup --template`
Test that the template can be loaded with `setup --index-management`
"""
es = Elasticsearch([self.get_elasticsearch_url()])
self.render_config_template(
Expand All @@ -52,7 +52,7 @@ def test_template(self):
}],
elasticsearch={"host": self.get_elasticsearch_url()},
)
exit_code = self.run_beat(extra_args=["setup", "--template", "-E", "setup.template.overwrite=true"])
exit_code = self.run_beat(extra_args=["setup", "--index-management", "-E", "setup.template.overwrite=true"])

assert exit_code == 0
assert self.log_contains('Loaded index template')
Expand Down Expand Up @@ -100,7 +100,7 @@ def test_migration(self):
}],
elasticsearch={"host": self.get_elasticsearch_url()},
)
exit_code = self.run_beat(extra_args=["setup", "--template",
exit_code = self.run_beat(extra_args=["setup", "--index-management",
"-E", "setup.template.overwrite=true", "-E", "migration.6_to_7.enabled=true"])

assert exit_code == 0
Expand Down