Skip to content

Commit 7e0c462

Browse files
authored
[RORDEV-1552] ES 9.1.0 support (#1143)
1 parent bad8fc6 commit 7e0c462

File tree

182 files changed

+15348
-3
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

182 files changed

+15348
-3
lines changed

azure-pipelines.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,8 @@ stages:
188188
strategy:
189189
maxParallel: 99
190190
matrix:
191-
IT_es90x:
192-
ROR_TASK: integration_es90x
191+
IT_es91x:
192+
ROR_TASK: integration_es91x
193193
- job:
194194
condition:
195195
and(
@@ -296,6 +296,8 @@ stages:
296296
strategy:
297297
maxParallel: 99
298298
matrix:
299+
IT_es91x:
300+
ROR_TASK: integration_es91x
299301
IT_es90x:
300302
ROR_TASK: integration_es90x
301303
- job:

ci/run-pipeline.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ run_integration_tests() {
5757
./gradlew --no-daemon ror-tools:test integration-tests:test "-PesModule=$ES_MODULE" || (find . | grep hs_err | xargs cat && exit 1)
5858
}
5959

60+
if [[ -z $TRAVIS ]] || [[ $ROR_TASK == "integration_es91x" ]]; then
61+
run_integration_tests "es91x"
62+
fi
63+
6064
if [[ -z $TRAVIS ]] || [[ $ROR_TASK == "integration_es90x" ]]; then
6165
run_integration_tests "es90x"
6266
fi

ci/supported-es-versions/es9x.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
9.1.0
12
9.0.4
23
9.0.3
34
9.0.2

es91x/Dockerfile

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
ARG ES_VERSION
2+
ARG ROR_VERSION
3+
4+
FROM alpine:3.21.0 AS builder
5+
6+
ENV GOSU_VERSION=1.17
7+
RUN set -eux; \
8+
apk add --no-cache --virtual .gosu-deps \
9+
ca-certificates \
10+
dpkg \
11+
gnupg \
12+
; \
13+
dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')"; \
14+
wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch"; \
15+
wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch.asc"; \
16+
# verify the signature
17+
export GNUPGHOME="$(mktemp -d)"; \
18+
gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4; \
19+
gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu; \
20+
gpgconf --kill all;
21+
22+
FROM docker.elastic.co/elasticsearch/elasticsearch:${ES_VERSION}
23+
COPY --from=builder /usr/local/bin/gosu /usr/local/bin/gosu
24+
25+
ARG ES_VERSION
26+
ARG ROR_VERSION
27+
28+
ENV KIBANA_USER_PASS=kibana
29+
ENV ADMIN_USER_PASS=admin
30+
31+
USER root
32+
33+
RUN chmod +x /usr/local/bin/gosu \
34+
&& gosu --version \
35+
&& gosu nobody true
36+
37+
USER 1000
38+
39+
COPY readonlyrest-${ROR_VERSION}_es${ES_VERSION}.zip /tmp/readonlyrest.zip
40+
COPY init-readonlyrest.yml /usr/share/elasticsearch/config/readonlyrest.yml
41+
COPY ror-entrypoint.sh /usr/local/bin/ror-entrypoint.sh
42+
43+
RUN /usr/share/elasticsearch/bin/elasticsearch-plugin install --batch file:///tmp/readonlyrest.zip
44+
45+
ENTRYPOINT ["/usr/bin/tini", "--", "/usr/local/bin/ror-entrypoint.sh"]

es91x/build.gradle

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
/*
2+
* This file is part of ReadonlyREST.
3+
*
4+
* ReadonlyREST is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* ReadonlyREST is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with ReadonlyREST. If not, see http://www.gnu.org/licenses/
16+
*/
17+
import org.gradle.crypto.checksum.Checksum
18+
19+
plugins {
20+
id 'org.gradle.crypto.checksum'
21+
id "readonlyrest.plugin-common-conventions"
22+
}
23+
24+
def pluginFullName = pluginName + '-' + version
25+
def projectJavaLanguageVersion = JavaLanguageVersion.of(21)
26+
def moduleEsVersion = project.property('esVersion') != null ? project.property('esVersion') : project.property('latestSupportedEsVersion')
27+
def releaseDockerImageLatest = 'beshultd/elasticsearch-readonlyrest:' + moduleEsVersion + '-ror-latest'
28+
def releaseDockerImageVersion = 'beshultd/elasticsearch-readonlyrest:' + moduleEsVersion + '-ror-' + pluginVersion
29+
def preBuildDockerImageVersion = 'beshultd/elasticsearch-readonlyrest-dev:' + moduleEsVersion + '-ror-' + pluginVersion
30+
31+
java {
32+
toolchain {
33+
languageVersion = projectJavaLanguageVersion
34+
}
35+
}
36+
37+
dependencies {
38+
implementation project(path: ':core')
39+
implementation project(path: ':ror-tools', configuration: 'shadow')
40+
implementation project(path: ':ror-tools-core')
41+
implementation group: 'org.elasticsearch', name: 'elasticsearch' , version: moduleEsVersion
42+
implementation group: 'org.elasticsearch.client', name: 'elasticsearch-rest-client', version: moduleEsVersion
43+
implementation group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.13'
44+
implementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.11.1'
45+
compileOnly group: 'org.locationtech.spatial4j', name: 'spatial4j', version: '0.7'
46+
// if you don't have this dependency in local maven, please run publishToMavenLocal task first
47+
compileOnly group: 'org.elasticsearch.plugin', name: 'transport-netty4', version: moduleEsVersion
48+
}
49+
50+
configurations {
51+
wagon
52+
distJars {
53+
exclude group: 'org.elasticsearch'
54+
exclude group: 'lucene-core'
55+
exclude module: 'log4j-api'
56+
exclude module: 'log4j-core'
57+
exclude group: 'lucene-analyzers-common'
58+
exclude group: 'org.apache.commons'
59+
exclude group: 'org.yaml'
60+
exclude group: 'com.fasterxml.jackson.core', module: 'jackson-core'
61+
}
62+
}
63+
64+
tasks.register('cleanOldData') {
65+
doLast {
66+
delete 'build/tmp/' + pluginFullName
67+
}
68+
}
69+
70+
tasks.register('jarHellCheck', JavaExec) {
71+
outputs.upToDateWhen { false }
72+
mainClass.set("org.elasticsearch.jdk.JarHell")
73+
classpath = project.sourceSets.main.compileClasspath.filter { it.exists() }
74+
javaLauncher = javaToolchains.launcherFor {
75+
languageVersion = projectJavaLanguageVersion
76+
}
77+
}
78+
79+
tasks.register('resolvePluginDescriptorTemplate', Copy) {
80+
outputs.upToDateWhen { false }
81+
from './plugin-metadata'
82+
into 'build/tmp/' + pluginFullName
83+
expand([
84+
'descriptor': [
85+
'name' : pluginName,
86+
'pluginVersion': pluginVersion,
87+
'esVersion' : moduleEsVersion
88+
]
89+
])
90+
}
91+
92+
tasks.register('buildRorPluginZip') {
93+
dependsOn(packageRorPlugin, createRorPluginChecksums)
94+
}
95+
96+
tasks.register('packageRorPlugin', Zip) {
97+
dependsOn(cleanOldData, jarHellCheck, toJar, resolvePluginDescriptorTemplate)
98+
outputs.upToDateWhen { false }
99+
archivesBaseName = pluginName
100+
into('.') {
101+
from configurations.distJars.filter { x -> !x.name.contains('spatial4j') && !x.name.contains('jts') }
102+
from 'build/libs/' + pluginFullName + '.jar'
103+
from 'build/tmp/' + pluginFullName
104+
}
105+
}
106+
107+
tasks.register('createRorPluginChecksums', Checksum) {
108+
dependsOn(packageRorPlugin)
109+
def distributionsDir = layout.buildDirectory.dir("distributions")
110+
111+
outputs.upToDateWhen { false }
112+
inputFiles.setFrom(packageRorPlugin.archiveFile)
113+
outputDirectory.set(distributionsDir)
114+
checksumAlgorithm.set(Checksum.Algorithm.SHA512)
115+
}
116+
117+
tasks.register('uploadRorPluginToS3', Exec) {
118+
dependsOn(packageRorPlugin, createRorPluginChecksums)
119+
120+
def distributionsDir = layout.buildDirectory.get().asFile.path + "/distributions"
121+
def pluginFileZip = distributionsDir + "/" + pluginFullName + ".zip"
122+
def pluginSha1 = distributionsDir + "/" + pluginFullName + ".zip.sha1"
123+
def pluginSha512 = distributionsDir + "/" + pluginFullName + ".zip.sha512"
124+
def targetS3Dir = "build/" + pluginVersion + "/"
125+
126+
commandLine '../ci/upload-files-to-s3.sh', pluginFileZip, pluginSha512, pluginSha1, targetS3Dir
127+
}
128+
129+
tasks.register('prepareDockerImageFiles', Copy) {
130+
dependsOn packageRorPlugin
131+
outputs.upToDateWhen { false }
132+
133+
from layout.projectDirectory.file("Dockerfile")
134+
from layout.buildDirectory.file("distributions/" + pluginFullName + ".zip")
135+
from rootProject.files("docker-image")
136+
137+
into layout.buildDirectory.dir("docker-image")
138+
}
139+
140+
tasks.register('pushRorDockerImage', Exec) {
141+
dependsOn('packageRorPlugin', 'prepareDockerImageFiles', 'prepareMultiplatformBuilder')
142+
group 'docker'
143+
executable 'docker'
144+
workingDir 'build/docker-image'
145+
args = [
146+
'buildx', 'build', '--platform', 'linux/amd64,linux/arm64',
147+
'--build-arg', 'ROR_VERSION=' + pluginVersion, '--build-arg', "ES_VERSION=" + project.properties['esVersion'],
148+
'-t', releaseDockerImageLatest, '-t', releaseDockerImageVersion,
149+
'--push', '.'
150+
]
151+
}
152+
153+
tasks.register('pushRorPreBuildDockerImage', Exec) {
154+
dependsOn('packageRorPlugin', 'prepareDockerImageFiles', 'prepareMultiplatformBuilder')
155+
group 'docker'
156+
executable 'docker'
157+
workingDir 'build/docker-image'
158+
args = [
159+
'buildx', 'build', '--platform', 'linux/amd64,linux/arm64',
160+
'--build-arg', 'ROR_VERSION=' + pluginVersion, '--build-arg', "ES_VERSION=" + project.properties['esVersion'],
161+
'-t', preBuildDockerImageVersion,
162+
'--push', '.'
163+
]
164+
}
165+
166+
tasks.register('localRorDockerImage', Exec) {
167+
// we prepare docker image for local architecture - the image is loaded to local registry
168+
dependsOn('packageRorPlugin', 'prepareDockerImageFiles')
169+
group 'docker'
170+
executable 'docker'
171+
workingDir 'build/docker-image'
172+
args = [
173+
'buildx', 'build',
174+
'--build-arg', 'ROR_VERSION=' + pluginVersion, '--build-arg', "ES_VERSION=" + project.properties['esVersion'],
175+
'-t', releaseDockerImageVersion,
176+
'--load', '.'
177+
]
178+
}

es91x/gradle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
latestSupportedEsVersion=9.1.0
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
ALL-UNNAMED:
2+
- files:
3+
- relative_path: ../
4+
relative_to: config
5+
mode: read
6+
- manage_threads
7+
- inbound_network
8+
- outbound_network
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#
2+
# This file is part of ReadonlyREST.
3+
#
4+
# ReadonlyREST is free software: you can redistribute it and/or modify
5+
# it under the terms of the GNU General Public License as published by
6+
# the Free Software Foundation, either version 3 of the License, or
7+
# (at your option) any later version.
8+
#
9+
# ReadonlyREST is distributed in the hope that it will be useful,
10+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
# GNU General Public License for more details.
13+
#
14+
# You should have received a copy of the GNU General Public License
15+
# along with ReadonlyREST. If not, see http://www.gnu.org/licenses/
16+
#
17+
#
18+
# Elasticsearch plugin descriptor file
19+
# This file must exist as 'plugin-descriptor.properties' in a folder named `elasticsearch`
20+
# inside all plugins.
21+
#
22+
name=${descriptor.name}
23+
version=${descriptor.pluginVersion}
24+
description=Safely expose Elasticsearch REST API
25+
classname=tech.beshu.ror.es.ReadonlyRestPlugin
26+
java.version=1.8
27+
elasticsearch.version=${descriptor.esVersion}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
grant {
2+
permission java.io.FilePermission "/usr/share/elasticsearch", "read";
3+
permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
4+
permission java.lang.RuntimePermission "accessClassInPackage.sun.misc";
5+
permission java.lang.RuntimePermission "accessClassInPackage.sun.misc.*";
6+
permission java.lang.RuntimePermission "accessDeclaredMembers";
7+
permission java.lang.RuntimePermission "getClassLoader";
8+
permission java.lang.RuntimePermission "setContextClassLoader";
9+
permission java.net.SocketPermission "*", "accept, resolve, connect";
10+
permission java.security.SecurityPermission "insertProvider";
11+
permission java.security.SecurityPermission "putProviderProperty.BCFIPS";
12+
permission java.security.SecurityPermission "putProviderProperty.BCJSSE";
13+
permission java.util.PropertyPermission "*", "read,write";
14+
};

0 commit comments

Comments
 (0)