Skip to content

Commit 4ac7832

Browse files
authored
fix(pgadmin): switch standalone pgAdmin to python3.12 site-packages path (#4500)
* fix(pgadmin): switch standalone pgAdmin to python3.12 site-packages path The new internal-registry pgAdmin image (registry.internal.crunchydata.com/gitlab/crunchy-pgadmin4-ubi9@sha256: b10575053e71e820ae15747f5e11e543296f0dafeb5513bbf44a8053b5cd7c1a) ships pgadmin4 under /usr/local/lib/python3.12/site-packages/pgadmin4. The previous developers.crunchydata.com image was on python3.11, so the operator hard-codes that path. The startup script generated by the operator does `cd "$PGADMIN_DIR"`, which fails on the new image with: cd: /usr/local/lib/python3.11/site-packages/pgadmin4: No such file or directory The container exits 1 immediately and the pod ends up in CrashLoopBackOff. This was caught running the standalone-pgadmin-user-management kuttl suite against the new image. * internal/controller/standalone_pgadmin/config.go: bump pgAdminDir from python3.11 -> python3.12 so the generated startup script's `cd "$PGADMIN_DIR"` succeeds. * internal/controller/standalone_pgadmin/pod_test.go: refresh both golden pod-spec fixtures to match the new path. * updated pgadmin dockerfile * resolve conflict
1 parent 9fa17c8 commit 4ac7832

3 files changed

Lines changed: 20 additions & 4 deletions

File tree

components/image-pgadmin/Dockerfile

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
ARG BASE_VERSION=ubi9
66
ARG PGADMIN4_VERSION=9.15
7-
ARG PYTHON_VERSION=3.11
7+
ARG PYTHON_VERSION=3.12
88
ARG PG_MAJOR=18
99

1010
# Some Python packages available in UBI repositories are too old for pgAdmin
@@ -115,11 +115,19 @@ RUN rpm -ivh "https://dl.fedoraproject.org/pub/epel/epel-release-latest-${BASE_V
115115
#
116116
# - https://docs.python.org/3/whatsnew/3.12.html
117117
# - https://github.com/pgadmin-org/pgadmin4/blob/REL-8_14/requirements.txt#L57
118+
#
119+
# Install "wheel" and "packaging" alongside pip/setuptools so legacy pgAdmin
120+
# transitive deps (e.g. Flask-Principal) that ship as sdists without a
121+
# pyproject.toml can build via "setup.py bdist_wheel". Without these the
122+
# wheel package's bdist_wheel shim fails on Python 3.12 with UBI's older
123+
# rpm setuptools because its fallback path imports "packaging".
118124
ARG PGADMIN4_VERSION
119125
RUN \
120126
microdnf install -y --nodocs \
127+
"python${PYTHON_VERSION}-packaging" \
121128
"python${PYTHON_VERSION}-pip" \
122129
"python${PYTHON_VERSION}-setuptools" \
130+
"python${PYTHON_VERSION}-wheel" \
123131
&& microdnf clean all \
124132
&& rm -f /etc/yum.repos.d/redhat.repo \
125133
&& "python${PYTHON_VERSION}" -m pip install --no-cache-dir \
@@ -129,6 +137,14 @@ microdnf install -y --nodocs \
129137
&& update-alternatives --install /usr/bin/python3 python3 "/usr/bin/python${PYTHON_VERSION}" 1 \
130138
&& update-alternatives --set python3 "/usr/bin/python${PYTHON_VERSION}"
131139

140+
# The operator invokes pgAdmin's setup.py CLI (add-user, update-user, load-servers,
141+
# setup-db) against the same install that gunicorn is serving. When setup.py runs
142+
# as a CLI, pgAdmin's Flask app.name ends with "-cli" and delete_adhoc_servers()
143+
# wipes servers users registered through the web UI. Gate that call so it only
144+
# runs for non-CLI invocations.
145+
RUN sed -i "s/delete_adhoc_servers()/if not app.name.endswith('-cli'): delete_adhoc_servers()/g" \
146+
/usr/local/lib/python${PYTHON_VERSION}/site-packages/pgadmin4/pgadmin/__init__.py
147+
132148
# config_local.py should be colocated with config.py
133149
COPY --chmod=0444 conf/config_local.py \
134150
/usr/local/lib/python${PYTHON_VERSION}/site-packages/pgadmin4/config_local.py

internal/controller/standalone_pgadmin/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ const (
1515
pgAdminPort = 5050
1616

1717
// Directory for pgAdmin in container
18-
pgAdminDir = "/usr/local/lib/python3.11/site-packages/pgadmin4"
18+
pgAdminDir = "/usr/local/lib/python3.12/site-packages/pgadmin4"
1919
)

internal/controller/standalone_pgadmin/pod_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ containers:
4545
- |-
4646
monitor() {
4747
export PGADMIN_SETUP_PASSWORD="$(date +%s | sha256sum | base64 | head -c 32)"
48-
PGADMIN_DIR=/usr/local/lib/python3.11/site-packages/pgadmin4
48+
PGADMIN_DIR=/usr/local/lib/python3.12/site-packages/pgadmin4
4949
APP_RELEASE=$(cd $PGADMIN_DIR && python3 -c "import config; print(config.APP_RELEASE)")
5050
5151
echo "Running pgAdmin4 Setup"
@@ -246,7 +246,7 @@ containers:
246246
- |-
247247
monitor() {
248248
export PGADMIN_SETUP_PASSWORD="$(date +%s | sha256sum | base64 | head -c 32)"
249-
PGADMIN_DIR=/usr/local/lib/python3.11/site-packages/pgadmin4
249+
PGADMIN_DIR=/usr/local/lib/python3.12/site-packages/pgadmin4
250250
APP_RELEASE=$(cd $PGADMIN_DIR && python3 -c "import config; print(config.APP_RELEASE)")
251251
252252
echo "Running pgAdmin4 Setup"

0 commit comments

Comments
 (0)