Skip to content

feat(dist): Make conf/logs/plugins/pid paths overridable and fix log4j2 config resolution - #3253

Open
AvanishShukla20 wants to merge 16 commits into
apache:masterfrom
AvanishShukla20:conf+logs+plugins+pidOverride
Open

AvanishShukla20 wants to merge 16 commits into
apache:masterfrom
AvanishShukla20:conf+logs+plugins+pidOverride

Conversation

@AvanishShukla20

@AvanishShukla20 AvanishShukla20 commented Sep 29, 2026 •

Copy link
Copy Markdown

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:

Concern Flag Variable Fallback
Conf dir -c CONF_OVERRIDE $TOP/conf
Logs dir -l LOGS_OVERRIDE $TOP/logs
Plugins dir -o PLUGINS_OVERRIDE $TOP/plugins
PID file -i PID_FILE_OVERRIDE $BIN/pid
  • Plugins (-o) — files are written here at startup (OpenTelemetry agent
    download, extension jars), so it must be writable. The start scripts validate
    it with ensure_path_writable in util.sh, which fails fast if the path is
    not writable.
  • PID file (-i) — supervisors need the PID
    file in a known, writable, per-instance location, and the stop scripts
    must target the same PID the start scripts wrote. -i was added to
    both start and stop scripts to keep them in agreement. The PID file's parent
    directory is validated (ensure_path_writable) before the service is
    launched.
  • init-store.sh — accepts -c and -o (or inherits CONF_OVERRIDE /
    PLUGINS_OVERRIDE from start-hugegraph.sh), so the schema initialization
    uses the same conf and plugins directories as the server.
  • restart-hugegraph-store.sh — parses all the flags, forwards all of
    them to start-hugegraph-store.sh, and forwards only -i (the PID file) to
    stop-hugegraph-store.sh. Stop and start run
    as separate processes, so their option parsing cannot interfere with each
    other.
  • Store/PD start scripts moved getopts before the path assignments so the
    overrides 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_dir and canonicalize_file to util.sh. They turn a
relative override into an absolute path before it is used or exported.

  • Directory overrides (-c, -l, -o) are created if missing and resolved.
  • The PID file override (-i) has its parent directory created and resolved
    by the start scripts. The stop scripts call canonicalize_file … nocreate,
    which resolves the path but does not create any directory.
  • Fail fast: each call is followed by || exit 1.

3. Monitor (-m true) works together with the overrides

-m true installs a cron job (start-monitor.sh) that runs
monitor-hugegraph.sh.

  • start-hugegraph.sh exports the four overrides, and start-monitor.sh
    persists them in the cron command.
  • monitor-hugegraph.sh reads CONF/LOGS from the overrides, and restarts
    the server by calling stop-hugegraph.sh -i <pid_file> and
    start-hugegraph.sh -m false with the same -c/-l/-o/-i values.

Cron command serialization

  • JAVA_HOME, the four overrides, and the monitor script path are each written
    into the cron line as one POSIX shell word (shell_quote / cron_quote
    in util.sh), e.g. /data/team's-logs becomes '/data/team'\''s-logs'.
    Callers add no extra quotes.
  • CR/LF is rejected with a clear error before canonicalization (in the
    getopts loop).
    % is also rejected when -m true, because cron treats it specially
    inside shell quotes. Both checks run before the crontab is touched.
  • The cron entry is written with printf '%s\n', and grep -F -- is used so a
    value starting with - is not read as an option.
  • stop-monitor.sh builds its removal key with the same quoting, so a path with
    an apostrophe still matches and the job can be removed.

4. Quoting of override paths

PID_FILE, CONF, LOGS (and OUTPUT, which is derived from LOGS) are
quoted 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_OPTIONS across PD/Store/Server start scripts so logging is
resolved consistently:

-Dlogging.config=${CONF}/log4j2.xml     # Spring Boot picks up the intended config
-DLOG_PATH=${LOGS} -Dbolt.log.path=${LOGS} -Dlogging.path=${LOGS}
  • Added the missing -Dlogging.config so Spring Boot–based modules honor the
    intended log4j2.xml .

6. LOG_PATH made overridable in the log4j2.xml files

Changed log4j2.xml files from a hardcoded <property name="LOG_PATH">logs</property>
to:

<property name="LOG_PATH">${sys:LOG_PATH:-logs}</property>

so the log directory tracks the -DLOG_PATH set by the start scripts. This
spans the PD, Store, and Server dist conf/ configs.

How LOG_PATH resolves

Configs now converge on ${sys:LOG_PATH:-logs} — the LOG_PATH JVM
system property
(-DLOG_PATH=<dir>), falling back to relative ./logs.
The start scripts set this from the logs override:

Category Files Override mechanism
Dist / daemon conf/ pd/store/server conf/log4j2.xml Start script -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

  • Trivial rework / code cleanup without any test coverage. Run the Service on live cluster and manually tested these.
  • Already covered by existing tests, such as (please modify tests here).
  • Need tests and can be verified as follows:
    • 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 crontab and checks spaces, apostrophes, backslashes and shell metacharacters survive
      execution 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/-i path
      overrides across Server, PD and Store: unsafe-character rejection both
      before and after canonicalization, writability/readability checks, and
      the relative-conf-path guard for graphs and ssl.keystore_file when
      -c is 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 in 1d42786
  • Doc - 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, unsafe
    character restrictions, and the graphs/ssl.keystore_file relative-path
    pitfall under -c.
  • hugegraph-pd/README.md — "Startup Options" section extended with
    -c/-l/-i/-o flags, defaults and behavior, alongside the existing
    -g/-j/-y/-d flags.
  • hugegraph-store/README.md — "Startup Options" section extended the same
    way, plus a note that restart-hugegraph-store.sh validates -c/-l/-o
    before 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-reference
    noting that Server's test-cron-quote.sh/test-override-guards.sh also
    validate each module's own copy of util.sh.

Visual overview

Conceptual overview of PR #3253

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.

@AvanishShukla20 AvanishShukla20 changed the title feat(dist): Make conf/logs/plugins/pid paths overridable and fix log4j2 config resolution #3236 feat(dist): Make conf/logs/plugins/pid paths overridable and fix log4j2 config resolution Sep 29, 2026
@AvanishShukla20
AvanishShukla20 force-pushed the conf+logs+plugins+pidOverride branch 3 times, most recently from 77f7353 to 0c16408 Compare September 30, 2026 11:15
@AvanishShukla20
AvanishShukla20 marked this pull request as ready for review September 30, 2026 11:16

@bitflicker64 bitflicker64 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 imbajin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

codecov Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 60.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.62%. Comparing base (0abd931) to head (c85bc9a).
⚠️ Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
...ava/org/apache/hugegraph/api/cypher/CypherAPI.java 60.00% 1 Missing and 1 partial ⚠️
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     
Flag Coverage Δ *Carryforward flag
commons 96.37% <ø> (ø) Carriedforward from 91f5ef8
hstore 36.15% <60.00%> (+0.06%) ⬆️
pd 57.04% <ø> (+0.23%) ⬆️
server_hbase 42.38% <60.00%> (-0.17%) ⬇️
server_memory 57.05% <60.00%> (+0.39%) ⬆️
server_rocksdb 42.87% <60.00%> (-0.22%) ⬇️
store 36.13% <ø> (-0.10%) ⬇️

*This pull request uses carry forward flags. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@imbajin imbajin left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@imbajin imbajin left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 bitflicker64 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 $TOP/conf; stock rest-server.properties sets graphs=./conf/graphs; hugegraph-server.sh line 91 runs cd "${TOP}" before Java, and HugeGraphServer, GraphManager and InitStore read ServerOptions.GRAPHS as a path relative to that working directory. All latest-head CI checks pass.

@imbajin imbajin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@AvanishShukla20

AvanishShukla20 commented Oct 2, 2026 •

Copy link
Copy Markdown
Author

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.

@imbajin
Apologies for dropping the commit 8de1ddcf9 during the mistakenly done rebase/history cleanup.I have incorporated the changes of 8de1ddcf9 in the latest commit ( d384a6c ) in this PR.

@imbajin imbajin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 bitflicker64 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

…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
@AvanishShukla20
AvanishShukla20 force-pushed the conf+logs+plugins+pidOverride branch from d384a6c to 56a38a6 Compare October 8, 2026 06:05
- 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

@imbajin imbajin left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@AvanishShukla20

AvanishShukla20 commented Oct 20, 2026 •

Copy link
Copy Markdown
Author

Implementation Summary (860ec0f)

1. Bash-array JVM launchers — Quoting fix

  • Updated start-hugegraph-pd.sh, stop-hugegraph-pd.sh, start-hugegraph-store.sh, and restart-hugegraph-store.sh to build JVM options using Bash arrays instead of a single interpolated string.
  • Added test-launcher-argv.sh, which runs the actual launchers against a stub java executable and verifies that each -D... option, classpath argument, and config-file argument is passed as exactly one argument.
  • Added a self-check that deliberately reproduces the old, broken unquoted-string implementation to verify that the regression test detects the issue.

2. reject_relative_conf_path — New util.sh function

  • Added reject_relative_conf_path to reject relative graphs, verify-path, and license-path values in configuration files when -c overrides the config path.

3. ensure_file_readable — New util.sh function

  • Added ensure_file_readable to the Server, PD, and Store util.sh files.
  • Validates that a potentially overridden -c configuration file exists (-f) and is readable (-r) before any read_property call.
  • Integrated into:
    • start-hugegraph.sh
    • init-store.sh
    • start-hugegraph-pd.sh
    • start-hugegraph-store.sh
  • Remaining gap: monitor-hugegraph.sh has only partial coverage. The audit confirms the CONF readability guard and empty-URL guard, but forwarding is covered only for -l, -o, and -i. Full guard coverage is still pending.

4. canonicalize_dir — Optional nocreate mode

  • Extended canonicalize_dir with an optional second argument:
    • Default mode: creates the directory.
    • nocreate mode: canonicalizes the path without creating the directory.
    • Applied nocreate handling to -i (PID file) through canonicalize_file.

5. Classpath validation for -o

  • Enabled classpath mode in reject_unsafe_path for -o, adding : to the rejected characters.
  • Prevents paths containing : from corrupting classpath entry boundaries when the plugins directory is included in the colon-separated CLASSPATH / JAVA_TOOL_OPTIONS string.
  • Kept -c and -l on crlf mode because they are consumed as individual -D values rather than colon-separated lists.

6. Shell test scripts moved out of the assembly

  • Moved the following scripts from src/assembly/static/bin/ to hugegraph-dist/src/test/shell/:
    • test-canonicalize.sh
    • test-cron-quote.sh
    • test-override-guards.sh
    • test-launcher-argv.sh
  • Prevents these test-only scripts from being included in the release tarball's bin/ directory through assembly.xml's <include>*</include> rule.

7. stop-hugegraph-pd.sh

  • Updated the process-termination logic to match the Server/Store pattern:
    if kill_process_and_wait ...; then
        rm "$PID_FILE"
    else
        exit 1
    fi
  • Ensures a timed-out process termination returns a failure exit code instead of incorrectly falling through to exit code 0.

8. test-override-guards.sh — New regression test script

  • Added test-override-guards.sh under hugegraph-dist/src/test/shell/, covering end-to-end behavioural checks for the -c, -l, -o, and -i overrides across Server, PD, and Store start/stop/restart/init scripts.

Monitor scripts fixes (will be covered in upcoming commits)

  • Safely recognize or migrate the legacy (unquoted) cron-entry format when adding/removing entries.
  • Add an upgrade regression covering "old-version creation → new-version removal", while retaining the existing tests for spaces and single quotes in paths.
  • Using util.sh helpers in the monitor scripts as needed.

@bitflicker64 bitflicker64 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 positional false. With -i /x/pid false it sets the PID file and leaves CLOSE_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 false instead of the bare false. (#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 -F does not match, crontab_remove returns 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() runs sh -c <user.dir>/bin/restart-hugegraph-store.sh with no arguments when PD publishes a new S: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/pid and exits 0 without stopping anything. It then calls start with no flags, which resolves $TOP/conf. The ps check at line 253 looks for $TOP/conf and 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 example export CONF_OVERRIDE LOGS_OVERRIDE PLUGINS_OVERRIDE PID_FILE_OVERRIDE below 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 -c either; that Java code is not part of this PR and may be better as a follow-up. (#3253 (comment))

@imbajin imbajin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@AvanishShukla20

Copy link
Copy Markdown
Author

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 positional false. With -i /x/pid false it sets the PID file and leaves CLOSE_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 false instead of the bare false. (#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 -F does not match, crontab_remove returns 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))

@bitflicker64 The changes intended for monitor scripts, start-monitor.sh will be covered as next steps after fixture failures and other feedbacks are resolved.
The head 860ec0f does not cover it fully as described in implementation summary. Thank you so much for pointing out the fixture failures.Review feedbacks from imbajin have also been noted . They will be addressed in the upcoming commit.

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 imbajin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 imbajin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 bitflicker64 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 -F does not match, crontab_remove returns 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 bitflicker64 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 bitflicker64 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 bitflicker64 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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: exec runs inside $(...), so fd 9 opens only in that subshell and the parent's flock -w ... 9 fails with Bad file descriptor; on Linux -m true never installs the monitor, stop-hugegraph.sh never removes one, and test-cron-quote.sh fails 40 cases. Open the fd in the current shell, for example if ! eval "exec ${CRONTAB_LOCK_FD}>\"\$CRONTAB_LOCK_FILE\""; then, in the PD, Store and Server util.sh. (#3253 (comment))

Comment thread docs/server-runtime.md Resolved
…+pidOverride

Conflicts:
	docs/server-runtime.md
	hugegraph-store/hg-store-dist/src/assembly/static/bin/start-hugegraph-store.sh
@AvanishShukla20
AvanishShukla20 force-pushed the conf+logs+plugins+pidOverride branch from 269fb75 to fd066d0 Compare November 11, 2026 07:25
	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 bitflicker64 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 $CONF as a substring, so starting a Store with -c /etc/hg/store while another runs with -c /etc/hg/store-b prints already running and exits 0 without launching. Match the full -Dspring.config.location=${CONF}/application.yml argument here and at start-hugegraph-pd.sh line 259. (#3253 (comment))

Comment thread docs/server-runtime.md Resolved
…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
@AvanishShukla20
AvanishShukla20 force-pushed the conf+logs+plugins+pidOverride branch from d3e2829 to 36dbdf6 Compare November 12, 2026 17:56

@bitflicker64 bitflicker64 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread .github/workflows/pd-store-ci.yml Resolved
Comment thread docs/server-runtime.md Resolved
- 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 bitflicker64 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
@AvanishShukla20
AvanishShukla20 force-pushed the conf+logs+plugins+pidOverride branch from f627f3e to c85bc9a Compare November 22, 2026 14:21
@AvanishShukla20

Copy link
Copy Markdown
Author

@imbajin the latest head (c85bc9a) addresses all the previous review feedbacks and CI checks have also passed on it.Can we please proceed with further steps. Thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Support overriding conf and logs directories in upstream startup scripts

3 participants