-
Notifications
You must be signed in to change notification settings - Fork 61
Description
https://issues.redhat.com/browse/OPENJDK-3053
Hi,
we are using these images in kustomize-based kubernetes deployments.
while kustomize can merge ConfigMaps, i.e. "VAL=foo" in a CM in the "base" can be overwritten by "VAL=bar" in an "overlay") it cannot merge variables -- if we have JAVA_OPTS_APPEND
(or JAVA_OPTS
for that matter) in one place, we can only overwrite it, but not extend it.
e.g. if we have a "base" with JAVA_OPTS_APPEND=-Dmyoption=foo
and we would like to add -DanotherOption=bar
in the "overlay", that requires to put JAVA_OPTS_APPEND=-Dmyoption=foo -Dmyoption=bar
into the overlay.
Would you accept a PR that introduces a way to aggregate JAVA_OPTS_APPEND
like the following?
# export syntax for easier toying around in shell
export JAVA_OPTS_APPEND_2_BASE_OPTS="-Done.option=foo -Danother.option=bar"
export JAVA_OPTS_APPEND_1_EARLY_OPTS="-XX:-HeapDumpOnOutOfMemoryError"
export JAVA_OPTS_APPEND_3_CACERTS="-Djavax.net.ssl.trustStore=/media/configmap/cacerts/cacerts -Djavax.net.ssl.trustStorePassword=changedit"
export JAVA_OPTS_APPEND_100_END_OPTS="-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/media/pvc/heapdumps"
result (where i would prefer to have this (natural) order, but depending on the complexity no order guarantees might be given):
JAVA_OPTS_APPEND=-XX:-HeapDumpOnOutOfMemoryError -Done.option=foo -Danother.option=bar -Djavax.net.ssl.trustStore=/media/configmap/cacerts/cacerts -Djavax.net.ssl.trustStorePassword=changedit -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/media/pvc/heapdumps
simple, without natural order:
shopt -s extglob
appends=$(compgen -v JAVA_OPTS_APPEND_)
for append in $appends
do JAVA_OPTS_APPEND="$JAVA_OPTS_APPEND ${!append}"
done
likely the logic should back-off when JAVA_OPTS_APPEND is already set.
advanced, natural order and enforced numeric infix to prevent unexpected ordering (which could also help warning about clashes):
shopt -s extglob
appends=$(compgen -v -X '!JAVA_OPTS_APPEND_+([[:digit:]])_*' | sort -V)
for append in $appends
do JAVA_OPTS_APPEND="$JAVA_OPTS_APPEND ${!append}"
done
additionally to backing off when already set, likely extglob should be set only temporarily to prevent unexpected side-effects in other scripts.
I verified both options with ubi8/openjdk-17-runtime:1.19-4.1715070687
already.