Skip to content

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

Merged
tuhaihe merged 2 commits into
apache:mainfrom
MisterRaindrop:fix/gpdemo-absolute-trusted-shell
Oct 28, 2026
Merged

tuhaihe merged 2 commits 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

@leborchuk leborchuk 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.

LGTM

Comment thread gpAux/gpdemo/demo_cluster.sh Resolved
Comment thread gpAux/gpdemo/demo_cluster.sh Resolved

@Alena0704 Alena0704 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

tuhaihe and others added 2 commits October 28, 2026 17:51
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.
Co-authored-by: Alena Rybakina <58230554+Alena0704@users.noreply.github.com>
@tuhaihe
tuhaihe force-pushed the fix/gpdemo-absolute-trusted-shell branch from 5b15fc6 to 7fc39e5 Compare October 28, 2026 09:51
@tuhaihe
tuhaihe enabled auto-merge (squash) October 28, 2026 09:54
@tuhaihe
tuhaihe merged commit 6841b19 into apache:main Oct 28, 2026
140 checks passed
@tuhaihe tuhaihe added this to the Behave tests milestone Oct 29, 2026
MisterRaindrop added a commit to MisterRaindrop/cloudberry that referenced this pull request Oct 29, 2026
cluster config held a relative TRUSTED_SHELL, so gpinitsystem could not
find lalshell from the directory the scenarios run in. apache#2177 made it
absolute, so remove those tags.

Two of them, the banner scenarios, are tagged @backup_restore_bashrc
because they append to ~/.bashrc. before_scenario() returns early for
the gpinitsystem feature before it backs ~/.bashrc up, while
after_scenario() still restores it, and with no backup to restore it
deletes ~/.bashrc. Back it up before that early return. Alena Rybakina
found this in review.

The mirror port scenario also waits for the gpinitsystem fixes in apache#2178
and keeps its tag until that is merged.
MisterRaindrop added a commit to MisterRaindrop/cloudberry that referenced this pull request Oct 29, 2026
cluster config held a relative TRUSTED_SHELL, so gpinitsystem could not
find lalshell from the directory the scenarios run in. apache#2177 made it
absolute, so remove those tags.

Two of them, the banner scenarios, are tagged @backup_restore_bashrc
because they append to ~/.bashrc. before_scenario() returns early for
the gpinitsystem feature before it backs ~/.bashrc up, while
after_scenario() still restores it, and with no backup to restore it
deletes ~/.bashrc. Back it up before that early return. Alena Rybakina
found this in review.

The mirror port scenario also waits for the gpinitsystem fixes in apache#2178
and keeps its tag until that is merged.
MisterRaindrop added a commit to MisterRaindrop/cloudberry that referenced this pull request Oct 30, 2026
cluster config held a relative TRUSTED_SHELL, so gpinitsystem could not
find lalshell from the directory the scenarios run in. apache#2177 made it
absolute, so remove those tags.

Two of them, the banner scenarios, are tagged @backup_restore_bashrc
because they append to ~/.bashrc. before_scenario() returns early for
the gpinitsystem feature before it backs ~/.bashrc up, while
after_scenario() still restores it, and with no backup to restore it
deletes ~/.bashrc. Back it up before that early return. Alena Rybakina
found this in review.

The mirror port scenario also waits for the gpinitsystem fixes in apache#2178
and keeps its tag until that is merged.
tuhaihe pushed a commit to MisterRaindrop/cloudberry that referenced this pull request Oct 31, 2026
cluster config held a relative TRUSTED_SHELL, so gpinitsystem could not
find lalshell from the directory the scenarios run in. apache#2177 made it
absolute, so remove those tags.

Two of them, the banner scenarios, are tagged @backup_restore_bashrc
because they append to ~/.bashrc. before_scenario() returns early for
the gpinitsystem feature before it backs ~/.bashrc up, while
after_scenario() still restores it, and with no backup to restore it
deletes ~/.bashrc. Back it up before that early return. Alena Rybakina
found this in review.

The mirror port scenario also waits for the gpinitsystem fixes in apache#2178
and keeps its tag until that is merged.
tuhaihe pushed a commit that referenced this pull request Nov 1, 2026
cluster config held a relative TRUSTED_SHELL, so gpinitsystem could not
find lalshell from the directory the scenarios run in. #2177 made it
absolute, so remove those tags.

Two of them, the banner scenarios, are tagged @backup_restore_bashrc
because they append to ~/.bashrc. before_scenario() returns early for
the gpinitsystem feature before it backs ~/.bashrc up, while
after_scenario() still restores it, and with no backup to restore it
deletes ~/.bashrc. Back it up before that early return. Alena Rybakina
found this in review.

The mirror port scenario also waits for the gpinitsystem fixes in #2178
and keeps its tag until that is merged.
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.

4 participants