Skip to content

Commit d17d837

Browse files
authored
simplify plugin by removing distribution specific code (#1020)
1 parent 2f8ebf0 commit d17d837

File tree

11 files changed

+272
-361
lines changed

11 files changed

+272
-361
lines changed

.ci/Dockerfile

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
ARG ELASTIC_STACK_VERSION
22
# TODO: refactor this to be implicitly resolved by logstash-plugins/.ci/Dockerfile
3-
ARG DISTRIBUTION_SUFFIX
4-
FROM docker.elastic.co/logstash/logstash$DISTRIBUTION_SUFFIX:$ELASTIC_STACK_VERSION
3+
FROM docker.elastic.co/logstash/logstash:$ELASTIC_STACK_VERSION
54
USER logstash
65
COPY --chown=logstash:logstash Gemfile /usr/share/plugins/plugin/Gemfile
76
COPY --chown=logstash:logstash *.gemspec VERSION* version* /usr/share/plugins/plugin/
87
RUN cp /usr/share/logstash/logstash-core/versions-gem-copy.yml /usr/share/logstash/versions.yml
98
ENV PATH="${PATH}:/usr/share/logstash/vendor/jruby/bin:/usr/share/logstash/jdk/bin"
109
ENV LOGSTASH_SOURCE="1"
1110
ENV ELASTIC_STACK_VERSION=$ELASTIC_STACK_VERSION
12-
# DISTRIBUTION="default" (by default) or "oss"
13-
ARG DISTRIBUTION
14-
ENV DISTRIBUTION=$DISTRIBUTION
1511
# INTEGRATION="true" while integration testing (false-y by default)
1612
ARG INTEGRATION
1713
ENV INTEGRATION=$INTEGRATION

.ci/Dockerfile.elasticsearch

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
ARG ELASTIC_STACK_VERSION
2-
ARG DISTRIBUTION_SUFFIX
3-
FROM docker.elastic.co/elasticsearch/elasticsearch$DISTRIBUTION_SUFFIX:$ELASTIC_STACK_VERSION
2+
FROM docker.elastic.co/elasticsearch/elasticsearch:$ELASTIC_STACK_VERSION
43

54
ARG plugin_path=/usr/share/plugins/plugin
65
ARG es_path=/usr/share/elasticsearch

.ci/docker-compose.override.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,7 @@ services:
77
build:
88
args:
99
- ELASTIC_STACK_VERSION=$ELASTIC_STACK_VERSION
10-
- DISTRIBUTION=${DISTRIBUTION:-default}
11-
- DISTRIBUTION_SUFFIX=${DISTRIBUTION_SUFFIX}
1210
environment:
13-
- DISTRIBUTION=${DISTRIBUTION:-default}
14-
- DISTRIBUTION_SUFFIX=${DISTRIBUTION_SUFFIX}
1511
- INTEGRATION=${INTEGRATION:-false}
1612
- SECURE_INTEGRATION=${SECURE_INTEGRATION:-false}
1713

@@ -23,7 +19,6 @@ services:
2319
- ELASTIC_STACK_VERSION=$ELASTIC_STACK_VERSION
2420
- INTEGRATION=${INTEGRATION:-false}
2521
- SECURE_INTEGRATION=${SECURE_INTEGRATION:-false}
26-
- DISTRIBUTION_SUFFIX=${DISTRIBUTION_SUFFIX}
2722
command: /usr/share/elasticsearch/elasticsearch-run.sh
2823
tty: true
2924
ports:

.ci/docker-setup.sh

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ VERSION_URL="https://raw.githubusercontent.com/elastic/logstash/master/ci/logsta
99

1010
pull_docker_snapshot() {
1111
project="${1?project name required}"
12-
local docker_image="docker.elastic.co/${project}/${project}${DISTRIBUTION_SUFFIX}:${ELASTIC_STACK_VERSION}"
12+
local docker_image="docker.elastic.co/${project}/${project}:${ELASTIC_STACK_VERSION}"
1313
echo "Pulling $docker_image"
1414
docker pull "$docker_image"
1515
}
@@ -31,13 +31,7 @@ if [ "$ELASTIC_STACK_VERSION" ]; then
3131
export ELASTIC_STACK_VERSION=$ELASTIC_STACK_RETRIEVED_VERSION
3232
fi
3333

34-
case "${DISTRIBUTION}" in
35-
default) DISTRIBUTION_SUFFIX="" ;; # empty string when explicit "default" is given
36-
*) DISTRIBUTION_SUFFIX="${DISTRIBUTION/*/-}${DISTRIBUTION}" ;;
37-
esac
38-
export DISTRIBUTION_SUFFIX
39-
40-
echo "Testing against version: $ELASTIC_STACK_VERSION (distribution: ${DISTRIBUTION:-'default'})"
34+
echo "Testing against version: $ELASTIC_STACK_VERSION"
4135

4236
if [[ "$ELASTIC_STACK_VERSION" = *"-SNAPSHOT" ]]; then
4337
pull_docker_snapshot "logstash"

.ci/logstash-run.sh

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,6 @@ else
2929
extra_tag_args="--tag ~secure_integration --tag integration"
3030
fi
3131

32-
if [[ "$DISTRIBUTION" == "oss" ]]; then
33-
extra_tag_args="$extra_tag_args --tag distribution:oss --tag ~distribution:xpack"
34-
elif [[ "$DISTRIBUTION" == "default" ]]; then
35-
extra_tag_args="$extra_tag_args --tag ~distribution:oss --tag distribution:xpack"
36-
fi
3732
echo "Waiting for elasticsearch to respond..."
3833
ES_VERSION=$(wait_for_es)
3934
echo "Elasticsearch $ES_VERSION is Up!"

.travis.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import:
22
- logstash-plugins/.ci:travis/[email protected]
33

44
env:
5-
- DISTRIBUTION=default INTEGRATION=false ELASTIC_STACK_VERSION=6.x
6-
- DISTRIBUTION=default INTEGRATION=false ELASTIC_STACK_VERSION=7.x
7-
- DISTRIBUTION=default INTEGRATION=true ELASTIC_STACK_VERSION=6.x
8-
- DISTRIBUTION=default INTEGRATION=true ELASTIC_STACK_VERSION=7.x
9-
- DISTRIBUTION=default INTEGRATION=true ELASTIC_STACK_VERSION=7.x SNAPSHOT=true
10-
- DISTRIBUTION=default INTEGRATION=true ELASTIC_STACK_VERSION=8.x SNAPSHOT=true
11-
- DISTRIBUTION=default SECURE_INTEGRATION=true INTEGRATION=true ELASTIC_STACK_VERSION=7.x
5+
- INTEGRATION=false ELASTIC_STACK_VERSION=6.x
6+
- INTEGRATION=false ELASTIC_STACK_VERSION=7.x
7+
- INTEGRATION=true ELASTIC_STACK_VERSION=6.x
8+
- INTEGRATION=true ELASTIC_STACK_VERSION=7.x
9+
- INTEGRATION=true ELASTIC_STACK_VERSION=7.x SNAPSHOT=true
10+
- INTEGRATION=true ELASTIC_STACK_VERSION=8.x SNAPSHOT=true
11+
- SECURE_INTEGRATION=true INTEGRATION=true ELASTIC_STACK_VERSION=7.x

lib/logstash/outputs/elasticsearch/ilm.rb

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,12 @@ def ilm_in_use?
1616
begin
1717
if @ilm_enabled == 'auto'
1818
if ilm_on_by_default?
19-
ilm_ready, error = ilm_ready?
20-
if !ilm_ready
21-
@logger.info("Index Lifecycle Management is set to 'auto', but will be disabled - #{error}")
22-
false
23-
else
24-
ilm_alias_set?
25-
end
19+
ilm_alias_set?
2620
else
2721
@logger.info("Index Lifecycle Management is set to 'auto', but will be disabled - Your Elasticsearch cluster is before 7.0.0, which is the minimum version required to automatically run Index Lifecycle Management")
2822
false
2923
end
3024
elsif @ilm_enabled.to_s == 'true'
31-
ilm_ready, error = ilm_ready?
32-
raise LogStash::ConfigurationError,"Index Lifecycle Management is set to enabled in Logstash, but cannot be used - #{error}" unless ilm_ready
3325
ilm_alias_set?
3426
else
3527
false
@@ -47,29 +39,6 @@ def ilm_on_by_default?
4739
maximum_seen_major_version >= 7
4840
end
4941

50-
def ilm_ready?
51-
# Check the Elasticsearch instance for ILM readiness - this means that the version has to be a non-OSS release, with ILM feature
52-
# available and enabled.
53-
begin
54-
xpack = client.get_xpack_info
55-
features = xpack.nil? || xpack.empty? ? nil : xpack["features"]
56-
ilm = features.nil? ? nil : features["ilm"]
57-
return false, "Index Lifecycle management is not installed on your Elasticsearch cluster" if features.nil? || ilm.nil?
58-
return false, "Index Lifecycle management is not available in your Elasticsearch cluster" unless ilm['available']
59-
return false, "Index Lifecycle management is not enabled in your Elasticsearch cluster" unless ilm['enabled']
60-
return true, nil
61-
rescue ::LogStash::Outputs::ElasticSearch::HttpClient::Pool::BadResponseCodeError => e
62-
# Check xpack endpoint: If no xpack endpoint, then this version of Elasticsearch is not compatible
63-
if e.response_code == 404
64-
return false, "Index Lifecycle management is not installed on your Elasticsearch cluster"
65-
elsif e.response_code == 400
66-
return false, "Index Lifecycle management is not installed on your Elasticsearch cluster"
67-
else
68-
raise e
69-
end
70-
end
71-
end
72-
7342
def default_index?(index)
7443
index == @default_index
7544
end
@@ -113,4 +82,4 @@ def policy_payload
11382
LogStash::Json.load(::IO.read(policy_path))
11483
end
11584
end
116-
end; end; end
85+
end; end; end

0 commit comments

Comments
 (0)