Skip to content

gpdemo: write an absolute TRUSTED_SHELL into the generated config - #2177

Open
MisterRaindrop wants to merge 1 commit into
apache:mainfrom
MisterRaindrop:fix/gpdemo-absolute-trusted-shell
Open

MisterRaindrop wants to merge 1 commit into
apache:mainfrom
MisterRaindrop:fix/gpdemo-absolute-trusted-shell

Conversation

@MisterRaindrop

@MisterRaindrop MisterRaindrop commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

demo_cluster.sh writes the cluster config through an unquoted here-doc, so

TRUSTED_SHELL="$(dirname "$0")/lalshell"

is expanded when the file is written, not when it is sourced. gpAux/gpdemo's Makefile and the Behave suite both run the script as ./demo_cluster.sh, so $0 is relative, dirname gives ., and the generated config says

TRUSTED_SHELL="./lalshell"

gpinitsystem sources that file from wherever it is running and looks for lalshell in that directory. That never mattered while only demo_cluster.sh itself ran gpinitsystem from gpAux/gpdemo, but the Behave suite runs gpinitsystem -c ../gpAux/gpdemo/clusterConfigFile from gpMgmt, which fails with

gp_bash_functions.sh: line 270: ./lalshell: No such file or directory

The script now writes the absolute path of the directory it lives in, still quoted so a path containing whitespace survives being sourced.

Split out of #1639 (originally 767f126, by @tuhaihe).

Test Plan

Rocky 9 build image, built from #2170's tree (the Behave CI workflow), demo cluster created the way CI creates it, then behave --tags ~@needs_fix test/behave/mgmt_utils/gpinitsystem.feature with #2170's feature file from before it tagged the scenarios below:

main this PR
TRUSTED_SHELL in the generated config "./lalshell" "/home/gpadmin/cloudberry/gpAux/gpdemo/lalshell"
./lalshell: No such file or directory in the run 25 0
scenarios passed / failed (16 run) 4 / 12 15 / 1

With this change, these scenarios go from failing to passing: the three locale scenarios (gpinitsystem.feature lines 302, 312, 320 in #2170), the two banner scenarios (335, 342), -D (355), the default trusted_shell (362), and the three @extended backout-file scenarios (84, 99, 113). The @extended ones are excluded in CI, but they ran here.

The one that still fails, "should create consistent port entry on segments postgresql.conf file" (348), now gets past gpinitsystem and fails on the next check: a mirror's postgresql.conf still has its primary's port (expected 15437, got 15434). That is a separate gpinitsystem defect, fixed by b971d48 in #1639, which will come as its own PR. The changed-trusted_shell scenario (369) sets TRUSTED_SHELL=ssh and does not use lalshell. It passes in CI and passed with this change here. In the main run here it failed because gpcreateseg.sh exited on an INT/TERM signal, after the scenarios before it had failed; I have not looked further into that.

#2170 tags these scenarios @needs_fix and points them at this change. Whichever of the two PRs lands second removes the tags; 348 keeps its tag until b971d48 lands.

Type of Change

  • Bug fix (non-breaking change)

Checklist

  • This PR contains AI-assisted code generation

demo_cluster.sh writes the cluster config through an unquoted here-doc,
so

    TRUSTED_SHELL="$(dirname "$0")/lalshell"

is expanded as the file is written, not as it is sourced. gpAux/gpdemo's
Makefile invokes the script as ./demo_cluster.sh, which makes $0
relative and dirname "." -- so the generated config carries

    TRUSTED_SHELL="./lalshell"

gpinitsystem sources that file from wherever it happens to be running
and looks for lalshell in that directory instead.

Nothing noticed while the demo cluster was only ever created by
demo_cluster.sh itself, from the directory lalshell sits in, but the
Behave suite runs

    gpinitsystem -a -c ../gpAux/gpdemo/clusterConfigFile

directly in a dozen scenarios. Resolve the directory the script itself
lives in and write that, and keep the quotes so a path containing
whitespace survives being sourced.
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.

2 participants