scylladb / scylla-jmx

Scylla JMX proxy
GNU Affero General Public License v3.0
28 stars 51 forks source link

install.sh: select java executable at runtime #202

Closed tchaikov closed 1 year ago

tchaikov commented 1 year ago

before this change, a symbolic link to java runtime is created in the install directory of scylla-jmx, and scylla-jmx uses it to launch scylla-jmx-1.0.jar. and we only check for the expected java version when install.sh is called without --packaging specified. but, another important use case of install.sh is for creating relocatable package. in that case, the --packaging parameter is specified. so we always end up using /usr/bin/java for launching jmx jar if jmx is installed from the relocatable package.

but we do intend to use OpenJDK-11 for running scylla-jmx if it is available, no matter how scylla-jmx is installed.

so, in this change, instead of relying on user pointing /usr/bin/java to the appropriate java runtime, we just choose it by ourselves. to accomplish this goal, scripts/select-java is extracted out of install.sh. this script picks JRE and execv it, and fails if neither JRE-8 nor JRE-11 is found. to minimize the impact to other parts of this project, while preserve a meaningful name in the source tree, the name select-java is used, while it is installed using the old name of symlinks/scylla-jmx, even it is not a symblink anymore.

also, the error mesage is adjusted to place "openjdk-11" before "openjdk-8" as a hint that openjdk-11 is prefered. this error mesage is only printed out in non-packaging mode.

Fixes #194 Signed-off-by: Kefu Chai kefu.chai@scylladb.com

tchaikov commented 1 year ago

tested by running following commands for generating the relocatable packages, and also rpm / deb packages:

$ ./tools/toolchain/dbuild ./configure.py --mode dev --disable-dpdk
$ ./tools/toolchain/dbuild ninja

and i checked the generated rpm package manually by:

$ rpm2cpio scylla-jmx-5.3.0~dev-0.20230413.8d46436a87a6.noarch.rpm | cpio -idmv
$ ./usr/lib/scylla/jmx/select-java --version
openjdk 11.0.18 2023-01-17
OpenJDK Runtime Environment (Red_Hat-11.0.18.0.10-1.fc38) (build 11.0.18+10)
OpenJDK 64-Bit Server VM (Red_Hat-11.0.18.0.10-1.fc38) (build 11.0.18+10, mixed mode, sharing)
$ ar vx scylla-jmx_5.3.0~dev-0.20230413.8d46436a87a6-1_all.deb
$ tar xJvf data.tar.xz 
$ ./opt/scylladb/jmx/select-java --version
openjdk 11.0.18 2023-01-17
OpenJDK Runtime Environment (Red_Hat-11.0.18.0.10-1.fc38) (build 11.0.18+10)
OpenJDK 64-Bit Server VM (Red_Hat-11.0.18.0.10-1.fc38) (build 11.0.18+10, mixed mode, sharing)
denesb commented 1 year ago

Since this is a non-trivial change, I didn't immediately queue it in scylla.git, instead I opened a PR to have CI check it. See https://github.com/scylladb/scylladb/pull/13492.

tchaikov commented 1 year ago

Since this is a non-trivial change, I didn't immediately queue it in scylla.git, instead I opened a PR to have CI check it. See scylladb/scylladb#13492.

@denesb hi Botond, thanks for your review and help.