Skip to content

Commit ad29262

Browse files
authored
Apply Elasticsearch GeoIP changes and sync with Elasticsearch 8.16. (#170)
* Apply Elasticsearch GeoIP changes and sync with Elasticsearch 8.16. * Use ES repo if defined, upgrade dependencies and replace shadow plugin. * Target ES 8.16 branch with 8.latest (8.15.3 now) to make green build with #170 PR.
1 parent 5f6bf31 commit ad29262

19 files changed

+387
-343
lines changed

.buildkite/pull-request-pipeline.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ steps:
2222
ELASTIC_STACK_VERSION: "8.x"
2323
INTEGRATION: true
2424
SECURE_INTEGRATION: true
25+
# temporary definition to cover PR-170
26+
# TODO: remove once 8.16 released
27+
ELASTICSEARCH_TREEISH: 8.16
2528

2629
- label: ":hammer: CI setup and integration tests with ES 8.x-SNAPSHOT run on :docker:"
2730
command:

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 0.1.16
2+
- Reflects the Elasticsearch GeoIP changes into the plugin and syncs with Elasticsearch 8.16 branch [#170](https://github.com/elastic/logstash-filter-elastic_integration/pull/170)
3+
14
## 0.1.15
25
- Fixes the connection failure where SSL verification mode is disabled over SSL connection [#165](https://github.com/elastic/logstash-filter-elastic_integration/pull/165)
36

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.1.15
1+
0.1.16

build.gradle

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ plugins {
2121
id "idea"
2222
id "com.adarshr.test-logger" version "3.2.0"
2323
id "de.undercouch.download" version "5.3.1"
24-
id "com.github.johnrengelman.shadow" version "8.1.1"
24+
id "com.gradleup.shadow" version "8.3.2"
2525
}
2626

2727
// ===========================================================================
@@ -95,10 +95,10 @@ dependencies {
9595

9696
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.1.0'
9797
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.1.0'
98-
testImplementation 'org.mockito:mockito-junit-jupiter:5.1.1'
98+
testImplementation 'org.mockito:mockito-junit-jupiter:5.14.1'
9999
testImplementation 'org.hamcrest:hamcrest-library:2.2'
100100
testImplementation "com.github.seregamorph:hamcrest-more-matchers:0.1"
101-
testImplementation "com.github.tomakehurst:wiremock-jre8:2.35.0"
101+
testImplementation 'com.github.tomakehurst:wiremock-jre8:2.35.1'
102102
testRuntimeOnly requiredLogstashCoreJar("log4j-core")
103103

104104
geolite2('org.elasticsearch:geolite2-databases:20191119') {
@@ -161,7 +161,7 @@ def _requiredLogstashJar(pathPrefix, jarSpec, flavorSpec = null) {
161161
}
162162

163163
// https://docs.github.com/en/repositories/working-with-files/using-files/downloading-source-code-archives#source-code-archive-urls
164-
String githubArchivePath(org, repo, treeish="main", archiveFormat="zip") {
164+
String githubArchivePath(repo, treeish="main", archiveFormat="zip") {
165165
def pathFragment = {
166166
switch(treeish) {
167167
case ~'^refs/(?:heads|tags)/' : return "${treeish}" // unambiguous ref
@@ -171,7 +171,7 @@ String githubArchivePath(org, repo, treeish="main", archiveFormat="zip") {
171171
}
172172
}()
173173

174-
"https://github.com/${org}/${repo}/archive/${pathFragment}.${archiveFormat}"
174+
"https://github.com/${repo}/archive/${pathFragment}.${archiveFormat}"
175175
}
176176

177177
task downloadElasticsearchSourceZip(type: Download) {
@@ -186,7 +186,10 @@ task downloadElasticsearchSourceZip(type: Download) {
186186
""")
187187
}
188188

189-
src githubArchivePath("elastic", "elasticsearch", esTreeish, "zip")
189+
def esRepo = envOrPropertyValue("ELASTICSEARCH_REPO") ?: "elastic/elasticsearch"
190+
inputs.property("ELASTICSEARCH_REPO", esRepo)
191+
192+
src githubArchivePath(esRepo, esTreeish, "zip")
190193
dest "${buildDir}/elasticsearch-source.zip"
191194
onlyIfModified true
192195
useETag "all"
@@ -383,6 +386,8 @@ test {
383386
useJUnitPlatform()
384387
testLogging {
385388
exceptionFormat "full"
389+
outputs.upToDateWhen { false }
390+
showStandardStreams = true
386391
}
387392
}
388393

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
LOGSTASH_PATH=../../ls
2-
ELASTICSEARCH_TREEISH=8.15
2+
ELASTICSEARCH_TREEISH=8.16

lib/logstash/filters/elastic_integration/geoip_database_provider_bridge.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ module LogStash::Filters::ElasticIntegration::GeoipDatabaseProviderBridge
2020
"in a Logstash with Geoip Database Management enabled."
2121

2222
def initialize_geoip_database_provider!
23-
java_import('co.elastic.logstash.filters.elasticintegration.geoip.GeoIpDatabaseProvider')
24-
@geoip_database_provider ||= GeoIpDatabaseProvider::Builder.new.tap do |builder|
23+
java_import('co.elastic.logstash.filters.elasticintegration.geoip.IpDatabaseProvider')
24+
@geoip_database_provider ||= IpDatabaseProvider::Builder.new.tap do |builder|
2525
if geoip_database_directory
2626
logger.debug("discovering geoip databases from #{geoip_database_directory}")
2727
builder.discoverDatabases(java.io.File.new(geoip_database_directory))
@@ -53,8 +53,8 @@ def load_geoip_database_manager!
5353
:UNAVAILABLE
5454
end
5555

56-
java_import('co.elastic.logstash.filters.elasticintegration.geoip.ManagedGeoipDatabaseHolder')
57-
class ObservingDatabaseHolder < ManagedGeoipDatabaseHolder
56+
java_import('co.elastic.logstash.filters.elasticintegration.geoip.ManagedIpDatabaseHolder')
57+
class ObservingDatabaseHolder < ManagedIpDatabaseHolder
5858
def initialize(simple_database_type, eula_manager:, logger: nil)
5959
super("GeoLite2-#{simple_database_type}")
6060

src/main/java/co/elastic/logstash/filters/elasticintegration/EventProcessorBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ public synchronized EventProcessor build(final PluginContext pluginContext) {
316316
private static ScriptService initScriptService(final Settings settings, final ThreadPool threadPool) throws IOException {
317317
Map<String, ScriptEngine> engines = new HashMap<>();
318318
engines.put(PainlessScriptEngine.NAME, getPainlessScriptEngine(settings));
319-
engines.put(MustacheScriptEngine.NAME, new MustacheScriptEngine());
319+
engines.put(MustacheScriptEngine.NAME, new MustacheScriptEngine(settings));
320320
return new ScriptService(settings, engines, ScriptModule.CORE_CONTEXTS, threadPool::absoluteTimeInMillis);
321321
}
322322

src/main/java/co/elastic/logstash/filters/elasticintegration/geoip/ConstantGeoipDatabaseHolder.java

Lines changed: 0 additions & 41 deletions
This file was deleted.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package co.elastic.logstash.filters.elasticintegration.geoip;
2+
3+
import org.elasticsearch.ingest.geoip.IpDatabase;
4+
5+
import java.io.Closeable;
6+
import java.io.IOException;
7+
import java.util.Objects;
8+
9+
public class ConstantIpDatabaseHolder implements IpDatabaseHolder, Closeable {
10+
private final IpDatabaseAdapter ipDatabase;
11+
12+
public ConstantIpDatabaseHolder(final IpDatabaseAdapter ipDatabase) {
13+
this.ipDatabase = Objects.requireNonNull(ipDatabase);
14+
}
15+
16+
@Override
17+
public boolean isValid() {
18+
return true;
19+
}
20+
21+
@Override
22+
public IpDatabase getDatabase() {
23+
return this.ipDatabase;
24+
}
25+
26+
@Override
27+
public String getTypeIdentifier() {
28+
return this.ipDatabase.getDatabaseType();
29+
}
30+
31+
@Override
32+
public String info() {
33+
return String.format("ConstantIpDatabaseHolder{type=%s}", getTypeIdentifier());
34+
}
35+
36+
@Override
37+
public void close() throws IOException {
38+
this.ipDatabase.closeReader();
39+
}
40+
}

src/main/java/co/elastic/logstash/filters/elasticintegration/geoip/GeoIpDatabaseAdapter.java

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

0 commit comments

Comments
 (0)