Skip to content

Commit 5951004

Browse files
authored
Validate that required functionality in Elasticsearch is available upon initial connection (#1015)
1 parent e4f2209 commit 5951004

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 11.0.2
2+
- Validate that required functionality in Elasticsearch is available upon initial connection [#1015](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/1015)
3+
14
## 11.0.1
25
- Fix: DLQ regression shipped in 11.0.0 [#1012](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/1012)
36
- [DOC] Fixed broken link in list item [#1011](https://github.com/logstash-plugins/logstash-output-elasticsearch/pull/1011)

lib/logstash/outputs/elasticsearch/license_checker.rb

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def initialize(logger)
1111
# @param url [LogStash::Util::SafeURI] ES node URL
1212
# @return [Boolean] true if provided license is deemed appropriate
1313
def appropriate_license?(pool, url)
14-
license = pool.get_license(url)
14+
license = extract_license(pool.get_license(url))
1515
case license_status(license)
1616
when 'active'
1717
true
@@ -24,20 +24,26 @@ def appropriate_license?(pool, url)
2424
end
2525
end
2626

27+
NO_LICENSE = {}.freeze
28+
private_constant :NO_LICENSE
29+
30+
def extract_license(license)
31+
license.fetch("license", NO_LICENSE)
32+
end
33+
2734
def license_status(license)
28-
license.fetch("license", {}).fetch("status", nil)
35+
license.fetch("status", nil)
2936
end
3037

3138
private
3239

3340
def warn_no_license(url)
34-
@logger.error("Connecting to an OSS distribution of Elasticsearch is no longer supported, " +
35-
"please upgrade to the default distribution of Elasticsearch", url: url.sanitized.to_s)
41+
@logger.error("Could not connect to a compatible version of Elasticsearch", url: url.sanitized.to_s)
3642
end
3743

3844
def warn_invalid_license(url, license)
39-
@logger.warn("WARNING: Current Elasticsearch license is not active, " +
40-
"please check Elasticsearch's licensing information", url: url.sanitized.to_s, license: license)
45+
@logger.warn("Elasticsearch license is not active, please check Elasticsearch’s licensing information",
46+
url: url.sanitized.to_s, license: license)
4147
end
4248

4349
end

logstash-output-elasticsearch.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Gem::Specification.new do |s|
22
s.name = 'logstash-output-elasticsearch'
3-
s.version = '11.0.1'
3+
s.version = '11.0.2'
44

55
s.licenses = ['apache-2.0']
66
s.summary = "Stores logs in Elasticsearch"

0 commit comments

Comments
 (0)