-
Notifications
You must be signed in to change notification settings - Fork 627
fix(server): configure finite DNS cache TTL #3126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
10ed6d2
35e1a24
0a07cd8
625d3b7
9438a94
4d0ff03
9d53f15
791947c
b40c42f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -64,6 +64,10 @@ ensure_path_writable "$PLUGINS" | |
| MAX_MEM=$((32 * 1024)) | ||
| MIN_MEM=$((1 * 512)) | ||
| MIN_JAVA_VERSION=11 | ||
| # JDK 24 removed the Security Manager (JEP 486): "-Djava.security.manager=allow" | ||
| # is a fatal VM initialization error there and System.setSecurityManager() always | ||
| # throws, so HugeSecurityManager cannot be installed on newer runtimes. | ||
| MAX_SECURITY_JAVA_VERSION=23 | ||
|
|
||
| # Add the slf4j-log4j12 binding | ||
| CP=$(find -L $LIB -name 'log4j-slf4j-impl*.jar' | sort | tr '\n' ':') | ||
|
|
@@ -93,8 +97,15 @@ else | |
| JAVA="$JAVA_HOME/bin/java -server" | ||
| fi | ||
|
|
||
| JAVA_VERSION=$($JAVA -version 2>&1 | head -1 | cut -d'"' -f2 | sed 's/^1\.//' | cut -d'.' -f1) | ||
| if [[ $? -ne 0 || $JAVA_VERSION -lt $MIN_JAVA_VERSION ]]; then | ||
| # Pick the version line explicitly: the JVM prints a preamble such as | ||
| # "Picked up JAVA_TOOL_OPTIONS: ..." before it whenever JAVA_TOOL_OPTIONS or | ||
| # _JAVA_OPTIONS is set, and reading that line instead would leave JAVA_VERSION | ||
| # unusable and silently skip every version-gated option below. | ||
| JAVA_VERSION=$($JAVA -version 2>&1 | awk -F'"' '/version "/ {print $2; exit}' | | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 9d53f15. The match is now anchored to the JVM banner line itself — only lines starting with Added two mock-JVM regressions where an agent banner precedes the JVM's:
Both fail against the unanchored match (re-verified by mutating the packaged launcher back to |
||
| sed 's/^1\.//' | cut -d'.' -f1) | ||
| # Drop any pre-release suffix, e.g. "24-ea" -> "24" | ||
| JAVA_VERSION="${JAVA_VERSION%%[!0-9]*}" | ||
| if [[ -z $JAVA_VERSION || $JAVA_VERSION -lt $MIN_JAVA_VERSION ]]; then | ||
| echo "Make sure the JDK is installed and the version >= $MIN_JAVA_VERSION, current is $JAVA_VERSION" \ | ||
| >> "${OUTPUT}" | ||
| exit 1 | ||
|
|
@@ -142,8 +153,39 @@ case "$GC_OPTION" in | |
| esac | ||
|
|
||
| JVM_OPTIONS="-Dlog4j.configurationFile=${CONF}/log4j2.xml" | ||
| SECURITY_MANAGER_OPTION="" | ||
| if [[ ${OPEN_SECURITY_CHECK} == "true" ]]; then | ||
| JVM_OPTIONS="${JVM_OPTIONS} -Djava.security.manager=org.apache.hugegraph.security.HugeSecurityManager" | ||
| if [[ ${JAVA_VERSION} -gt ${MAX_SECURITY_JAVA_VERSION} ]]; then | ||
| SECURITY_UNSUPPORTED_MSG=$(cat <<EOF | ||
| The security check requires Java ${MIN_JAVA_VERSION}-${MAX_SECURITY_JAVA_VERSION}, current is ${JAVA_VERSION}. | ||
| JDK 24+ removed the Security Manager (JEP 486), so HugeSecurityManager can no longer be installed. | ||
| Run the server on Java ${MAX_SECURITY_JAVA_VERSION} or lower, or start it with the security check | ||
| disabled: 'start-hugegraph.sh -s false'. | ||
| EOF | ||
| ) | ||
| echo "${SECURITY_UNSUPPORTED_MSG}" >&2 | ||
| echo "${SECURITY_UNSUPPORTED_MSG}" >> "${OUTPUT}" | ||
| exit 1 | ||
| fi | ||
|
|
||
| SECURITY_PROPERTIES="${CONF}/java-security.properties" | ||
| if [[ ! -r ${SECURITY_PROPERTIES} ]]; then | ||
| # The bootstrap validates the effective policy and refuses to start, but | ||
| # its stderr goes to the stdout log in daemon mode. Name the cause here | ||
| # so it also reaches the log start-hugegraph.sh points operators at. | ||
| cat >> "${OUTPUT}" <<EOF | ||
| ERROR: Missing or unreadable '${SECURITY_PROPERTIES}'. | ||
| An upgraded deployment that reuses an older conf/ directory must add this file, | ||
| or supply its own -Djava.security.properties=<file> setting a finite positive | ||
| networkaddress.cache.ttl. | ||
| EOF | ||
| fi | ||
| JVM_OPTIONS="${JVM_OPTIONS} \ | ||
| -Djava.security.properties=${SECURITY_PROPERTIES}" | ||
| if [[ ${JAVA_VERSION} -ge 18 ]]; then | ||
|
bitflicker64 marked this conversation as resolved.
|
||
| # Required to install HugeSecurityManager programmatically on JDK 18+. | ||
| SECURITY_MANAGER_OPTION="-Djava.security.manager=allow" | ||
| fi | ||
| fi | ||
|
|
||
| if [ "${OPEN_TELEMETRY}" == "true" ]; then | ||
|
|
@@ -186,10 +228,14 @@ fi | |
|
|
||
| # Turn on security check | ||
| if [[ "${STDOUT_MODE:-false}" == "true" ]]; then | ||
| exec ${JAVA} -Dname="HugeGraphServer" ${JVM_OPTIONS} ${JAVA_OPTIONS} -cp ${CLASSPATH}: \ | ||
| org.apache.hugegraph.dist.HugeGraphServer ${GREMLIN_SERVER_CONF} ${REST_SERVER_CONF} | ||
| exec ${JAVA} -Dname="HugeGraphServer" ${JVM_OPTIONS} ${JAVA_OPTIONS} \ | ||
| ${SECURITY_MANAGER_OPTION} -cp ${CLASSPATH}: \ | ||
| org.apache.hugegraph.bootstrap.HugeGraphServerBootstrap \ | ||
| ${OPEN_SECURITY_CHECK} ${GREMLIN_SERVER_CONF} ${REST_SERVER_CONF} | ||
| else | ||
| exec ${JAVA} -Dname="HugeGraphServer" ${JVM_OPTIONS} ${JAVA_OPTIONS} -cp ${CLASSPATH}: \ | ||
| org.apache.hugegraph.dist.HugeGraphServer ${GREMLIN_SERVER_CONF} ${REST_SERVER_CONF} \ | ||
| exec ${JAVA} -Dname="HugeGraphServer" ${JVM_OPTIONS} ${JAVA_OPTIONS} \ | ||
| ${SECURITY_MANAGER_OPTION} -cp ${CLASSPATH}: \ | ||
| org.apache.hugegraph.bootstrap.HugeGraphServerBootstrap \ | ||
| ${OPEN_SECURITY_CHECK} ${GREMLIN_SERVER_CONF} ${REST_SERVER_CONF} \ | ||
| >> ${LOGS}/hugegraph-server-stdout.log 2>&1 | ||
| fi | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| # Licensed to the Apache Software Foundation (ASF) under one or more | ||
| # contributor license agreements. See the NOTICE file distributed with | ||
| # this work for additional information regarding copyright ownership. | ||
| # The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| # (the "License"); you may not use this file except in compliance with | ||
| # the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| # Permit failed network clients to resolve a changed address instead of | ||
| # retaining the first successful DNS result for the lifetime of the JVM. | ||
| networkaddress.cache.ttl=30 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HugeGraphServerBootstrapTest: it runsmvn package -Dmaven.test.skip=true, whilerun-unit-test.shonly runshugegraph-testfor the memory matrix and does nothing for RocksDB. As a result, the workflow's RocksDB path validates only the shell smoke script, not these two unit tests; please add an explicitmvn test -pl hugegraph-server/hugegraph-dist -am -Dtest=HugeGraphServerBootstrapTest(or include the module in an existing test command) so the added assertions are exercised in CI.