Skip to content

Commit 64d1b4e

Browse files
kkimuraksachilles
authored andcommitted
Check if server side DB version met requirement
1 parent 61c7912 commit 64d1b4e

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ ENV GITLAB_VERSION=${VERSION} \
1616
GITLAB_CACHE_DIR="/etc/docker-gitlab" \
1717
RAILS_ENV=production \
1818
NODE_ENV=production \
19-
NO_SOURCEMAPS=true
19+
NO_SOURCEMAPS=true \
20+
# v18.5.2 : minimum = 16.5, maximum = 17.x (currently 17.6, is 170006)
21+
POSTGRESQL_SERVER_REQUIRED_VERSION_MINIMUM=160005 \
22+
POSTGRESQL_SERVER_REQUIRED_VERSION_MAXIMUM=170100
2023

2124
ENV GITLAB_INSTALL_DIR="${GITLAB_HOME}/gitlab" \
2225
GITLAB_SHELL_INSTALL_DIR="${GITLAB_HOME}/gitlab-shell" \

assets/runtime/functions

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,23 @@ gitlab_generate_postgresqlrc() {
190190

191191
echo "- Detected server version: ${DB_SERVER_VERSION}"
192192

193+
# remove leading zero (prior to 10.x it was like "090605" so that cannot treated as number)
194+
DB_SERVER_VERSION="${DB_SERVER_VERSION##+(0)}"
195+
193196
# Anyway, we can get major version (8, 9, 10 and so on) by dividing by 10000.
194197
# DB_SERVER_VERSION_MAJOR=${DB_SERVER_VERSION%%.*}
195198
DB_SERVER_VERSION_MAJOR=$((DB_SERVER_VERSION/10000))
196199
DB_CLIENT_VERSION_PACKAGE_NAME=
197200

201+
# Check version requirement
202+
if [[ "${DB_SERVER_VERSION}" -lt "${POSTGRESQL_SERVER_REQUIRED_VERSION_MINIMUM}"
203+
|| "${DB_SERVER_VERSION}" -gt "${POSTGRESQL_SERVER_REQUIRED_VERSION_MAXIMUM}"
204+
]]; then
205+
echo " Version requirement mismatch! (${POSTGRESQL_SERVER_REQUIRED_VERSION_MINIMUM} < ${DB_SERVER_VERSION} < ${POSTGRESQL_SERVER_REQUIRED_VERSION_MAXIMUM})"
206+
echo " Aborting.."
207+
return 1
208+
fi
209+
198210
if [[ "${DB_SERVER_VERSION_MAJOR}" -ge 10 ]]; then
199211
# v10 or later: use "rough major version" as version number in package name
200212
DB_CLIENT_VERSION_PACKAGE_NAME=${DB_SERVER_VERSION_MAJOR}

0 commit comments

Comments
 (0)