Skip to content

Commit

Permalink
remove http.* settings (#16552)
Browse files Browse the repository at this point in the history
The commit removes the deprecated settings http.port, http.host, http.enabled, and http.environment
  • Loading branch information
kaisecheng authored Oct 18, 2024
1 parent 467ab3f commit 566bdf6
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 119 deletions.
2 changes: 1 addition & 1 deletion docker/data/logstash/config/logstash-full.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
http.host: "0.0.0.0"
api.http.host: "0.0.0.0"
xpack.monitoring.elasticsearch.hosts: [ "http://elasticsearch:9200" ]
2 changes: 1 addition & 1 deletion docker/data/logstash/config/logstash-oss.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
http.host: "0.0.0.0"
api.http.host: "0.0.0.0"
4 changes: 0 additions & 4 deletions docker/data/logstash/env2yaml/env2yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@ var validSettings = []string{
"dead_letter_queue.storage_policy",
"dead_letter_queue.retain.age",
"path.dead_letter_queue",
"http.enabled", // DEPRECATED: prefer `api.enabled`
"http.environment", // DEPRECATED: prefer `api.environment`
"http.host", // DEPRECATED: prefer `api.http.host`
"http.port", // DEPRECATED: prefer `api.http.port`
"log.level",
"log.format",
"log.format.json.fix_duplicate_message_fields",
Expand Down
2 changes: 1 addition & 1 deletion docs/static/docker.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ The following settings have different default values when using the Docker
images:

[horizontal]
`http.host`:: `0.0.0.0`
`api.http.host`:: `0.0.0.0`
`monitoring.elasticsearch.hosts`:: `http://elasticsearch:9200`

NOTE: The setting `monitoring.elasticsearch.hosts` is not
Expand Down
8 changes: 4 additions & 4 deletions logstash-core/lib/logstash/environment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ module Environment
Setting::Boolean.new("enable-local-plugin-development", false),
Setting::String.new("log.format", "plain", true, ["json", "plain"]),
Setting::Boolean.new("log.format.json.fix_duplicate_message_fields", true),
Setting::Boolean.new("api.enabled", true).with_deprecated_alias("http.enabled", "9"),
Setting::String.new("api.http.host", "127.0.0.1").with_deprecated_alias("http.host", "9"),
Setting::PortRange.new("api.http.port", 9600..9700).with_deprecated_alias("http.port", "9"),
Setting::String.new("api.environment", "production").with_deprecated_alias("http.environment", "9"),
Setting::Boolean.new("api.enabled", true),
Setting::String.new("api.http.host", "127.0.0.1"),
Setting::PortRange.new("api.http.port", 9600..9700),
Setting::String.new("api.environment", "production"),
Setting::String.new("api.auth.type", "none", true, %w(none basic)),
Setting::String.new("api.auth.basic.username", nil, false).nullable,
Setting::Password.new("api.auth.basic.password", nil, false).nullable,
Expand Down
15 changes: 0 additions & 15 deletions logstash-core/lib/logstash/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -251,21 +251,6 @@ class LogStash::Runner < Clamp::StrictCommand
I18n.t("logstash.runner.flag.quiet"),
:new_flag => "log.level", :new_value => "error"

deprecated_option ["--http.enabled"], :flag,
I18n.t("logstash.runner.flag.http_enabled"),
:new_flag => "api.enabled", :passthrough => true, # use settings to disambiguate
:obsoleted_version => "9"

deprecated_option ["--http.host"], "HTTP_HOST",
I18n.t("logstash.runner.flag.http_host"),
:new_flag => "api.http.host", :passthrough => true, # use settings to disambiguate
:obsoleted_version => "9"

deprecated_option ["--http.port"], "HTTP_PORT",
I18n.t("logstash.runner.flag.http_port"),
:new_flag => "api.http.port", :passthrough => true, # use settings to disambiguate
:obsoleted_version => "9"

# We configure the registry and load any plugin that can register hooks
# with logstash, this needs to be done before any operation.
SYSTEM_SETTINGS = LogStash::SETTINGS.clone
Expand Down
10 changes: 0 additions & 10 deletions logstash-core/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -280,16 +280,6 @@ en:
e.g. 'username:<password>'
configtest: |+
Check configuration for valid syntax and then exit.
http_enabled: |+
Can be used to disable the Web API, which is
enabled by default.
DEPRECATED: use `--api.enabled=false`
http_host: |+
Web API binding host
DEPRECATED: use `--api.http.host=IP`
http_port: |+
Web API http port
DEPRECATED: use `--api.http.port=PORT`
api_enabled: |+
Can be used to disable the Web API, which is
enabled by default.
Expand Down
83 changes: 0 additions & 83 deletions logstash-core/spec/logstash/runner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -255,37 +255,6 @@
subject.run("bin/logstash", args)
end
end

context "using deprecated :http.host alias" do
let(:deprecation_logger_stub) { double("DeprecationLogger(Settings)").as_null_object }
before(:each) { allow(LogStash::Settings).to receive(:deprecation_logger).and_return(deprecation_logger_stub) }

let(:runner_deprecation_logger_stub) { double("DeprecationLogger(Runner)").as_null_object }
before(:each) { allow(runner).to receive(:deprecation_logger).and_return(runner_deprecation_logger_stub) }

context "when deprecated :http.host is defined by the user" do
let(:args) { ["--http.host", "localhost", "-e", pipeline_string]}
it "creates an Agent whose `api.http.host` uses the provided value and provides helpful deprecation message" do
expect(deprecation_logger_stub).to receive(:deprecated).with(a_string_including "`http.host` is a deprecated alias for `api.http.host`")
expect(runner_deprecation_logger_stub).to receive(:deprecated).with(a_string_including 'The flag ["--http.host"] has been deprecated')
expect(LogStash::Agent).to receive(:new) do |settings|
expect(settings.set?("api.http.host")).to be(true)
expect(settings.get("api.http.host")).to eq("localhost")
end

subject.run("bin/logstash", args)
end
end

context "when :api.http.host and deprecated alias :http.host are both defined by the user" do
it "errors helpfully" do
args = ["--api.http.host", "api.local", "--http.host", "http.local", "-e", pipeline_string]
expect do
expect(subject.run("bin/logstash", args)).to_not eq(0)
end.to output(a_string_including("Both `api.http.host` and its deprecated alias `http.host` have been set. Please only set `api.http.host`")).to_stderr
end
end
end
end

context ":api.http.port" do
Expand Down Expand Up @@ -326,58 +295,6 @@
end
end
end

context "using deprecated :http.port alias" do
let(:deprecation_logger_stub) { double("DeprecationLogger(Settings)").as_null_object }
before(:each) { allow(LogStash::Settings).to receive(:deprecation_logger).and_return(deprecation_logger_stub) }

let(:runner_deprecation_logger_stub) { double("DeprecationLogger(Runner)").as_null_object }
before(:each) { allow(runner).to receive(:deprecation_logger).and_return(runner_deprecation_logger_stub) }

context "when defined using deprecated :http.port alias" do
let(:args) { ["--http.port", port_argument, "-e", pipeline_string] }

context "as a single-value string" do
let(:port_argument) { "10000" }
it "creates an Agent whose `api.http.port` uses an appropriate single-element range and logs a helpful deprecation message" do
expect(deprecation_logger_stub).to receive(:deprecated).with(a_string_including "`http.port` is a deprecated alias for `api.http.port`")
expect(runner_deprecation_logger_stub).to receive(:deprecated).with(a_string_including 'The flag ["--http.port"] has been deprecated')

expect(LogStash::Agent).to receive(:new) do |settings|
expect(settings.set?("api.http.port")).to be(true)
expect(settings.get("api.http.port")).to eq(10000..10000)
end

subject.run("bin/logstash", args)
end
end

context "as a range" do
let(:port_argument) { "10000-20000" }
it "creates an Agent whose `api.http.port` uses the appropriate inclusive-end range and logs a helpful deprecation message" do
expect(deprecation_logger_stub).to receive(:deprecated).with(a_string_including "`http.port` is a deprecated alias for `api.http.port`")
expect(runner_deprecation_logger_stub).to receive(:deprecated).with(a_string_including 'The flag ["--http.port"] has been deprecated')

expect(LogStash::Agent).to receive(:new) do |settings|
expect(settings.set?("api.http.port")).to be(true)
expect(settings.get("api.http.port")).to eq(10000..20000)
end

subject.run("bin/logstash", args)
end
end
end

context "when defined by both canonical name and deprecated :http.port alias" do
let(:args) { ["--api.http.port", "9603", "--http.port", "9604", "-e", pipeline_string] }

it "errors helpfully" do
expect do
expect(subject.run("bin/logstash", args)).to_not eq(0)
end.to output(a_string_including("Both `api.http.port` and its deprecated alias `http.port` have been set. Please only set `api.http.port`")).to_stderr
end
end
end
end

context "when :pipeline_workers is not defined by the user" do
Expand Down

0 comments on commit 566bdf6

Please sign in to comment.