Repository navigation
feat(dist): Make conf/logs/plugins/pid paths overridable and fix log4j2 config resolution - #3253
AvanishShukla20 wants to merge 16 commits into
Conversation
77f7353 to
0c16408
Compare
bitflicker64
left a comment
There was a problem hiding this comment.
Blocking: yes. Summary: the conf, logs and pid overrides work for the paths they touch, but PD, Store and Server still require a writable $TOP/plugins, so the read-only install case from #3236 fails to start, and Store still writes its GC log to $TOP/logs, which a fresh install started with -l does not have, so the JVM exits; the change also drops -Dfastjson.parser.safeMode=true from Store and breaks restart-hugegraph-store.sh whenever start flags are passed. Evidence: static read of the full diff at 0c16408 against master 2f827d6 and the surrounding util.sh, restart-hugegraph-store.sh, monitor-hugegraph.sh, start-monitor.sh and application.yml; bash reproduction of the sourced stop/start getopts loops (restart.sh -j -Xmx4g exits 1 with 'illegal option -- j'); JDK 17 java -Xlog:gc=info:file=/nonexistent_dir_x/gc.log -version fails with 'Could not create the Java Virtual Machine'. All six workflow runs at this head are action_required, so no CI result exists yet.
imbajin
left a comment
There was a problem hiding this comment.
Blocking: yes. Summary: Relative config and log overrides can be interpreted from different working directories across startup and Java launch, causing startup to miss configured files or write logs elsewhere. Evidence: exact-head static trace of start-hugegraph.sh and hugegraph-server.sh across the change to TOP.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3253 +/- ##
============================================
+ Coverage 58.53% 58.62% +0.08%
- Complexity 2717 6933 +4216
============================================
Files 779 780 +1
Lines 69439 69640 +201
Branches 9577 9725 +148
============================================
+ Hits 40647 40826 +179
- Misses 25101 25118 +17
- Partials 3691 3696 +5
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
The Store startup changes must preserve Fastjson safe mode and route GC logs through the selected log directory.
Both issues are addressed by 8de1ddcf9. Plugin writability, restart/monitor propagation, relative paths, and deployment documentation still require work.
There was a problem hiding this comment.
The fixes in 8de1ddcf9 retain Fastjson safe mode and route the default GC log through ${LOGS}/gc.log.
Validation:
- Startup regressions cover default paths, absolute log overrides, and custom
JAVA_OPTIONS. - JDK 11 opens the captured GC paths; Fastjson 1.2.83 confirms safe mode.
- Shell syntax, formatting, diff checks, and independent review pass.
- Reactor compilation passes with generated Java reused after verifying identical proto inputs. Fresh native Protobuf generation and full Store-cluster acceptance remain unverified.
Plugin writability, restart/monitor propagation, relative paths, and matching documentation remain open.
bitflicker64
left a comment
There was a problem hiding this comment.
Blocking: yes. Summary: The -c, -l and -i overrides apply to the start and stop scripts, but on Server the -c override does not reach init-store.sh or the graphs directory, so a server started from an external conf dir can run against a backend that was initialized from, and graph configs loaded from, $TOP/conf. Earlier open findings on this head (writable $TOP/plugins on all three roles, the restart-hugegraph-store.sh getopts break, monitor restarts without overrides, relative override paths) are still unaddressed at 8de1ddc and are not repeated here. Evidence: static read of the full diff 2f827d6..8de1ddc and surrounding scripts; init-store.sh lines 30 and 58 still use
imbajin
left a comment
There was a problem hiding this comment.
Blocking: yes. Summary: Relative or unwritable -i overrides can leave a started service without a PID file that the stop scripts can find. Evidence: exact-head trace of PD/Store start and stop scripts; startup changes to $TOP before writing, stop reads from the caller directory, and PID writes occur after daemon launch.
a6e726c to
8741ae9
Compare
@imbajin |
imbajin
left a comment
There was a problem hiding this comment.
Blocking: yes. Summary: Store's default GC option still targets an uncreated nested directory, which can prevent a clean Store start; invalid overrides can silently fall back to defaults, and several new path flows do not preserve valid values. Evidence: static trace across Store startup and the changed path canonicalization, stop, and monitor scripts.
bitflicker64
left a comment
There was a problem hiding this comment.
Blocking: yes. Summary: The new Store GC log path is ${LOGS}/logs/gc.log, which nothing creates, so every Store start that uses the default JAVA_OPTIONS (tarball, Docker image, CI foreground test) fails before the JVM starts. Earlier open findings on the relative graphs path, PID write checks, unquoted PID_FILE, cron quoting, and the -o usage text are not repeated here. Evidence: static read of the full diff 176fb56..d384a6c and the Store launcher, Docker entrypoint and travis test; local JDK 17 run of java -Xlog:gc=info:file=<dir>/logs/logs/gc.log:... -version with only <dir>/logs present prints Invalid -Xlog option and Could not create the Java Virtual Machine. CI at this head has not run: all six workflow runs are action_required.
…j2 configs resolution ( apache#3236 )
…nonicalise overridden paths & fix store GC paths
- Add plugins directory override with -o flag
- Pass conf and plugins overrides to init-store.sh
- Route GC log output to ${LOGS} (fallback ./logs) instead of hardcoded path
- Persist path overrides into monitor-hugegraph.sh cron env so -m true
restarts reuse the correct conf/logs/pid paths
- Enable Fastjson safe mode (-Dfastjson.parser.safeMode=true) in Store JVM
- Run restart-hugegraph-store.sh steps as separate subprocesses, passing
-i to stop and all flags to start to avoid shared getopts/OPTIND clashes
d384a6c to
56a38a6
Compare
- Exit when canonicalize_dir/canonicalize_file fails
- Create and check the PID file's parent dir before launch
(server, PD, store) so the PID write cannot fail after startup
- Quote PID_FILE/CONF/LOGS (and OUTPUT, derived from LOGS)
in tests, reads and redirects in the start and stop scripts
- Quote BIN/TOP in start-monitor.sh, stop-monitor.sh and
monitor-hugegraph.sh
- Serialize JAVA_HOME, the four overrides and the monitor path into
the cron line as one POSIX shell word
- Reject CR/LF before canonicalization, and % when -m true
- Write the cron entry with printf '%s\n'; match add/remove on the
same serialized key so apostrophe paths stay removable
- Add -o plugins_dir to the usage text in util.sh
- Store: write gc.log under ${LOGS}
- Add test-cron-quote.sh (spaces, apostrophes, backslashes, shell
metacharacters, dash, duplicate add/remove, rejected input)
- Add test-canonicalize.sh (absolute, relative and nested paths,
unresolvable parents, nocreate mode for the stop scripts)
…+pidOverride Conflicts: hugegraph-pd/hg-pd-dist/src/assembly/static/bin/start-hugegraph-pd.sh hugegraph-store/hg-store-dist/src/assembly/static/bin/start-hugegraph-store.sh
…e canonicalization 1. Bash-array JVM launchers for quoting fix (PD/Store start+stop+restart) + test-launcher-argv.sh + test-override-guards.sh 2. reject_relative_conf_path util function (graphs/verify-path/license-path/data-path) — server, PD, store 3. ensure_file_readable util function (server, PD, store) 4. canonicalize_dir nocreate mode for -c and -i 5. classpath mode (reject ':') for -o validation 6. Moved test scripts out of assembly into src/test/shell and added them in server-tests.yml 7. stop-hugegraph-pd.sh timeout now exits 1 instead of falling through
There was a problem hiding this comment.
Fresh independent cross/adversarial review of this revision: 5/10 readiness; needs fixes (updated Oct 20, 22:30 UTC; prior 6/10 superseded by new independent runtime evidence).
The new CI step invokes test-override-guards.sh, but running the unmodified script with bash hugegraph-server/hugegraph-dist/src/test/shell/test-override-guards.sh at this revision independently returns PASS=74 FAIL=2 SKIP=0, exit 1. The failures are:
The monitor reads the configuration without the readability guard and only creates the log directory, without checking its writability. Consequently this newly required CI step cannot pass as written. Please add the matching fail-fast guards before reading the configuration or using the logs, retaining the assertions; if the intended contract differs, align the implementation and test without dropping equivalent failure coverage.
The new canonicalization and argv fixes are real progress: fresh bounded execution gives canonicalization 60/0, cron quoting 336/0, and launcher argv 22/0. Cross-checks also confirm that Store no longer starts after a failed stop and preserves paths containing spaces. The already-reported signal/preload fixture contract and Store override inheritance remain unresolved; they are not duplicated inline here.
Evidence boundary: independent cloud shell/fixture execution and static review, not a live-service, Maven, real JNI, performance or same-RC acceptance run. These local failures are not a claim that GitHub CI has already run and failed. The score is newly assessed for this revision, not inherited from the previous head; core CI must pass before merge readiness.
Update, Oct 20 22:30 UTC: independently reproduced the already-reported multiline JVM-option regression, without adding duplicate inline comments. On the same OpenJDK 21.0.12.1, the unchanged test-launcher-gc.sh fixture returns 15 pass / 6 fail at this reviewed revision, versus 21 pass / 0 fail with the prior 6052186 launchers. Both JAVA_OPTIONS and -j lose the second-line setting across Server, PD and Store: PrintFlagsFinal reports the existing RSet value 5 rather than the requested 2. A separate original-Store-launcher argv capture confirms the silent loss, while the launcher still exits successfully. This user-visible configuration regression, beyond fixture integration failures, lowers the independently assessed readiness to 5/10. Preserve all intended whitespace-separated JVM options across lines and add this regression coverage when fixing the parser. The original Store stop and Docker entrypoint fixtures also pass with prior launchers but fail at this revision, matching the existing discussions. These are bounded cloud process/JVM probes, not live graph-service, cluster, performance or same-RC acceptance tests; GitHub CI status is not inferred from them.
Implementation Summary (860ec0f)1. Bash-array JVM launchers — Quoting fix
2.
|
bitflicker64
left a comment
There was a problem hiding this comment.
Blocking: yes. Summary: Moving the user-supplied JVM option strings to read -r -a keeps only their first line, which drops options from multi-line -j and JAVA_OPTIONS values and fails the existing test-launcher-gc.sh, and two more existing fixtures (test-stop-hugegraph-store.sh and test-docker-entrypoint-process.sh) now fail on the new util.sh helper and config check. Three earlier comments still apply and are repeated unchanged; the other earlier comments from this account are fixed at this head, while the override-guards monitor failures, the signal and preload fixtures, the unchecked crontab -l reads and the missing docs from imbajin's reviews remain open. Evidence: ran the four new shell tests with bash 5.3 (canonicalize 60/0, cron-quote 337/0, launcher-argv 22/0, override-guards 74/2); ran seven existing fixtures on Linux (bash 5.2, JDK 17) at merge base 86c05ef and at this head: all pass at the base, and signal, stop-store, store-preloads, launcher-gc and docker-entrypoint-process fail at this head; read -r -d '' -a at the six sites makes test-launcher-gc pass; the only workflow run at this head is action_required, so there is no CI result.
The earlier review comments below still apply at 860ec0f; this head does not fix them.
- Important: The comment says this stop keeps the monitor, but stop-hugegraph.sh only reads options with
getopts "i:m:", and getopts stops at the positionalfalse. With-i /x/pid falseit sets the PID file and leavesCLOSE_MONITOR=true, so this call runs stop-monitor.sh and removes the cron job that is doing the restart. After one health-check restart the server is no longer monitored. The bug exists at the base too, but this PR edits this line and its comment. Please pass-m falseinstead of the barefalse. (#3253 (comment)) - Important: The removal key now always has single quotes around it, but the previous start-monitor.sh wrote the unquoted form
... && $TOP/bin/monitor-hugegraph.sh. After an in-place upgrade with an existing monitor job,grep -Fdoes not match,crontab_removereturns 0, stop-hugegraph.sh prints that the monitor was closed, and the old cron line can restart the server within a minute. The new start-monitor.sh also does not detect the old line and adds a second job. Please match both the quoted and unquoted forms when removing (and when checking for duplicates in crontab_append), and add an old-format-to-new-format case to test-cron-quote.sh. (#3253 (comment)) - Important: Store does not export the four overrides, so the restart that Store triggers on itself loses them.
PdConfigureListener.restart()runssh -c <user.dir>/bin/restart-hugegraph-store.shwith no arguments when PD publishes a newS:Timestamp, and the child only inherits the JVM environment. Here the overrides stay plain shell variables (start-hugegraph.sh on Server does export them). For a Store started with-c /etc/hugegraph-store -i /run/hugegraph-store/pid, that restart calls stop without-i, which finds no$BIN/pidand exits 0 without stopping anything. It then calls start with no flags, which resolves$TOP/conf. Thepscheck at line 253 looks for$TOP/confand does not match the running JVM, so a second Store JVM is launched from the stock conf while the original keeps running. Please export the overrides after they are resolved, for exampleexport CONF_OVERRIDE LOGS_OVERRIDE PLUGINS_OVERRIDE PID_FILE_OVERRIDEbelow this block, so restart-hugegraph-store.sh and stop-hugegraph-store.sh pick them up when called without flags. Separately, the listener reads and writes<user.dir>/conf/application-pd.yml, so the pushed config does not follow-ceither; that Java code is not part of this PR and may be better as a follow-up. (#3253 (comment))
imbajin
left a comment
There was a problem hiding this comment.
Blocking: yes. Summary: This head still has source-level startup defects, including Store being stopped before full path validation and Cygwin plugin paths splitting the runtime classpath. Evidence: exact-head static trace through the changed restart checks and Cygwin classpath conversion.
@bitflicker64 The changes intended for monitor scripts, start-monitor.sh will be covered as next steps after fixture failures and other feedbacks are resolved. |
1. test-start-hugegraph-signal.sh: source real util.sh, add gremlin-server.yaml 2. test-store-preloads.sh: verified sources real util.sh, stubs only ensure_path_writable/download_and_verify 3. test-stop-hugegraph-store.sh: verified sources real util.sh, stubs only kill_process_and_wait 4. test-launcher-gc.sh: verified sources real util.sh per launcher, stubs only free_memory 5. test-docker-entrypoint-process.sh: add conf/gremlin-server.yaml 6. PdConfigureListener.java: resolve application-pd.yml via spring.config.location 7. PdConfigureListenerYamlTest.java: add resolveConfigFilePath tests 8. start-hugegraph-store.sh: export CONF_OVERRIDE/LOGS_OVERRIDE/PLUGINS_OVERRIDE/PID_FILE_OVERRIDE 9. restart-hugegraph-store.sh: validate conf/logs/plugins/pid overrides before stopping the running Store 10. util.sh (server/pd/store): reject ';' in classpath mode 11. test-cron-quote.sh: add classpath ';' rejection assertion (server/pd/store) 12. monitor-hugegraph.sh: add ensure_file_readable and ensure_path_writable guards
imbajin
left a comment
There was a problem hiding this comment.
Blocking: yes. Summary: Four configuration and restart regressions remain in the path override support. Evidence: exact-head launcher/listener traces, a Bash child-environment probe, and an actual JVM unified-logging parser failure.
…ndling - restart-hugegraph-store.sh: seed -c/-l/-o/-i from inherited *_OVERRIDE env vars before getopts, so a no-arg restart targets external dirs. - start-hugegraph-store.sh/start-hugegraph-pd.sh/hugegraph-server.sh: build JAVA_OPTIONS in a new JAVA_OPTIONS_ARR so the exported scalar survives into any inheriting child process. - start-hugegraph.sh/start-hugegraph-store.sh: validate -c/-l/-o/-i after getopts on the effective variable, covering env-var input too. - util.sh (Store): add "xlog" mode to reject_unsafe_path(); reject ':' in $LOGS before the -Xlog:gc=... option, since its grammar also delimits on ':'. Annotated the same dormant lines in PD/Server. - test-override-guards.sh: added regression coverage for all four above fixes - Added -m false line in monitor-hugegraph.sh script
imbajin
left a comment
There was a problem hiding this comment.
Blocking: yes. Summary: Plugin-path validation can be bypassed by normalization of a relative override, leaving plugin classes unavailable. Evidence: A JDK 21 probe using the exact launcher helpers and classpath construction accepted the raw path, failed class loading after normalization under a colon-containing working directory, and passed with a delimiter-free control path.
bitflicker64
left a comment
There was a problem hiding this comment.
Blocking: yes. Summary: Most earlier findings are fixed at this head (monitor -m false, Store override export and no-argument restart, multi-line JVM options, the Store stop and Docker entrypoint fixtures, the new shell tests running in CI), but -c with an https REST URL still reads the keystore from $TOP/conf, and the Store listener misreads Spring-style config locations. The earlier stop-monitor.sh comment on old-format cron lines still applies. Evidence: on Linux (bash 5.2, JDK 17) the four new shell tests pass at this head (canonicalize 60/0, cron-quote rc 0, override-guards 109/0, launcher-argv 22/0), and the existing signal, stop-store, store-preloads, launcher-gc, cgroup-memory, topling-selection and check-port (69/0) fixtures pass at merge base 86c05ef and at this head; static trace of ServerOptions.SSL_KEYSTORE_FILE through RestServer.configHttpServer against start-hugegraph.sh lines 119-126; a JDK 17 probe of File.getParentFile on Spring location forms; the only workflow run at this head is action_required, so there is no CI result.
The earlier review comments below still apply at 3e78d09; this head does not fix them.
- Important: The removal key now always has single quotes around it, but the previous start-monitor.sh wrote the unquoted form
... && $TOP/bin/monitor-hugegraph.sh. After an in-place upgrade with an existing monitor job,grep -Fdoes not match,crontab_removereturns 0, stop-hugegraph.sh prints that the monitor was closed, and the old cron line can restart the server within a minute. The new start-monitor.sh also does not detect the old line and adds a second job. Please match both the quoted and unquoted forms when removing (and when checking for duplicates in crontab_append), and add an old-format-to-new-format case to test-cron-quote.sh. (#3253 (comment))
…tab old/new-format gaps in monitor scripts
- Re-validate plugins dir (-o) for unsafe classpath chars AFTER canonicalize_dir resolves it
- start-hugegraph.sh: resolve the HTTPS keystore the same way the JVM will (ssl.keystore_file, default path, reject relative under -c) instead of always checking/downloading under ${CONF}.
- PdConfigureListener.resolveConfigFilePath: correctly handle Spring's spring.config.location syntax (optional:/file: prefixes, directory form, comma-separated lists), with added unit tests per form.
- stop-monitor.sh/start-monitor.sh: match both the quoted and unquoted forms when removing (and when checking for duplicates in crontab_append), and add an old-format-to-new-format case to test-cron-quote.sh.
- util.sh (server/pd/store): add crontab_lock_acquire/release (flock-based or mkdir-based fallback), crontab_list (read the table, telling "empty" apart from "read failed"), and crontab_append/crontab_remove (file-backed, locked, interrupt-safe add/remove of a single cron line by key).
bitflicker64
left a comment
There was a problem hiding this comment.
Blocking: yes. Summary: The keystore, resolved plugin path, Spring location and legacy cron findings are fixed at this head, and the new shell suites and existing launcher fixtures pass on Linux. The new crontab lock and legacy cron key add two monitor regressions: a lock file owned by another account stops stop-monitor.sh from removing the job, and the unanchored key matches another install's job.
The earlier review comments below still apply at 53cba6c; this head does not fix them.
- 🧹 Minor: These new launcher options change user-facing deployment behavior, but no deployment documentation is updated in this PR. The Server runtime guide documents -g/-j only, and the PR marks Documentation Status as Doc - TODO; repository guidance requires matching in-repository docs for user-visible deployment changes. Please document the new -c, -i, -l, and -o overrides and their defaults in the appropriate Server/PD/Store runtime guidance in this change. (#3253 (comment))
…lision - util.sh (server/pd/store): key the crontab lock file to the calling user's uid (.hugegraph-crontab-$(id -u).lock) - util.sh (server/pd/store): print an error when the lock file can't be opened instead of silently returning 1 - start-monitor.sh/stop-monitor.sh: anchor the legacy unquoted dedup/ removal key with "&& " so grep -F can't match a shorter install's path as a substring of a longer, unrelated install's crontab line. - test-cron-quote.sh: add a regression test for the anchored-key fix.
- docs/server-runtime.md: add "Launcher path overrides" section with defaults, resolution behavior, and unsafe-character restrictions. - hugegraph-pd/README.md, hugegraph-store/README.md: extend "Startup Options" with the four path flags alongside existing -g/-j/-y/-d. - hugegraph-server/AGENTS.md: add "Launcher shell fixtures" subsection listing all four shell tests and their CI coverage. - hugegraph-pd/AGENTS.md, hugegraph-store/AGENTS.md: cross-reference Server's shell tests that also validate each module's util.sh.
bitflicker64
left a comment
There was a problem hiding this comment.
Blocking: yes. Summary: The lock-file fix at this head opens the crontab lock fd inside a command substitution, so on any host with flock every crontab edit fails: -m true installs no monitor and stop-hugegraph.sh cannot remove one. The earlier override, restart, legacy cron key and docs findings are fixed at this head.
bitflicker64
left a comment
There was a problem hiding this comment.
Blocking: yes. Summary: The earlier override, restart and docs findings stay fixed, but the crontab lock fd bug still breaks -m true on Linux, the last upstream merge was recorded with one parent so the PR conflicts with master and CI has not run, and the Store and PD already-running check matches conf dirs by substring.
The earlier review comments below still apply at 269fb75; this head does not fix them.
- Critical:
execruns inside$(...), so fd 9 opens only in that subshell and the parent'sflock -w ... 9fails withBad file descriptor; on Linux-m truenever installs the monitor,stop-hugegraph.shnever removes one, andtest-cron-quote.shfails 40 cases. Open the fd in the current shell, for exampleif ! eval "exec ${CRONTAB_LOCK_FD}>\"\$CRONTAB_LOCK_FILE\""; then, in the PD, Store and Serverutil.sh. (#3253 (comment))
…+pidOverride Conflicts: docs/server-runtime.md hugegraph-store/hg-store-dist/src/assembly/static/bin/start-hugegraph-store.sh
269fb75 to
fd066d0
Compare
util.sh(server,pd,store): exec ran inside $(...), so fd 9 closed with the subshell and flock always failed; run it directly so the fd persists for flock to use.
bitflicker64
left a comment
There was a problem hiding this comment.
Blocking: yes. Summary: The crontab lock, one-parent merge and -i docs findings are fixed at this head, but quoting the OpenTelemetry agent option breaks the existing test-java-security-properties.sh check, so server-rocksdb CI fails, the new PdConfigureListener tests never run in CI, and the Store and PD already-running check still matches conf dirs by substring.
The earlier review comments below still apply at 7791441; this head does not fix them.
- Important:
grep -F -- "${CONF}"matches any process whose arguments contain$CONFas a substring, so starting a Store with-c /etc/hg/storewhile another runs with-c /etc/hg/store-bprintsalready runningand exits 0 without launching. Match the full-Dspring.config.location=${CONF}/application.ymlargument here and atstart-hugegraph-pd.shline 259. (#3253 (comment))
…eck, correct -i docs - pd-store-ci.yml: add PdConfigureListenerYamlTest to the hg-store-node -Dtest list and require its surefire report in the coverage check - test-java-security-properties.sh: accept the quoted -javaagent option in the JAVA_TOOL_OPTIONS assertion - docs/server-runtime.md: drop init-store.sh from the -i parent-directory sentence
d3e2829 to
36dbdf6
Compare
bitflicker64
left a comment
There was a problem hiding this comment.
Blocking: yes. Summary: the new PdConfigureListenerYamlTest report entry breaks the test-check-jacoco-report.sh contract, so pd_store / store fails at this head. Under -c, Gremlin auth tokens and the Cypher client config still load from $TOP/conf, and the monitor cron job is keyed on the install directory alone, so two instances of one install share and remove one job.
- ci(pd-store-ci): add PdConfigureListenerYamlTest.xml to store job's required test-report set - fix(start-hugegraph): reject relative `tokens:` path in gremlin-server.yaml config block - fix(cypher-api): resolve remote-objects.yaml from CONF_OVERRIDE instead of fixed $TOP path - fix(start/stop-monitor): disambiguate crontab job key by PID file for multi-instance installs
bitflicker64
left a comment
There was a problem hiding this comment.
Blocking: yes. Summary: The new gremlin-server.yaml shape check rejects the shipped config, so every default Server start exits 1 and six CI jobs fail at this head. The per-pid monitor key also lets a stop without -i remove the monitor jobs of instances started with -i.
…efault pidfile key
- start-hugegraph.sh: only flag 'config:' lines that also carry 'tokens:'
as needing single-line form, so the stock gremlin-server.yaml's
multi-line serializer config: {} blocks are no longer rejected
- test-override-guards.sh: add Section 12 regression fixture that starts
from the shipped conf/gremlin-server.yaml.
- start-monitor.sh/stop-monitor.sh: tag the default (no -i) crontab job/key
with "# pidfile:default" so it's no longer a substring prefix of any -i
job's key
f627f3e to
c85bc9a
Compare
|
@imbajin the latest head ( |
Purpose of the PR
close #3236
Support running the PD, Store, and Server roles from read-only install locations, allowing their config, log, plugin, and PID paths to be redirected to writable, externally-managed directories.
Main Changes
1. Overridable runtime paths (start/stop/init/restart scripts)
Added CLI override flags — each mapping to an environment variable with a
fallback to default:
-cCONF_OVERRIDE$TOP/conf-lLOGS_OVERRIDE$TOP/logs-oPLUGINS_OVERRIDE$TOP/plugins-iPID_FILE_OVERRIDE$BIN/pid-o) — files are written here at startup (OpenTelemetry agentdownload, extension jars), so it must be writable. The start scripts validate
it with
ensure_path_writableinutil.sh, which fails fast if the path isnot writable.
-i) — supervisors need the PIDfile in a known, writable, per-instance location, and the stop scripts
must target the same PID the start scripts wrote.
-iwas added toboth start and stop scripts to keep them in agreement. The PID file's parent
directory is validated (
ensure_path_writable) before the service islaunched.
init-store.sh— accepts-cand-o(or inheritsCONF_OVERRIDE/PLUGINS_OVERRIDEfromstart-hugegraph.sh), so the schema initializationuses the same conf and plugins directories as the server.
restart-hugegraph-store.sh— parses all the flags, forwards all ofthem to
start-hugegraph-store.sh, and forwards only-i(the PID file) tostop-hugegraph-store.sh. Stop and start runas separate processes, so their option parsing cannot interfere with each
other.
getoptsbefore the path assignments so theoverrides are actually applied (previously the option string omitted these
flags and/or paths were finalized before parsing).
2. Relative paths are normalized, and failures stop the script
Added
canonicalize_dirandcanonicalize_filetoutil.sh. They turn arelative override into an absolute path before it is used or exported.
-c,-l,-o) are created if missing and resolved.-i) has its parent directory created and resolvedby the start scripts. The stop scripts call
canonicalize_file … nocreate,which resolves the path but does not create any directory.
|| exit 1.3. Monitor (
-m true) works together with the overrides-m trueinstalls a cron job (start-monitor.sh) that runsmonitor-hugegraph.sh.start-hugegraph.shexports the four overrides, andstart-monitor.shpersists them in the cron command.
monitor-hugegraph.shreadsCONF/LOGSfrom the overrides, and restartsthe server by calling
stop-hugegraph.sh -i <pid_file>andstart-hugegraph.sh -m falsewith the same-c/-l/-o/-ivalues.Cron command serialization
JAVA_HOME, the four overrides, and the monitor script path are each writteninto the cron line as one POSIX shell word (
shell_quote/cron_quotein
util.sh), e.g./data/team's-logsbecomes'/data/team'\''s-logs'.Callers add no extra quotes.
getoptsloop).%is also rejected when-m true, because cron treats it speciallyinside shell quotes. Both checks run before the crontab is touched.
printf '%s\n', andgrep -F --is used so avalue starting with
-is not read as an option.stop-monitor.shbuilds its removal key with the same quoting, so a path withan apostrophe still matches and the job can be removed.
4. Quoting of override paths
PID_FILE,CONF,LOGS(andOUTPUT, which is derived fromLOGS) arequoted wherever they are tested, read, redirected, or passed as an argument in
the start and stop scripts, so a path containing spaces is handled as one
value (for example a PID file at
/var/lib/Huge Graph/server.pid).5. Log4j2 / logging-config resolution fixes (start scripts)
Expanded
JVM_OPTIONSacross PD/Store/Server start scripts so logging isresolved consistently:
-Dlogging.configso Spring Boot–based modules honor theintended
log4j2.xml.6.
LOG_PATHmade overridable in thelog4j2.xmlfilesChanged
log4j2.xmlfiles from a hardcoded<property name="LOG_PATH">logs</property>to:
so the log directory tracks the
-DLOG_PATHset by the start scripts. Thisspans the PD, Store, and Server dist
conf/configs.How
LOG_PATHresolvesConfigs now converge on
${sys:LOG_PATH:-logs}— theLOG_PATHJVMsystem property (
-DLOG_PATH=<dir>), falling back to relative./logs.The start scripts set this from the logs override:
conf/conf/log4j2.xml-l <dir>→-DLOG_PATH=${LOGS}Backward compatibility
Every override falls back to the previous default when its flag/variable is not supplied, so existing standalone invocations and packaging behave as before.
Verifying these changes
hugegraph-server/hugegraph-dist/src/test/shell/test-canonicalize.sh—relative/absolute/unresolvable directory and PID-file overrides.
hugegraph-server/hugegraph-dist/src/test/shell/test-cron-quote.sh—It uses a stubbed
crontaband checks spaces, apostrophes, backslashes and shell metacharacters surviveexecution through
/bin/sh(and dash when installed); CR/LF and%rejection; duplicate add and removal; rejected input leaves the existing
crontab unchanged.
hugegraph-server/hugegraph-dist/src/test/shell/test-override-guards.sh—static and behavioral guard-coverage checks for the
-c/-l/-o/-ipathoverrides across Server, PD and Store: unsafe-character rejection both
before and after canonicalization, writability/readability checks, and
the relative-conf-path guard for
graphsandssl.keystore_filewhen-cis set.hugegraph-server/hugegraph-dist/src/test/shell/test-launcher-argv.sh—verifies the launcher's argv/classpath construction honors the resolved
overrides (conf/logs/plugins/pid).
Does this PR potentially affect the following parts?
Documentation Status
Select one option and provide the documentation location when applicable.
Doc - TODO: required documentation is pending; complete it before merging.Doc - Done: documentation is included in1d42786Doc - No Need: no user-visible documentation is affected.Documentation added for this PR
docs/server-runtime.md— new "Launcher path overrides" section documenting-c/-l/-i/-o, their defaults, create-vs-resolve-only behavior, unsafecharacter restrictions, and the
graphs/ssl.keystore_filerelative-pathpitfall under
-c.hugegraph-pd/README.md— "Startup Options" section extended with-c/-l/-i/-oflags, defaults and behavior, alongside the existing-g/-j/-y/-dflags.hugegraph-store/README.md— "Startup Options" section extended the sameway, plus a note that
restart-hugegraph-store.shvalidates-c/-l/-obefore stopping the running Store.
hugegraph-server/AGENTS.md— new "Launcher shell fixtures" subsection under"Tests" listing all four shell test files, what each covers, and that they
run in CI via
server-tests.yml.hugegraph-pd/AGENTS.md/hugegraph-store/AGENTS.md— cross-referencenoting that Server's
test-cron-quote.sh/test-override-guards.shalsovalidate each module's own copy of
util.sh.Visual overview
Conceptual overview of proposed runtime path overrides: configuration, logs, plugins and PID paths are normalized for PD, Store and Server launchers. Start and stop use the same PID path, and the optional Server monitor preserves overrides on restart. Path edge cases and restart validation remain open; this is not acceptance evidence.