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
Changes from 1 commit
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
Next Next commit
Remove deprecated --template and --index-policy flags
  • Loading branch information
kvch committed Nov 8, 2021

Verified

This commit was signed with the committer’s verified signature. The key has expired.
addaleax Anna Henningsen
commit fc669a1b5d187fb3bf7525f9ff01a85c2e9f96cd
6 changes: 3 additions & 3 deletions auditbeat/tests/system/test_base.py
Original file line number Diff line number Diff line change
@@ -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):
@@ -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
22 changes: 3 additions & 19 deletions filebeat/tests/system/test_base.py
Original file line number Diff line number Diff line change
@@ -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')
5 changes: 0 additions & 5 deletions heartbeat/cmd/root.go
Original file line number Diff line number Diff line change
@@ -18,7 +18,6 @@
package cmd

import (
"fmt"

// include all heartbeat specific autodiscovery builders
_ "github.com/elastic/beats/v7/heartbeat/autodiscover/builder/hints"
@@ -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
}
6 changes: 3 additions & 3 deletions heartbeat/tests/system/test_base.py
Original file line number Diff line number Diff line change
@@ -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(
@@ -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')
20 changes: 0 additions & 20 deletions libbeat/cmd/setup.go
Original file line number Diff line number Diff line change
@@ -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 {
@@ -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

@@ -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
}
}
}
@@ -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
@@ -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*
17 changes: 0 additions & 17 deletions libbeat/tests/system/test_ilm.py
Original file line number Diff line number Diff line change
@@ -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):
8 changes: 2 additions & 6 deletions libbeat/tests/system/test_template.py
Original file line number Diff line number Diff line change
@@ -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
@@ -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)
@@ -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)

@@ -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)

6 changes: 3 additions & 3 deletions metricbeat/tests/system/test_base.py
Original file line number Diff line number Diff line change
@@ -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(
@@ -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')