Skip to content

Commit b6af315

Browse files
estolfokaisecheng
andauthored
Deprecate config.reload.* as pipeline-level settings (#18312)
* Deprecate config.reload.* as pipeline-level settings * Update specs * Change name of constant * Don't remove the config.reload.* settings from #to_hash * Remove config.reload.* settings from _node/pipelines endpoint response * Remove config.reload.* settings from pipeline metrics * Remove config.reload.* settings from modules/node spec * Put rspec lets where it makes more sense * Revert "Put rspec lets where it makes more sense" This reverts commit ffd67a3. * Update deprecation message to include pipeline id * Update logstash-core/lib/logstash/settings.rb Co-authored-by: kaisecheng <[email protected]> * Update logstash-core/spec/logstash/settings_spec.rb Co-authored-by: kaisecheng <[email protected]> --------- Co-authored-by: kaisecheng <[email protected]>
1 parent a83b7a4 commit b6af315

File tree

7 files changed

+56
-26
lines changed

7 files changed

+56
-26
lines changed

docs/static/spec/openapi/logstash-api.yaml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -199,15 +199,11 @@ paths:
199199
workers: 1
200200
batch_size: 125
201201
batch_delay: 50
202-
config_reload_automatic: false
203-
config_reload_interval: 3
204202
dead_letter_queue_enabled: false
205203
ingestion-pipeline:
206204
workers: 8
207205
batch_size: 125
208206
batch_delay: 5
209-
config_reload_automatic: false
210-
config_reload_interval: 3
211207
dead_letter_queue_enabled: false
212208
x-metaTags:
213209
- content: Logstash
@@ -249,8 +245,6 @@ paths:
249245
workers: 1
250246
batch_size: 125
251247
batch_delay: 50
252-
config_reload_automatic: false
253-
config_reload_interval: 3
254248
dead_letter_queue_enabled: false
255249
x-metaTags:
256250
- content: Logstash
@@ -1790,10 +1784,6 @@ components:
17901784
type: integer
17911785
batch_delay:
17921786
type: integer
1793-
config_reload_automatic:
1794-
type: boolean
1795-
config_reload_interval:
1796-
type: integer
17971787
dead_letter_queue_enabled:
17981788
type: boolean
17991789

logstash-core/lib/logstash/api/commands/node.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ def pipeline(pipeline_id, options = {})
5151
:workers,
5252
:batch_size,
5353
:batch_delay,
54-
:config_reload_automatic,
55-
:config_reload_interval,
5654
:dead_letter_queue_enabled,
5755
:dead_letter_queue_path,
5856
).reject {|_, v| v.nil?}

logstash-core/lib/logstash/java_pipeline.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,6 @@ def start_workers
275275
config_metric.gauge(:workers, pipeline_workers)
276276
config_metric.gauge(:batch_size, batch_size)
277277
config_metric.gauge(:batch_delay, batch_delay)
278-
config_metric.gauge(:config_reload_automatic, settings.get("config.reload.automatic"))
279-
config_metric.gauge(:config_reload_interval, settings.get("config.reload.interval").to_nanos)
280278
config_metric.gauge(:dead_letter_queue_enabled, dlq_enabled?)
281279
config_metric.gauge(:dead_letter_queue_path, dlq_writer.get_path.to_absolute_path.to_s) if dlq_enabled?
282280
config_metric.gauge(:ephemeral_id, ephemeral_id)

logstash-core/lib/logstash/settings.rb

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ def self.included(base)
4444
PIPELINE_SETTINGS_WHITE_LIST = [
4545
"config.debug",
4646
"config.support_escapes",
47-
"config.reload.automatic",
48-
"config.reload.interval",
4947
"config.string",
5048
"dead_letter_queue.enable",
5149
"dead_letter_queue.flush_interval",
@@ -78,6 +76,12 @@ def self.included(base)
7876
"queue.type",
7977
]
8078

79+
# These are deprecated as pipeline override settings, they still exist as process-level settings
80+
DEPRECATED_PIPELINE_OVERRIDE_SETTINGS = [
81+
"config.reload.automatic",
82+
"config.reload.interval",
83+
]
84+
8185
def initialize
8286
@settings = {}
8387
# Theses settings were loaded from the yaml file
@@ -154,12 +158,10 @@ def set_value(setting_name, value, graceful = false)
154158
alias_method :set, :set_value
155159

156160
def to_hash
157-
hash = {}
158-
@settings.each do |name, setting|
161+
@settings.each_with_object({}) do |(name, setting), hash|
159162
next if (setting.kind_of? Setting::DeprecatedAlias) || (setting.kind_of? Java::org.logstash.settings.DeprecatedAlias)
160163
hash[name] = setting.value
161164
end
162-
hash
163165
end
164166

165167
def merge(hash, graceful = false)
@@ -169,7 +171,12 @@ def merge(hash, graceful = false)
169171

170172
def merge_pipeline_settings(hash, graceful = false)
171173
hash.each do |key, _|
172-
unless PIPELINE_SETTINGS_WHITE_LIST.include?(key)
174+
if DEPRECATED_PIPELINE_OVERRIDE_SETTINGS.include?(key)
175+
deprecation_logger.deprecated("Config option \"#{key}\", set for pipeline \"#{hash['pipeline.id']}\", is " +
176+
"deprecated as a pipeline override setting. Please only set it at " +
177+
"the process level.")
178+
hash.delete(key)
179+
elsif !PIPELINE_SETTINGS_WHITE_LIST.include?(key)
173180
raise ArgumentError.new("Only pipeline related settings are expected. Received \"#{key}\". Allowed settings: #{PIPELINE_SETTINGS_WHITE_LIST}")
174181
end
175182
end

logstash-core/spec/logstash/api/commands/node_spec.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,6 @@
9696
:workers,
9797
:batch_size,
9898
:batch_delay,
99-
:config_reload_automatic,
100-
:config_reload_interval,
10199
:dead_letter_queue_enabled,
102100
# :dead_letter_queue_path is nil in tests
103101
# so it is ignored
@@ -117,8 +115,6 @@
117115
:workers,
118116
:batch_size,
119117
:batch_delay,
120-
:config_reload_automatic,
121-
:config_reload_interval,
122118
:dead_letter_queue_enabled,
123119
# Be sure we display a graph when we set the option to
124120
:graph

logstash-core/spec/logstash/api/modules/node_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,6 @@
139139
"workers" => Numeric,
140140
"batch_size" => Numeric,
141141
"batch_delay" => Numeric,
142-
"config_reload_automatic" => Boolean,
143-
"config_reload_interval" => Numeric,
144142
"dead_letter_queue_enabled" => Boolean
145143
}
146144
},

logstash-core/spec/logstash/settings_spec.rb

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,4 +381,47 @@
381381
])
382382
end
383383
end
384+
385+
describe "deprecated pipeline override settings" do
386+
387+
let(:subject) { described_class.new }
388+
before(:each) { subject.register(LogStash::Setting.new("pipeline.id", String, "main")) }
389+
390+
context '#merge_pipeline_settings' do
391+
392+
described_class::DEPRECATED_PIPELINE_OVERRIDE_SETTINGS.each do |setting|
393+
394+
context "the setting (#{setting}) is set" do
395+
396+
let(:deprecation_logger) { subject.deprecation_logger }
397+
let(:setting_value) { double('setting_value') }
398+
399+
it "a warning is logged" do
400+
expect(deprecation_logger).to receive(:deprecated).with(
401+
a_string_matching("Config option \"#{setting}\", set for pipeline \"test\", is deprecated as a " +
402+
"pipeline override setting. Please only set it at the process level.")
403+
)
404+
subject.merge_pipeline_settings("pipeline.id" => "test", setting => setting_value)
405+
end
406+
407+
it "it does not set (#{setting})" do
408+
subject.merge_pipeline_settings(setting => double('setting_value'))
409+
expect{ subject.get_setting(setting) }.to raise_error(ArgumentError)
410+
end
411+
412+
context 'other settings are also set' do
413+
414+
before(:each) do
415+
subject.register(LogStash::Setting::BooleanSetting.new("config.debug", false))
416+
subject.merge_pipeline_settings(setting => setting_value, "config.debug" => true)
417+
end
418+
419+
it "it leaves other settings intact" do
420+
expect(subject.get_setting("config.debug").value).to be(true)
421+
end
422+
end
423+
end
424+
end
425+
end
426+
end
384427
end

0 commit comments

Comments
 (0)