Skip to content

Commit

Permalink
Add Patroni updates for static_primary support
Browse files Browse the repository at this point in the history
Use build arg to optionally include Patroni changes. Added a new release
matrix element to stamp-out a release image with the Patroni changes
enabled, bearing a tag suffix `-patroni-static-primary`
  • Loading branch information
thedodd committed Apr 29, 2022
1 parent 48a738a commit cca9ce0
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build_image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ env:
TIMESCALE_TSDB_ADMIN: "1.0.0"
TIMESCALEDB_TOOLKIT_REPO: github.com/timescale/timescaledb-toolkit
TIMESCALEDB_TOOLKIT_EXTENSIONS: forge-stable-1.3.1 1.5.1-cloud 1.6.0
TIMESCALE_STATIC_PRIMARY: "true"
jobs:
build-image:
name: Build the default Docker Image
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/publish_image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ env:
TIMESCALE_TSDB_ADMIN: "1.0.0"
TIMESCALEDB_TOOLKIT_REPO: github.com/timescale/timescaledb-toolkit
TIMESCALEDB_TOOLKIT_EXTENSIONS: forge-stable-1.3.1 1.5.1-cloud 1.6.0
TIMESCALE_STATIC_PRIMARY: ''
jobs:
publish-image:
name: Publish the Docker Images
Expand All @@ -23,6 +24,11 @@ jobs:
# This is the 'default' image, it contains PostgreSQL 14 13 and 12, and defaults to PostgreSQL 14 binaries
- pg_major: "14"
pg_versions: "14 13 12"
# This is the 'default' image, along with Patroni changes to support static primaries
- pg_major: "14"
pg_versions: "14 13 12"
patroni_static_primary: "true"
docker_tag_postfix: "-patroni-static-primary"
# This is the PostgreSQL 14 image containing only oss software
- pg_major: "14"
pg_versions: "14 13 12"
Expand Down Expand Up @@ -75,6 +81,7 @@ jobs:
DOCKER_ECR_URL: ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.us-east-1.amazonaws.com/timescaledb-ha
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
TIMESCALE_STATIC_PRIMARY: ${{ matrix.patroni_static_primary }}
# Note that our ECR registry has immutability guarantees, therefore we do not push
# the mutable ('latest') tags to the ECR registry
run: |
Expand Down
12 changes: 10 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,15 @@ RUN for postgisv in ${POSTGIS_VERSIONS}; do \
# This need to be done after the PostgreSQL packages have been installed,
# to ensure we have the preferred libpq installations etc.
RUN apt-get install -y python3-etcd python3-requests python3-pystache python3-kubernetes python3-pysyncobj
RUN apt-get install -y patroni
RUN apt-get install -y patroni=2.1.3-\*
# Patch Patroni code with changes from https://github.com/timescale/patroni/pull/1
# NOTE: This is a temporary solution until changes land upstream.
ARG TIMESCALE_STATIC_PRIMARY
RUN if [ "${TIMESCALE_STATIC_PRIMARY}" != "" ]; then \
wget -qO- https://raw.githubusercontent.com/timescale/patroni/v2.2.0-beta.2/patroni/ha.py > /usr/lib/python3/dist-packages/patroni/ha.py && \
wget -qO- https://raw.githubusercontent.com/timescale/patroni/v2.2.0-beta.2/patroni/config.py > /usr/lib/python3/dist-packages/patroni/config.py && \
wget -qO- https://raw.githubusercontent.com/timescale/patroni/v2.2.0-beta.2/patroni/validator.py > /usr/lib/python3/dist-packages/patroni/validator.py; \
fi

RUN for file in $(find /usr/share/postgresql -name 'postgresql.conf.sample'); do \
# We want timescaledb to be loaded in this image by every created cluster
Expand Down Expand Up @@ -268,7 +276,7 @@ RUN --mount=type=secret,uid=1000,id=AWS_ACCESS_KEY_ID --mount=type=secret,uid=10
[ -f "/run/secrets/AWS_ACCESS_KEY_ID" ] && export AWS_ACCESS_KEY_ID="$(cat /run/secrets/AWS_ACCESS_KEY_ID)" ; \
[ -f "/run/secrets/AWS_SECRET_ACCESS_KEY" ] && export AWS_SECRET_ACCESS_KEY="$(cat /run/secrets/AWS_SECRET_ACCESS_KEY)" ; \
set -e \
&& git clone https://${TIMESCALE_PROMSCALE_REPO} /build/promscale_extension \
&& git clone https://${TIMESCALE_PROMSCALE_REPO} /build/promscale_extension \
&& cd /build/promscale_extension \
&& for pg in ${PG_VERSIONS}; do \
/build/scripts/install_promscale.sh ${pg} ${TIMESCALE_PROMSCALE_EXTENSIONS} || exit 1 ; \
Expand Down
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ TIMESCALE_TSDB_ADMIN?=
TIMESCALE_HOT_FORGE?=
TIMESCALE_OOM_GUARD?=
TIMESCALE_CLOUDUTILS?=
TIMESCALE_STATIC_PRIMARY?=

DOCKER_EXTRA_BUILDARGS?=
DOCKER_REGISTRY?=localhost:5000
Expand Down Expand Up @@ -81,6 +82,7 @@ DOCKER_BUILD_COMMAND=docker build --progress=plain \
--build-arg TIMESCALE_TSDB_ADMIN="$(TIMESCALE_TSDB_ADMIN)" \
--build-arg TIMESCALEDB_TOOLKIT_EXTENSIONS="$(TIMESCALEDB_TOOLKIT_EXTENSIONS)" \
--build-arg TIMESCALEDB_TOOLKIT_REPO="$(TIMESCALEDB_TOOLKIT_REPO)" \
--build-arg TIMESCALE_STATIC_PRIMARY="$(TIMESCALE_STATIC_PRIMARY)" \
--cache-from "$(DOCKER_CACHE_FROM)" \
--label com.timescaledb.image.install_method=$(INSTALL_METHOD) \
--label org.opencontainers.image.created="$$(date -Iseconds --utc)" \
Expand Down

0 comments on commit cca9ce0

Please sign in to comment.