Skip to content
Merged
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
b7834d8
algorithm improvements and refactor
mgoworko Mar 31, 2025
c2a2da8
tests
mgoworko Apr 1, 2025
67157a1
bump azure base image
mgoworko Apr 1, 2025
0e2f70a
errors instead of exceptions
mgoworko Apr 2, 2025
db4b55a
errors instead of exceptions
mgoworko Apr 2, 2025
c620684
errors instead of exceptions
mgoworko Apr 2, 2025
00765e6
missing flag renames
mgoworko Apr 3, 2025
c76d8e4
use and test flag with and without =
mgoworko Apr 3, 2025
2485bc4
use new ror-tools.jar patch argument only for ROR>=1.64
mgoworko Apr 4, 2025
c75db4a
additional adjustments for testing from file and sources
mgoworko Apr 6, 2025
0b50455
review changes
mgoworko Apr 8, 2025
e5f4eef
review changes
mgoworko Apr 12, 2025
81a0ad6
review changes
mgoworko Apr 12, 2025
3f76ba0
Bump pre version
mgoworko Apr 12, 2025
f4e625b
qs
mgoworko Apr 16, 2025
d69c154
file hashes
mgoworko Apr 17, 2025
bfc2278
review changes
mgoworko Apr 25, 2025
a354e68
Merge remote-tracking branch 'origin/develop' into feature/rordev-143…
mgoworko Apr 25, 2025
24f3b09
qs
mgoworko Apr 25, 2025
fbc7644
review changes
mgoworko Apr 28, 2025
5b1d1c2
qs
mgoworko Apr 28, 2025
478d36b
qs
mgoworko Apr 28, 2025
e50df09
debug pipeline problem
mgoworko Apr 29, 2025
76fbbb1
debug pipeline problem
mgoworko Apr 29, 2025
b9dc12d
qs
mgoworko Apr 29, 2025
afacc0a
qs
mgoworko Apr 29, 2025
62641b5
qs
mgoworko Apr 29, 2025
ce4dd7e
qs
mgoworko Apr 29, 2025
5a2605e
qs
mgoworko Apr 29, 2025
736898e
qs
mgoworko Apr 29, 2025
0cd7839
qs
mgoworko Apr 29, 2025
1cf4c3a
qs
mgoworko Apr 29, 2025
a790c0d
review changes
mgoworko May 6, 2025
ea45985
Merge remote-tracking branch 'origin/develop' into feature/rordev-143…
mgoworko May 6, 2025
c602993
review changes
mgoworko May 7, 2025
7bc476e
test fix
mgoworko May 7, 2025
49dc936
fix
mgoworko May 7, 2025
2329ca0
comment
mgoworko May 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ parameters:
default: ' '

pool:
vmImage: 'ubuntu-20.04'
vmImage: 'ubuntu-22.04'

stages:

Expand Down
33 changes: 25 additions & 8 deletions docker-envs/base-ror-docker/es/install-ror-es-using-api.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,40 @@
#!/bin/bash

function verlte() {
[ "$1" = "`echo -e "$1\n$2" | sort -V | head -n1`" ]
verlte() {
local v1="$1"
local v2="${2%%[-+]*}" # Strip suffix from second argument in order to support -pre versions
[ "$v1" = "$(echo -e "$v1\n$v2" | sort -V | head -n1)" ]
}

if [[ -z "$ES_VERSION" ]]; then
echo "No ES_VERSION variable is set"
exit 1
fi

if [[ -z "$ROR_VERSION" ]]; then
echo "No $ROR_VERSION variable is set"
exit 2
if [[ ! -v ROR_VERSION || -z "$ROR_VERSION" ]]; then
echo "No ROR_VERSION variable is set"
exit 3
fi

echo "Installing ES ROR $ROR_VERSION..."
/usr/share/elasticsearch/bin/elasticsearch-plugin install --batch "https://api.beshu.tech/download/es?esVersion=$ES_VERSION&pluginVersion=$ROR_VERSION&email=ror-sandbox%40readonlyrest.com"
if verlte "6.5.0" "$ES_VERSION"; then
echo "Patching ES ROR $ROR_VERSION..."
/usr/share/elasticsearch/jdk/bin/java -jar /usr/share/elasticsearch/plugins/readonlyrest/ror-tools.jar patch --I_UNDERSTAND_AND_ACCEPT_ES_PATCHING yes

# Set Java path based on ES version
if verlte "7.0.0" "$ES_VERSION"; then
JAVA_BIN_PATH="/usr/share/elasticsearch/jdk/bin/java"
elif verlte "6.7.0" "$ES_VERSION"; then
JAVA_BIN_PATH="$JAVA_HOME/bin/java"
else
echo "Unsupported ES version: $ES_VERSION"
exit 4
fi

# Set OPTIONS based on ROR version
if verlte "1.64.0" "$ROR_VERSION"; then
OPTIONS="--I_UNDERSTAND_AND_ACCEPT_ES_PATCHING=yes"
else
OPTIONS=""
fi

$JAVA_BIN_PATH -jar /usr/share/elasticsearch/plugins/readonlyrest/ror-tools.jar patch $OPTIONS
echo "DONE!"
33 changes: 28 additions & 5 deletions docker-envs/base-ror-docker/es/install-ror-es-using-file.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#!/bin/bash

function verlte() {
[ "$1" = "`echo -e "$1\n$2" | sort -V | head -n1`" ]
verlte() {
local v1="$1"
local v2="${2%%[-+]*}" # Strip suffix from second argument in order to support -pre versions
[ "$v1" = "$(echo -e "$v1\n$v2" | sort -V | head -n1)" ]
}

if [[ -z "$ES_VERSION" ]]; then
Expand All @@ -11,8 +13,29 @@ fi

echo "Installing ES ROR from file..."
/usr/share/elasticsearch/bin/elasticsearch-plugin install --batch file:///tmp/ror.zip
if verlte "6.5.0" "$ES_VERSION"; then
echo "Patching ES ROR..."
/usr/share/elasticsearch/jdk/bin/java -jar /usr/share/elasticsearch/plugins/readonlyrest/ror-tools.jar patch --I_UNDERSTAND_AND_ACCEPT_ES_PATCHING yes
ROR_VERSION=$(unzip -p /tmp/ror.zip plugin-descriptor.properties | grep -oP '^version=\K.*')

if [[ ! -v ROR_VERSION || -z "$ROR_VERSION" ]]; then
echo "No ROR_VERSION variable is set"
exit 3
fi

# Set Java path based on ES version
if verlte "7.0.0" "$ES_VERSION"; then
JAVA_BIN_PATH="/usr/share/elasticsearch/jdk/bin/java"
elif verlte "6.7.0" "$ES_VERSION"; then
JAVA_BIN_PATH="$JAVA_HOME/bin/java"
else
echo "Unsupported ES version: $ES_VERSION"
exit 4
fi

# Set OPTIONS based on ROR version
if verlte "1.64.0" "$ROR_VERSION"; then
OPTIONS="--I_UNDERSTAND_AND_ACCEPT_ES_PATCHING=yes"
else
OPTIONS=""
fi

$JAVA_BIN_PATH -jar /usr/share/elasticsearch/plugins/readonlyrest/ror-tools.jar patch $OPTIONS
echo "DONE!"
2 changes: 1 addition & 1 deletion docker-envs/eck/kind-cluster/ror/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ spec:
runAsUser: 0
runAsGroup: 0
env:
- name: I_UNDERSTAND_IMPLICATION_OF_ES_PATCHING
- name: I_UNDERSTAND_AND_ACCEPT_ES_PATCHING
value: "yes"
- name: INTERNAL_USR_PASS
valueFrom:
Expand Down
2 changes: 1 addition & 1 deletion docker-image/ror-entrypoint-es6x.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ if $INVOKE_ROR_TOOLS verify | grep -q "Elasticsearch is NOT patched"; then
echo "Elasticsearch needs to be patched to work with ReadonlyREST. You can read about patching in our documentation:" \
"https://docs.readonlyrest.com/elasticsearch#id-3.-patch-elasticsearch. In this Docker image, the patching step" \
"is done automatically, but you must agree to have it done for you. You can do this by setting" \
"I_UNDERSTAND_IMPLICATION_OF_ES_PATCHING=yes environment variable when running the container."
"I_UNDERSTAND_AND_ACCEPT_ES_PATCHING=yes environment variable when running the container."
exit 2
fi

Expand Down
12 changes: 10 additions & 2 deletions docker-image/ror-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,15 @@ INVOKE_ROR_TOOLS="/usr/share/elasticsearch/jdk/bin/java -jar /usr/share/elastics

if $INVOKE_ROR_TOOLS verify | grep -q "Elasticsearch is NOT patched"; then

if [ -n "$I_UNDERSTAND_IMPLICATION_OF_ES_PATCHING" ] && [[ "${I_UNDERSTAND_IMPLICATION_OF_ES_PATCHING,,}" == *"yes"* ]]; then
if [ -n "$I_UNDERSTAND_AND_ACCEPT_ES_PATCHING" ]; then
CONFIRMATION="$I_UNDERSTAND_AND_ACCEPT_ES_PATCHING"
elif [ -n "$I_UNDERSTAND_IMPLICATION_OF_ES_PATCHING" ]; then
CONFIRMATION="$I_UNDERSTAND_IMPLICATION_OF_ES_PATCHING"
else
CONFIRMATION=""
fi

if [[ "${CONFIRMATION,,}" == *"yes"* ]]; then
if [ "$(id -u)" -ne 0 ]; then
echo "Elasticsearch needs to be patched to work with ReadonlyREST. You can read about patching in our documentation:" \
"https://docs.readonlyrest.com/elasticsearch#id-3.-patch-elasticsearch. To patch Elasticsearch the container " \
Expand All @@ -18,7 +26,7 @@ if $INVOKE_ROR_TOOLS verify | grep -q "Elasticsearch is NOT patched"; then
echo "Elasticsearch needs to be patched to work with ReadonlyREST. You can read about patching in our documentation:" \
"https://docs.readonlyrest.com/elasticsearch#id-3.-patch-elasticsearch. In this Docker image, the patching step" \
"is done automatically, but you must agree to have it done for you. You can do this by setting" \
"I_UNDERSTAND_IMPLICATION_OF_ES_PATCHING=yes environment variable when running the container."
"I_UNDERSTAND_AND_ACCEPT_ES_PATCHING=yes environment variable when running the container."
exit 2
fi

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
publishedPluginVersion=1.63.0
pluginVersion=1.64.0-pre7
pluginVersion=1.64.0-pre8
pluginName=readonlyrest

org.gradle.jvmargs=-Xmx6144m
10 changes: 10 additions & 0 deletions ror-tools-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ dependencies {
api group: 'org.ow2.asm', name: 'asm-util', version: '9.8'
api group: 'io.kevinlee', name: 'just-semver_3', version: '0.5.0'
api group: 'com.lihaoyi', name: 'os-lib_3', version: '0.11.3'
api group: 'com.github.pathikrit', name: 'better-files_3', version: '3.9.2'
api group: 'io.circe', name: 'circe-core_3', version: '0.14.6'
api group: 'io.circe', name: 'circe-generic_3', version: '0.14.6'
api group: 'io.circe', name: 'circe-parser_3', version: '0.14.6'
}

java {
Expand All @@ -77,6 +81,12 @@ compileScala {
)
}

tasks.withType(ScalaCompile).configureEach {
scalaCompileOptions.additionalParameters = [
"-Xmax-inlines", "128"
]
}

shadowJar {
configurations = [project.configurations.runtimeClasspath]
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,34 +17,42 @@
package tech.beshu.ror.tools.core.patches

import tech.beshu.ror.tools.core.patches.PatchingVerifier.Error.{CannotVerifyIfPatched, EsNotPatched}
import tech.beshu.ror.tools.core.patches.base.EsPatch
import tech.beshu.ror.tools.core.patches.base.EsPatch.IsPatched.{No, Yes}
import tech.beshu.ror.tools.core.patches.base.EsPatchExecutor
import tech.beshu.ror.tools.core.patches.base.EsPatchExecutor.EsPatchStatus
import tech.beshu.ror.tools.core.utils.EsDirectory
import tech.beshu.ror.tools.core.utils.InOut.ConsoleInOut
import tech.beshu.ror.tools.core.utils.RorToolsError.*

import scala.util.Try

object PatchingVerifier {

def verify(esHome: String): Either[Error, Unit] = {
for {
esPatch <- createPatcher(esHome)
result <- esPatch.isPatched match {
case Yes => Right(())
case No(cause) => Left(EsNotPatched(cause.message))
}
esPatchExecutor <- createEsPatchExecutor(esHome)
result <- esPatchExecutor.isPatched match
case EsPatchStatus.NotPatched =>
Left(EsNotPatched(EsNotPatchedError.message))
case EsPatchStatus.PatchedWithCurrentRorVersion(_) =>
Right(())
case EsPatchStatus.PatchProblemDetected(patchProblem) =>
Left(EsNotPatched(patchProblem.rorToolsError.message))
} yield result
}

private def createPatcher(esHome: String) = {
Try(EsPatch.create(os.Path(esHome)))
private def createEsPatchExecutor(esHome: String) = {
Try(EsPatchExecutor.create(EsDirectory.from(os.Path(esHome)))(ConsoleInOut))
.toEither
.left.map { e => CannotVerifyIfPatched(e.getMessage) }
}

sealed trait Error {
def message: String
}

object Error {
final case class EsNotPatched(override val message: String) extends Error

final case class CannotVerifyIfPatched(errorCause: String) extends Error {
override val message: String = s"Cannot verify if the ES was patched. $errorCause"
}
Expand Down
Loading
Loading