Skip to content

Commit 4760977

Browse files
authored
remove all 1x, 2x and 5x ES specific code (#1021)
1 parent d17d837 commit 4760977

29 files changed

+598
-1217
lines changed

.ci/Dockerfile.elasticsearch

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ ARG SECURE_INTEGRATION
88

99
RUN rm -f $es_path/config/scripts
1010

11-
COPY --chown=elasticsearch:elasticsearch spec/fixtures/scripts/groovy/* $es_path/config/scripts/
1211
COPY --chown=elasticsearch:elasticsearch spec/fixtures/test_certs/* $es_path/config/test_certs/
1312
COPY --chown=elasticsearch:elasticsearch .ci/elasticsearch-run.sh $es_path/
1413

.ci/logstash-run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@ else
3232
echo "Waiting for elasticsearch to respond..."
3333
ES_VERSION=$(wait_for_es)
3434
echo "Elasticsearch $ES_VERSION is Up!"
35-
bundle exec rspec -fd $extra_tag_args --tag update_tests:painless --tag update_tests:groovy --tag es_version:$ES_VERSION spec/integration
35+
bundle exec rspec -fd $extra_tag_args --tag update_tests:painless --tag es_version:$ES_VERSION spec/integration
3636
fi

lib/logstash/outputs/elasticsearch.rb

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ def retry_on_conflict_action_name
443443
end
444444

445445
def routing_field_name
446-
maximum_seen_major_version >= 6 ? :routing : :_routing
446+
:routing
447447
end
448448

449449
# Determine the correct value for the 'type' field for the given event
@@ -456,9 +456,7 @@ def get_event_type(event)
456456
event.sprintf(@document_type)
457457
else
458458
major_version = maximum_seen_major_version
459-
if major_version < 6
460-
es5_event_type(event)
461-
elsif major_version == 6
459+
if major_version == 6
462460
DEFAULT_EVENT_TYPE_ES6
463461
elsif major_version == 7
464462
DEFAULT_EVENT_TYPE_ES7
@@ -470,15 +468,6 @@ def get_event_type(event)
470468
type.to_s
471469
end
472470

473-
def es5_event_type(event)
474-
type = event.get('type')
475-
return DEFAULT_EVENT_TYPE_ES6 unless type
476-
if !type.is_a?(String) && !type.is_a?(Numeric)
477-
@logger.warn("Bad event type (non-string/integer type value set)", :type_class => type.class, :type_value => type, :event => event.to_hash)
478-
end
479-
type
480-
end
481-
482471
##
483472
# WARNING: This method is overridden in a subclass in Logstash Core 7.7-7.8's monitoring,
484473
# where a `client` argument is both required and ignored. In later versions of
@@ -487,7 +476,7 @@ def es5_event_type(event)
487476
# @param noop_required_client [nil]: required `nil` for legacy reasons.
488477
# @return [Boolean]
489478
def use_event_type?(noop_required_client)
490-
# always set type for ES <= 6
479+
# always set type for ES 6
491480
# for ES 7 only set it if the user defined it
492481
(maximum_seen_major_version < 7) || (maximum_seen_major_version == 7 && @document_type)
493482
end

lib/logstash/outputs/elasticsearch/http_client/pool.rb

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -176,23 +176,15 @@ def check_sniff
176176
@logger.warn("Sniff returned no nodes! Will not update hosts.")
177177
return nil
178178
else
179-
case major_version(url_meta[:version])
180-
when 5, 6, 7, 8
181-
sniff_5x_and_above(nodes)
182-
when 2, 1
183-
sniff_2x_1x(nodes)
184-
else
185-
@logger.warn("Could not determine version for nodes in ES cluster!")
186-
return nil
187-
end
179+
sniff(nodes)
188180
end
189181
end
190182

191183
def major_version(version_string)
192184
version_string.split('.').first.to_i
193185
end
194186

195-
def sniff_5x_and_above(nodes)
187+
def sniff(nodes)
196188
nodes.map do |id,info|
197189
# Skip master-only nodes
198190
next if info["roles"] && info["roles"] == ["master"]
@@ -208,24 +200,6 @@ def address_str_to_uri(addr_str)
208200
end
209201
end
210202

211-
def sniff_2x_1x(nodes)
212-
nodes.map do |id,info|
213-
# TODO Make sure this works with shield. Does that listed
214-
# stuff as 'https_address?'
215-
216-
addr_str = info['http_address'].to_s
217-
next unless addr_str # Skip hosts with HTTP disabled
218-
219-
# Only connect to nodes that serve data
220-
# this will skip connecting to client, tribe, and master only nodes
221-
# Note that if 'attributes' is NOT set, then that's just a regular node
222-
# with master + data + client enabled, so we allow that
223-
attributes = info['attributes']
224-
next if attributes && attributes['data'] == 'false'
225-
address_str_to_uri(addr_str)
226-
end.compact
227-
end
228-
229203
def stop_sniffer
230204
@sniffer.join if @sniffer
231205
end

lib/logstash/outputs/elasticsearch/template_manager.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def self.template_name(plugin)
5353
end
5454

5555
def self.default_template_path(es_major_version, ecs_compatibility=:disabled)
56-
template_version = es_major_version == 1 ? 2 : es_major_version
56+
template_version = es_major_version
5757
default_template_name = "templates/ecs-#{ecs_compatibility}/elasticsearch-#{template_version}x.json"
5858
::File.expand_path(default_template_name, ::File.dirname(__FILE__))
5959
end

lib/logstash/outputs/elasticsearch/templates/ecs-disabled/elasticsearch-2x.json

Lines changed: 0 additions & 95 deletions
This file was deleted.

lib/logstash/outputs/elasticsearch/templates/ecs-disabled/elasticsearch-5x.json

Lines changed: 0 additions & 46 deletions
This file was deleted.

spec/es_spec_helper.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,7 @@ def field_properties_from_template(template_name, field)
5353
end
5454

5555
def routing_field_name
56-
if ESHelper.es_version_satisfies?(">=6")
57-
:routing
58-
else
59-
:_routing
60-
end
56+
:routing
6157
end
6258

6359
def self.es_version

spec/fixtures/_nodes/2x_1x.json

Lines changed: 0 additions & 27 deletions
This file was deleted.

spec/fixtures/_nodes/5x_6x.json renamed to spec/fixtures/_nodes/6x.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"transport_address" : "http://localhost:9200",
1212
"host" : "localhost",
1313
"ip" : "127.0.0.1",
14-
"version" : "5.5.1",
14+
"version" : "6.8.10",
1515
"build_hash" : "19c13d0",
1616
"roles" : [
1717
"master"
@@ -29,7 +29,7 @@
2929
"transport_address" : "http://localhost:9201",
3030
"host" : "localhost",
3131
"ip" : "127.0.0.1",
32-
"version" : "5.5.1",
32+
"version" : "6.8.10",
3333
"build_hash" : "19c13d0",
3434
"roles" : [
3535
"data"
@@ -47,7 +47,7 @@
4747
"transport_address" : "http://localhost:9202",
4848
"host" : "localhost",
4949
"ip" : "127.0.0.1",
50-
"version" : "5.5.1",
50+
"version" : "6.8.10",
5151
"build_hash" : "19c13d0",
5252
"roles" : [
5353
"data",
@@ -66,7 +66,7 @@
6666
"transport_address" : "http://localhost:9203",
6767
"host" : "localhost",
6868
"ip" : "127.0.0.1",
69-
"version" : "5.5.1",
69+
"version" : "6.8.10",
7070
"build_hash" : "19c13d0",
7171
"roles" : [ ],
7272
"http" : {
@@ -78,4 +78,4 @@
7878
}
7979
}
8080
}
81-
}
81+
}

spec/fixtures/scripts/groovy/scripted_update.groovy

Lines changed: 0 additions & 2 deletions
This file was deleted.

spec/fixtures/scripts/groovy/scripted_update_nested.groovy

Lines changed: 0 additions & 2 deletions
This file was deleted.

spec/fixtures/scripts/groovy/scripted_upsert.groovy

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)