Skip to content

Commit ec27add

Browse files
authored
remove code related to ES 6.x and earlier (#1194)
* fixes secure integration tests by using credentials to check ES being up * remove ECS content for ES 6.x * remove document_type handling for 6.x * remove two different ways to define certain parameters like routing vs _routing * remove ES < 7 specific version handling * remove ES < 7 specific ILM feature checking * remove ES < 7 specific template handling * remove ES 6.x template * large cleanup related to ES < 7 specific tests
1 parent 05d5870 commit ec27add

25 files changed

+72
-425
lines changed

.ci/docker-run.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ cd .ci
77

88
if [ "$INTEGRATION" == "true" ]; then
99
# remove the `--attach logstash` if you want to see all logs including elasticsearch container logs
10-
docker-compose up --exit-code-from logstash --attach logstash
10+
docker compose up --exit-code-from logstash --attach logstash
1111
else
12-
docker-compose up --exit-code-from logstash logstash
12+
docker compose up --exit-code-from logstash logstash
1313
fi

.ci/docker-setup.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ cd .ci
8181

8282
export BUILDKIT_PROGRESS=plain
8383
if [ "$INTEGRATION" == "true" ]; then
84-
docker-compose down
85-
docker-compose build --quiet
84+
docker compose down
85+
docker compose build
8686
else
87-
docker-compose down
88-
docker-compose build logstash --quiet
87+
docker compose down
88+
docker compose build logstash
8989
fi

.ci/logstash-run.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ else
1313
fi
1414

1515
# CentOS 7 using curl defaults does not enable TLSv1.3
16-
CURL_OPTS="-k --tlsv1.2 --tls-max 1.3"
16+
CURL_OPTS="-s -u admin:elastic -k --tlsv1.2 --tls-max 1.3"
1717

1818
wait_for_es() {
1919
count=120
@@ -22,7 +22,7 @@ wait_for_es() {
2222
[[ $count -eq 0 ]] && exit 1
2323
sleep 1
2424
done
25-
echo $(curl $CURL_OPTS -vi $ES_URL | jq -r .version.number)
25+
echo $(curl $CURL_OPTS $ES_URL | jq -r .version.number)
2626
}
2727

2828
if [[ "$INTEGRATION" != "true" ]]; then

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ jobs:
99
- env: INTEGRATION=true SNAPSHOT=true LOG_LEVEL=info ELASTIC_STACK_VERSION=8.current
1010
- env: INTEGRATION=true SNAPSHOT=true LOG_LEVEL=info ELASTIC_STACK_VERSION=8.next
1111
- env: INTEGRATION=true SNAPSHOT=true LOG_LEVEL=info ELASTIC_STACK_VERSION=8.future
12+
- env: INTEGRATION=true SNAPSHOT=true LOG_LEVEL=info ELASTIC_STACK_VERSION=main
1213
- stage: "Secure Integration Tests"
1314
env: SECURE_INTEGRATION=true INTEGRATION=true LOG_LEVEL=info ELASTIC_STACK_VERSION=8.current SNAPSHOT=true
1415
- env: SECURE_INTEGRATION=true INTEGRATION=true LOG_LEVEL=info ELASTIC_STACK_VERSION=7.current

Rakefile

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
require "logstash/devutils/rake"
22

33
task :'vendor-ecs-schemata' do
4-
download_ecs_schemata(:v1, elasticsearch_major: 6, ecs_release_tag: 'v1.10.0') # WARNING: v1.11 breaks 6.x (see: https://github.com/elastic/ecs/issues/1649)
54
download_ecs_schemata(:v1, elasticsearch_major: 7, ecs_release_tag: 'v1.12.1')
65
download_ecs_schemata(:v1, elasticsearch_major: 8, ecs_release_tag: 'v1.12.1', generated_for: 7)
76
download_ecs_schemata(:v1, elasticsearch_major: 9, ecs_release_tag: 'v1.12.1', generated_for: 7)

docs/index.asciidoc

+2-7
Original file line numberDiff line numberDiff line change
@@ -612,8 +612,7 @@ Elasticsearch with the same ID.
612612

613613
NOTE: This option is deprecated due to the
614614
https://www.elastic.co/guide/en/elasticsearch/reference/6.0/removal-of-types.html[removal
615-
of types in Elasticsearch 6.0]. It will be removed in the next major version of
616-
Logstash.
615+
of types in Elasticsearch 6.0].
617616

618617
NOTE: This value is ignored and has no effect for Elasticsearch clusters `8.x`.
619618

@@ -622,9 +621,7 @@ similar events to the same 'type'. String expansion `%{foo}` works here.
622621
If you don't set a value for this option:
623622

624623
- for elasticsearch clusters 8.x: no value will be used;
625-
- for elasticsearch clusters 7.x: the value of '_doc' will be used;
626-
- for elasticsearch clusters 6.x: the value of 'doc' will be used;
627-
- for elasticsearch clusters 5.x and below: the event's 'type' field will be used, if the field is not present the value of 'doc' will be used.
624+
- for elasticsearch clusters 7.x: the value of '_doc' will be used.
628625

629626
[id="plugins-{type}s-{plugin}-ecs_compatibility"]
630627
===== `ecs_compatibility`
@@ -1039,8 +1036,6 @@ NOTE: Deprecates <<plugins-{type}s-{plugin}-failure_type_logging_whitelist>>.
10391036

10401037
This setting asks Elasticsearch for the list of all cluster nodes and adds them
10411038
to the hosts list.
1042-
For Elasticsearch 5.x and 6.x any nodes with `http.enabled` (on by default) will
1043-
be added to the hosts list, excluding master-only nodes.
10441039

10451040
[id="plugins-{type}s-{plugin}-sniffing_delay"]
10461041
===== `sniffing_delay`

lib/logstash/outputs/elasticsearch.rb

+10-45
Original file line numberDiff line numberDiff line change
@@ -14,39 +14,16 @@
1414
# .Compatibility Note
1515
# [NOTE]
1616
# ================================================================================
17-
# Starting with Elasticsearch 5.3, there's an {ref}modules-http.html[HTTP setting]
18-
# called `http.content_type.required`. If this option is set to `true`, and you
19-
# are using Logstash 2.4 through 5.2, you need to update the Elasticsearch output
20-
# plugin to version 6.2.5 or higher.
21-
#
22-
# ================================================================================
2317
#
2418
# This plugin is the recommended method of storing logs in Elasticsearch.
2519
# If you plan on using the Kibana web interface, you'll want to use this output.
2620
#
27-
# This output only speaks the HTTP protocol. HTTP is the preferred protocol for interacting with Elasticsearch as of Logstash 2.0.
28-
# We strongly encourage the use of HTTP over the node protocol for a number of reasons. HTTP is only marginally slower,
29-
# yet far easier to administer and work with. When using the HTTP protocol one may upgrade Elasticsearch versions without having
30-
# to upgrade Logstash in lock-step.
21+
# This output only speaks the HTTP protocol.
3122
#
3223
# You can learn more about Elasticsearch at <https://www.elastic.co/products/elasticsearch>
3324
#
34-
# ==== Template management for Elasticsearch 5.x
35-
# Index template for this version (Logstash 5.0) has been changed to reflect Elasticsearch's mapping changes in version 5.0.
36-
# Most importantly, the subfield for string multi-fields has changed from `.raw` to `.keyword` to match ES default
37-
# behavior.
38-
#
39-
# ** Users installing ES 5.x and LS 5.x **
40-
# This change will not affect you and you will continue to use the ES defaults.
41-
#
42-
# ** Users upgrading from LS 2.x to LS 5.x with ES 5.x **
43-
# LS will not force upgrade the template, if `logstash` template already exists. This means you will still use
44-
# `.raw` for sub-fields coming from 2.x. If you choose to use the new template, you will have to reindex your data after
45-
# the new template is installed.
46-
#
4725
# ==== Retry Policy
4826
#
49-
# The retry policy has changed significantly in the 2.2.0 release.
5027
# This plugin uses the Elasticsearch bulk API to optimize its imports into Elasticsearch. These requests may experience
5128
# either partial or total failures.
5229
#
@@ -129,8 +106,7 @@ class LogStash::Outputs::ElasticSearch < LogStash::Outputs::Base
129106
# - delete: deletes a document by id (An id is required for this action)
130107
# - create: indexes a document, fails if a document by that id already exists in the index.
131108
# - update: updates a document by id. Update has a special case where you can upsert -- update a
132-
# document if not already present. See the `upsert` option. NOTE: This does not work and is not supported
133-
# in Elasticsearch 1.x. Please upgrade to ES 2.x or greater to use this feature with Logstash!
109+
# document if not already present. See the `upsert` option.
134110
# - A sprintf style string to change the action based on the content of the event. The value `%{[foo]}`
135111
# would use the foo field for the action
136112
#
@@ -148,7 +124,7 @@ class LogStash::Outputs::ElasticSearch < LogStash::Outputs::Base
148124

149125
config :document_type,
150126
:validate => :string,
151-
:deprecated => "Document types are being deprecated in Elasticsearch 6.0, and removed entirely in 7.0. You should avoid this feature"
127+
:deprecated => "Document types were deprecated in Elasticsearch 7.0, and no longer configurable since 8.0. You should avoid this feature."
152128

153129
# From Logstash 1.3 onwards, a template is applied to Elasticsearch during
154130
# Logstash's startup if one with the name `template_name` does not already exist.
@@ -483,7 +459,7 @@ def event_action_tuple(event)
483459
join_value = event.get(@join_field)
484460
parent_value = event.sprintf(@parent)
485461
event.set(@join_field, { "name" => join_value, "parent" => parent_value })
486-
params[routing_field_name] = event.sprintf(@parent)
462+
params[:routing] = event.sprintf(@parent)
487463
else
488464
params[:parent] = event.sprintf(@parent)
489465
end
@@ -495,7 +471,7 @@ def event_action_tuple(event)
495471
if action == 'update'
496472
params[:_upsert] = LogStash::Json.load(event.sprintf(@upsert)) if @upsert != ""
497473
params[:_script] = event.sprintf(@script) if @script != ""
498-
params[retry_on_conflict_action_name] = @retry_on_conflict
474+
params[:retry_on_conflict] = @retry_on_conflict
499475
end
500476

501477
event_control = event.get("[@metadata][_ingest_document]")
@@ -552,7 +528,7 @@ def common_event_params(event)
552528
params = {
553529
:_id => resolve_document_id(event, event_id),
554530
:_index => resolve_index!(event, event_index),
555-
routing_field_name => resolve_routing(event, event_routing)
531+
:routing => resolve_routing(event, event_routing)
556532
}
557533

558534
target_pipeline = resolve_pipeline(event, event_pipeline)
@@ -615,16 +591,7 @@ def resolve_pipeline(event, event_pipeline)
615591
require "logstash/outputs/elasticsearch/#{name}"
616592
end
617593

618-
def retry_on_conflict_action_name
619-
maximum_seen_major_version >= 7 ? :retry_on_conflict : :_retry_on_conflict
620-
end
621-
622-
def routing_field_name
623-
:routing
624-
end
625-
626594
# Determine the correct value for the 'type' field for the given event
627-
DEFAULT_EVENT_TYPE_ES6 = "doc".freeze
628595
DEFAULT_EVENT_TYPE_ES7 = "_doc".freeze
629596

630597
def get_event_type(event)
@@ -633,9 +600,7 @@ def get_event_type(event)
633600
event.sprintf(@document_type)
634601
else
635602
major_version = maximum_seen_major_version
636-
if major_version == 6
637-
DEFAULT_EVENT_TYPE_ES6
638-
elsif major_version == 7
603+
if major_version == 7
639604
DEFAULT_EVENT_TYPE_ES7
640605
else
641606
nil
@@ -653,9 +618,9 @@ def get_event_type(event)
653618
# @param noop_required_client [nil]: required `nil` for legacy reasons.
654619
# @return [Boolean]
655620
def use_event_type?(noop_required_client)
656-
# always set type for ES 6
657-
# for ES 7 only set it if the user defined it
658-
(maximum_seen_major_version < 7) || (maximum_seen_major_version == 7 && @document_type)
621+
# never use event type unless
622+
# ES is 7.x and the user defined it
623+
maximum_seen_major_version == 7 && @document_type
659624
end
660625

661626
def install_template

lib/logstash/outputs/elasticsearch/data_stream_support.rb

-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ def invalid_data_stream_params(params)
127127
value.to_s == 'true'
128128
when 'manage_template'
129129
value.to_s == 'false'
130-
when 'ecs_compatibility' then true # required for LS <= 6.x
131130
else
132131
name.start_with?('data_stream_') ||
133132
shared_params.include?(name) ||

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

+2-5
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ def initialize(original_error, url)
5252
ROOT_URI_PATH = '/'.freeze
5353
LICENSE_PATH = '/_license'.freeze
5454

55-
VERSION_6_TO_7 = ::Gem::Requirement.new([">= 6.0.0", "< 7.0.0"])
5655
VERSION_7_TO_7_14 = ::Gem::Requirement.new([">= 7.0.0", "< 7.14.0"])
5756

5857
DEFAULT_OPTIONS = {
@@ -550,11 +549,9 @@ def elasticsearch?(response)
550549
return false if version_info['version'].nil?
551550

552551
version = ::Gem::Version.new(version_info["version"]['number'])
553-
return false if version < ::Gem::Version.new('6.0.0')
552+
return false if version < ::Gem::Version.new('7.0.0')
554553

555-
if VERSION_6_TO_7.satisfied_by?(version)
556-
return valid_tagline?(version_info)
557-
elsif VERSION_7_TO_7_14.satisfied_by?(version)
554+
if VERSION_7_TO_7_14.satisfied_by?(version)
558555
build_flavor = version_info["version"]['build_flavor']
559556
return false if build_flavor.nil? || build_flavor != 'default' || !valid_tagline?(version_info)
560557
else

lib/logstash/outputs/elasticsearch/ilm.rb

+1-11
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,7 @@ def ilm_in_use?
2121
"Serverless Elasticsearch cluster does not support Index Lifecycle Management.") if @ilm_enabled == 'auto'
2222
false
2323
elsif @ilm_enabled == 'auto'
24-
if ilm_on_by_default?
25-
ilm_alias_set?
26-
else
27-
@logger.info("ILM auto configuration (`ilm_enabled => auto` or unset) resolved to `false`."\
28-
" Elasticsearch cluster is before 7.0.0, which is the minimum version required to automatically run Index Lifecycle Management")
29-
false
30-
end
24+
ilm_alias_set?
3125
elsif @ilm_enabled.to_s == 'true'
3226
ilm_alias_set?
3327
else
@@ -42,10 +36,6 @@ def ilm_alias_set?
4236
default_index?(@index) || !default_rollover_alias?(@ilm_rollover_alias)
4337
end
4438

45-
def ilm_on_by_default?
46-
maximum_seen_major_version >= 7
47-
end
48-
4939
def default_index?(index)
5040
index == @default_index
5141
end

lib/logstash/outputs/elasticsearch/template_manager.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def self.install(client, template_endpoint, template_name, template, template_ov
4747
def self.add_ilm_settings_to_template(plugin, template)
4848
# Overwrite any index patterns, and use the rollover alias. Use 'index_patterns' rather than 'template' for pattern
4949
# definition - remove any existing definition of 'template'
50-
template.delete('template') if template.include?('template') if plugin.maximum_seen_major_version < 8
50+
template.delete('template') if template.include?('template') if plugin.maximum_seen_major_version == 7
5151
template['index_patterns'] = "#{plugin.ilm_rollover_alias}-*"
5252
settings = resolve_template_settings(plugin, template)
5353
if settings && (settings['index.lifecycle.name'] || settings['index.lifecycle.rollover_alias'])

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

-45
This file was deleted.

spec/es_spec_helper.rb

+1-5
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ def doc_type
3030
nil
3131
elsif ESHelper.es_version_satisfies?(">=7")
3232
"_doc"
33-
else
34-
"doc"
3533
end
3634
end
3735

@@ -70,7 +68,7 @@ def self.es_version
7068
end
7169

7270
RSpec::Matchers.define :have_hits do |expected|
73-
hits_count_path = ESHelper.es_version_satisfies?(">=7") ? %w(hits total value) : %w(hits total)
71+
hits_count_path = %w(hits total value)
7472

7573
match do |actual|
7674
@actual_hits_count = actual&.dig(*hits_count_path)
@@ -214,8 +212,6 @@ def get_template_mappings(template)
214212
template['template']['mappings']
215213
elsif ESHelper.es_version_satisfies?(">=7")
216214
template['mappings']
217-
else
218-
template['mappings']["_default_"]
219215
end
220216
end
221217
end

0 commit comments

Comments
 (0)