Skip to content

Commit

Permalink
chore: avoid blocking base image update (#200)
Browse files Browse the repository at this point in the history
If there's a package discrepancy we were avoiding updating the base
image. Now we update even if there's a discrepancy.

Signed-off-by: Jonathan Gonzalez V. <[email protected]>
Signed-off-by: Niccolò Fei <[email protected]>
Co-authored-by: Niccolò Fei <[email protected]>
  • Loading branch information
sxd and NiccoloFei authored Nov 27, 2024
1 parent e9421d8 commit b0c4285
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 24 deletions.
2 changes: 1 addition & 1 deletion UBI/Dockerfile-postgis-multiarch.template
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ RUN --mount=type=secret,id=subscription,target=/run/secrets/subscription.sh \
exit 1 ;; \
esac ; \
yum -y install --setopt=install_weak_deps=0 \
--enablerepo=ubi-%%UBI_MAJOR_VERSION%%-codeready-builder,codeready-builder-for-rhel-%%UBI_MAJOR_VERSION%%-${BUILDARCH}-rpms \
--enablerepo=codeready-builder-for-rhel-%%UBI_MAJOR_VERSION%%-${BUILDARCH}-rpms \
postgis%%POSTGIS_MAJOR%%_%%PG_MAJOR%%-%%POSTGIS_VERSION%% \
"$pgrouting_pkg" \
; \
Expand Down
2 changes: 1 addition & 1 deletion UBI/Dockerfile-postgis-multilang.template
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ RUN --mount=type=secret,id=subscription,target=/run/secrets/subscription.sh \
exit 1 ;; \
esac ; \
yum -y install --setopt=install_weak_deps=0 \
--enablerepo=ubi-%%UBI_MAJOR_VERSION%%-codeready-builder,codeready-builder-for-rhel-%%UBI_MAJOR_VERSION%%-${BUILDARCH}-rpms \
--enablerepo=codeready-builder-for-rhel-%%UBI_MAJOR_VERSION%%-${BUILDARCH}-rpms \
postgis%%POSTGIS_MAJOR%%_%%PG_MAJOR%%-%%POSTGIS_VERSION%% \
pgrouting_%%PG_MAJOR%% \
; \
Expand Down
2 changes: 1 addition & 1 deletion UBI/Dockerfile-postgis.template
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ RUN --mount=type=secret,id=subscription,target=/run/secrets/subscription.sh \
exit 1 ;; \
esac ; \
yum -y install --setopt=install_weak_deps=0 \
--enablerepo=ubi-%%UBI_MAJOR_VERSION%%-codeready-builder,codeready-builder-for-rhel-%%UBI_MAJOR_VERSION%%-${BUILDARCH}-rpms \
--enablerepo=codeready-builder-for-rhel-%%UBI_MAJOR_VERSION%%-${BUILDARCH}-rpms \
postgis%%POSTGIS_MAJOR%%_%%PG_MAJOR%%-%%POSTGIS_VERSION%% \
pgrouting_%%PG_MAJOR%% \
; \
Expand Down
46 changes: 25 additions & 21 deletions UBI/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -222,20 +222,28 @@ generate_redhat() {
exit 1
fi

if [ -f "${versionFile}" ]; then
oldUbiVersion=$(jq -r '.UBI_VERSION' "${versionFile}")
oldPostgresqlVersion=$(jq -r '.POSTGRES_VERSION' "${versionFile}")
oldBarmanVersion=$(jq -r '.BARMAN_VERSION' "${versionFile}")
oldImageReleaseVersion=$(jq -r '.IMAGE_RELEASE_VERSION' "${versionFile}")
imageReleaseVersion=$oldImageReleaseVersion
fi

pg_x86_64=$(get_postgresql_version "${ubiRelease}" 'x86_64' "$version")
pg_ppc64le=$(get_postgresql_version "${ubiRelease}" 'ppc64le' "$version")
pg_s390x=$(get_postgresql_version "${ubiRelease}" 's390x' "$version")
pg_arm64=$(get_postgresql_version "${ubiRelease}" 'aarch64' "$version")
postgresqlVersion="${pg_x86_64}"
if ! compare_architecture_pkgs "$pg_x86_64" "$pg_arm64" "$pg_ppc64le" "$pg_s390x"; then
echo "Version discrepancy between the architectures of PostgreSQL $version packages in UBI$ubiRelease." >&2
echo "x86_64: $pg_x86_64" >&2
echo "arm64: $pg_arm64" >&2
echo "ppc64le: $pg_ppc64le" >&2
echo "s390x: $pg_s390x" >&2
return
postgresqlVersion="${oldPostgresqlVersion}"
fi

postgresqlVersion="${pg_x86_64}"
if [ -z "$postgresqlVersion" ]; then
echo "Unable to retrieve latest PostgreSQL $version version for UBI$ubiRelease"
return
Expand All @@ -262,13 +270,7 @@ generate_redhat() {
# Output the full Postgresql package name
echo "$version: ${postgresqlVersion} (UBI${ubiRelease})"

if [ -f "${versionFile}" ]; then
oldUbiVersion=$(jq -r '.UBI_VERSION' "${versionFile}")
oldPostgresqlVersion=$(jq -r '.POSTGRES_VERSION' "${versionFile}")
oldBarmanVersion=$(jq -r '.BARMAN_VERSION' "${versionFile}")
oldImageReleaseVersion=$(jq -r '.IMAGE_RELEASE_VERSION' "${versionFile}")
imageReleaseVersion=$oldImageReleaseVersion
else
if [ ! -f "${versionFile}" ]; then
imageReleaseVersion=1

echo "{}" > "${versionFile}"
Expand Down Expand Up @@ -384,20 +386,29 @@ generate_redhat_postgis() {
exit 1
fi

if [ -f "${versionFile}" ]; then
oldUbiVersion=$(jq -r '.UBI_VERSION' "${versionFile}")
oldPostgresqlVersion=$(jq -r '.POSTGRES_VERSION' "${versionFile}")
oldPostgisVersion=$(jq -r '.POSTGIS_VERSION' "${versionFile}")
oldBarmanVersion=$(jq -r '.BARMAN_VERSION' "${versionFile}")
oldImageReleaseVersion=$(jq -r '.IMAGE_RELEASE_VERSION' "${versionFile}")
imageReleaseVersion=$oldImageReleaseVersion
fi

pg_x86_64=$(get_postgresql_version "${ubiRelease}" 'x86_64' "$version")
pg_ppc64le=$(get_postgresql_version "${ubiRelease}" 'ppc64le' "$version")
pg_s390x=$(get_postgresql_version "${ubiRelease}" 's390x' "$version")
pg_arm64=$(get_postgresql_version "${ubiRelease}" 'aarch64' "$version")
postgresqlVersion="${pg_x86_64}"
if ! compare_architecture_pkgs "$pg_x86_64" "$pg_arm64" "$pg_ppc64le" "$pg_s390x"; then
echo "Version discrepancy between the architectures of PostgreSQL $version packages in UBI$ubiRelease." >&2
echo "x86_64: $pg_x86_64" >&2
echo "arm64: $pg_arm64" >&2
echo "ppc64le: $pg_ppc64le" >&2
echo "s390x: $pg_s390x" >&2
return
postgresqlVersion="${oldPostgresqlVersion}"
fi

postgresqlVersion="${pg_x86_64}"
if [ -z "$postgresqlVersion" ]; then
echo "Unable to retrieve latest PostgreSQL $version version for UBI$ubiRelease"
return
Expand All @@ -419,16 +430,16 @@ generate_redhat_postgis() {
postgis_ppc64le=$(get_postgis_version "${ubiRelease}" 'ppc64le' "$version")
postgis_s390x=$(get_postgis_version "${ubiRelease}" 's390x' "$version")
postgis_arm64=$(get_postgis_version "${ubiRelease}" 'aarch64' "$version")
postgisVersion="${postgis_x86_64}"
if ! compare_architecture_pkgs "$postgis_x86_64" "$postgis_arm64" "$postgis_ppc64le" "$postgis_s390x"; then
echo "Version discrepancy between the architectures of PostGIS $version packages in UBI$ubiRelease." >&2
echo "x86_64: $postgis_x86_64" >&2
echo "arm64: $postgis_arm64" >&2
echo "ppc64le: $postgis_ppc64le" >&2
echo "s390x: $postgis_s390x" >&2
return
postgisVersion="${oldPostgisVersion}"
fi

postgisVersion="${postgis_x86_64}"
if [ -z "$postgisVersion" ]; then
echo "Unable to get the PostGIS version"
exit 1
Expand All @@ -446,14 +457,7 @@ generate_redhat_postgis() {
# Output the full Postgresql and PostGIS package name
echo "$version: ${postgresqlVersion} - PostGIS ${postgisVersion} (UBI${ubiRelease})"

if [ -f "${versionFile}" ]; then
oldUbiVersion=$(jq -r '.UBI_VERSION' "${versionFile}")
oldPostgresqlVersion=$(jq -r '.POSTGRES_VERSION' "${versionFile}")
oldPostgisVersion=$(jq -r '.POSTGIS_VERSION' "${versionFile}")
oldBarmanVersion=$(jq -r '.BARMAN_VERSION' "${versionFile}")
oldImageReleaseVersion=$(jq -r '.IMAGE_RELEASE_VERSION' "${versionFile}")
imageReleaseVersion=$oldImageReleaseVersion
else
if [ ! -f "${versionFile}" ]; then
imageReleaseVersion=1

echo "{}" > "${versionFile}"
Expand Down

0 comments on commit b0c4285

Please sign in to comment.