imbajin commented on code in PR #2952:
URL:
https://github.com/apache/incubator-hugegraph/pull/2952#discussion_r2837674045
##########
hugegraph-server/hugegraph-dist/docker/docker-entrypoint.sh:
##########
@@ -15,32 +15,66 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
+set -euo pipefail
-# create a folder to save the docker-related file
-DOCKER_FOLDER='./docker'
-mkdir -p $DOCKER_FOLDER
-
+DOCKER_FOLDER="./docker"
INIT_FLAG_FILE="init_complete"
+GRAPH_CONF="./conf/graphs/hugegraph.properties"
+
+mkdir -p "${DOCKER_FOLDER}"
+
+log() { echo "[hugegraph-server-entrypoint] $*"; }
+
+fail_on_deprecated() {
+ local old_name="$1" new_name="$2"
+ if [[ -n "${!old_name:-}" ]]; then
+ echo "ERROR: deprecated env '${old_name}' detected. Use '${new_name}'
instead." >&2
+ exit 2
+ fi
+}
+
+set_prop() {
+ local key="$1" val="$2" file="$3"
Review Comment:
⚠️ **`set_prop` uses unquoted sed with `#` delimiter — breaks if value
contains `#`**
The `set_prop` function uses `sed -ri "s#...#\\1${val}#"`. If `${val}`
contains a `#` character (e.g., a URL fragment, comment, or path), sed will
interpret it as a delimiter and produce a broken or corrupted properties file.
The same issue applies to the key argument used in the `grep -q -E` pattern
— a key containing regex metacharacters would fail silently.
```suggestion
set_prop() {
local key="$1" val="$2" file="$3"
# Escape val for use as sed replacement (handles &, /, \\, and newlines)
local esc_val
esc_val=$(printf '%s' "$val" | sed -e 's/[&\\/]/\\\\&/g')
if grep -qF "${key}=" "${file}"; then
sed -ri "s|^([[:space:]]*$(printf '%s' "${key}" | sed
's/[.|*+?[^]$/]/\\\\&/g')[[:space:]]*=).*|\\1${esc_val}|" "${file}"
else
printf '%s=%s\n' "${key}" "${val}" >> "${file}"
fi
}
```
##########
hugegraph-pd/hg-pd-dist/docker/docker-entrypoint.sh:
##########
@@ -15,8 +15,71 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
+set -euo pipefail
-# start hugegraph pd
-./bin/start-hugegraph-pd.sh -j "$JAVA_OPTS"
+log() { echo "[hugegraph-pd-entrypoint] $*"; }
+fail_on_deprecated() {
+ local old_name="$1" new_name="$2"
+ if [[ -n "${!old_name:-}" ]]; then
+ echo "ERROR: deprecated env '${old_name}' detected. Use '${new_name}'
instead." >&2
+ exit 2
+ fi
+}
+
+require_env() {
+ local name="$1"
+ if [[ -z "${!name:-}" ]]; then
+ echo "ERROR: missing required env '${name}'" >&2; exit 2
+ fi
+}
+
+json_escape() {
+ local s="$1"
+ s=${s//\\/\\\\}; s=${s//\"/\\\"}; s=${s//$'\n'/}
+ printf "%s" "$s"
+}
+
+# ── Guard deprecated vars ─────────────────────────────────────────────
+fail_on_deprecated "GRPC_HOST" "HG_PD_GRPC_HOST"
+fail_on_deprecated "RAFT_ADDRESS" "HG_PD_RAFT_ADDRESS"
+fail_on_deprecated "RAFT_PEERS" "HG_PD_RAFT_PEERS_LIST"
+fail_on_deprecated "PD_INITIAL_STORE_LIST" "HG_PD_INITIAL_STORE_LIST"
+
+# ── Required vars ─────────────────────────────────────────────────────
+require_env "HG_PD_GRPC_HOST"
+require_env "HG_PD_RAFT_ADDRESS"
+require_env "HG_PD_RAFT_PEERS_LIST"
+require_env "HG_PD_INITIAL_STORE_LIST"
+
+# ── Defaults ──────────────────────────────────────────────────────────
+: "${HG_PD_GRPC_PORT:=8686}"
+: "${HG_PD_REST_PORT:=8620}"
+: "${HG_PD_DATA_PATH:=/hugegraph-pd/pd_data}"
+
+# ── Build SPRING_APPLICATION_JSON ─────────────────────────────────────
+SPRING_APPLICATION_JSON="$(cat <<JSON
+{
+ "grpc": { "host": "$(json_escape "${HG_PD_GRPC_HOST}")",
+ "port": "$(json_escape "${HG_PD_GRPC_PORT}")" },
+ "server": { "port": "$(json_escape "${HG_PD_REST_PORT}")" },
+ "raft": { "address": "$(json_escape "${HG_PD_RAFT_ADDRESS}")",
+ "peers-list": "$(json_escape "${HG_PD_RAFT_PEERS_LIST}")" },
+ "pd": { "data-path": "$(json_escape "${HG_PD_DATA_PATH}")",
+ "initial-store-list": "$(json_escape
"${HG_PD_INITIAL_STORE_LIST}")" }
Review Comment:
⚠️ **`HG_PD_INITIAL_STORE_COUNT` default is set but never written to
`SPRING_APPLICATION_JSON`**
The entrypoint sets `: "${HG_PD_INITIAL_STORE_COUNT:=1}"` as a default for
single-node, but this value is never included in the `SPRING_APPLICATION_JSON`
block that configures Spring Boot. As a result, PD will use its
application-default value (3) for `pd.initial-store-count`, requiring 3 store
nodes before the cluster becomes ready — which breaks single-node deployments.
The `pd` section in `SPRING_APPLICATION_JSON` must include this:
```suggestion
"pd": { "data-path": "$(json_escape "${HG_PD_DATA_PATH}")",
"initial-store-list": "$(json_escape
"${HG_PD_INITIAL_STORE_LIST}")",
"initial-store-count": $(json_escape
"${HG_PD_INITIAL_STORE_COUNT}") }
```
Note: `initial-store-count` should be an integer in JSON (no quotes), not a
string.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]