Remove cdc and wal2json and use the default postgres entrypoint (#3260)

* Remove cdc and wal2json and use the default postgres entrypoint

* Remove the last bits of wal2json install

* Remove read-only postgres volume bind
This commit is contained in:
Michal Kuffa 2024-08-12 18:12:37 +02:00 committed by GitHub
parent 053f4010b6
commit 534a874c0b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 0 additions and 118 deletions

1
.env
View File

@ -11,7 +11,6 @@ SNUBA_IMAGE=getsentry/snuba:nightly
RELAY_IMAGE=getsentry/relay:nightly
SYMBOLICATOR_IMAGE=getsentry/symbolicator:nightly
VROOM_IMAGE=getsentry/vroom:nightly
WAL2JSON_VERSION=latest
HEALTHCHECK_INTERVAL=30s
HEALTHCHECK_TIMEOUT=1m30s
HEALTHCHECK_RETRIES=10

3
.gitignore vendored
View File

@ -98,9 +98,6 @@ geoip/GeoIP.conf
geoip/*.mmdb
geoip/.geoipupdate.lock
# wal2json download
postgres/wal2json
# integration testing
_integration-test/custom-ca-roots/nginx/*
sentry/test-custom-ca-roots.py

View File

@ -126,23 +126,12 @@ services:
[
"postgres",
"-c",
"wal_level=logical",
"-c",
"max_replication_slots=1",
"-c",
"max_wal_senders=1",
"-c",
"max_connections=${POSTGRES_MAX_CONNECTIONS:-100}",
]
environment:
POSTGRES_HOST_AUTH_METHOD: "trust"
entrypoint: /opt/sentry/postgres-entrypoint.sh
volumes:
- "sentry-postgres:/var/lib/postgresql/data"
- type: bind
read_only: true
source: ./postgres/
target: /opt/sentry/
zookeeper:
<<: *restart_policy
image: "confluentinc/cp-zookeeper:7.6.1"

View File

@ -32,7 +32,6 @@ source install/ensure-relay-credentials.sh
source install/generate-secret-key.sh
source install/update-docker-images.sh
source install/build-docker-images.sh
source install/install-wal2json.sh
source install/bootstrap-snuba.sh
source install/upgrade-postgres.sh
source install/set-up-and-migrate-database.sh

View File

@ -1,45 +0,0 @@
echo "${_group}Downloading and installing wal2json ..."
WAL2JSON_DIR=postgres/wal2json
FILE_TO_USE="$WAL2JSON_DIR/wal2json.so"
ARCH=$(uname -m)
FILE_NAME="wal2json-Linux-$ARCH-glibc.so"
docker_curl() {
# The environment variables can be specified in lower case or upper case.
# The lower case version has precedence. http_proxy is an exception as it is only available in lower case.
docker run --rm -e http_proxy -e https_proxy -e HTTPS_PROXY -e no_proxy -e NO_PROXY curlimages/curl:7.77.0 \
--connect-timeout 5 \
--max-time 10 \
--retry 5 \
--retry-max-time 60 \
"$@"
}
if [[ $WAL2JSON_VERSION == "latest" ]]; then
# Hard-code this. Super-hacky. We were curling the GitHub API here but
# hitting rate limits in CI. This library hasn't seen a new release for a
# year and a half at time of writing.
#
# If you're reading this do us a favor and go check:
#
# https://github.com/getsentry/wal2json/releases
#
# If there's a new release can you update this please? If not maybe subscribe
# for notifications on the repo with "Watch > Custom > Releases". Together we
# can make a difference.
VERSION=0.0.2
else
VERSION=$WAL2JSON_VERSION
fi
mkdir -p "$WAL2JSON_DIR"
if [ ! -f "$WAL2JSON_DIR/$VERSION/$FILE_NAME" ]; then
mkdir -p "$WAL2JSON_DIR/$VERSION"
docker_curl -L \
"https://github.com/getsentry/wal2json/releases/download/$VERSION/$FILE_NAME" \
>"$WAL2JSON_DIR/$VERSION/$FILE_NAME"
fi
cp "$WAL2JSON_DIR/$VERSION/$FILE_NAME" "$FILE_TO_USE"
echo "${_endgroup}"

View File

@ -1,7 +0,0 @@
#!/bin/bash
# Initializes the pg_hba file with access permissions to the replication
# slots.
set -e
{ echo "host replication all all trust"; } >>"$PGDATA/pg_hba.conf"

View File

@ -1,46 +0,0 @@
#!/bin/bash
# This script replaces the default docker entrypoint for postgres in the
# development environment.
# Its job is to ensure postgres is properly configured to support the
# Change Data Capture pipeline (by setting access permissions and installing
# the replication plugin we use for CDC). Unfortunately the default
# Postgres image does not allow this level of configurability so we need
# to do it this way in order not to have to publish and maintain our own
# Postgres image.
#
# This then, at the end, transfers control to the default entrypoint.
set -e
prep_init_db() {
cp /opt/sentry/init_hba.sh /docker-entrypoint-initdb.d/init_hba.sh
}
cdc_setup_hba_conf() {
# Ensure pg-hba is properly configured to allow connections
# to the replication slots.
PG_HBA="$PGDATA/pg_hba.conf"
if [ ! -f "$PG_HBA" ]; then
echo "DB not initialized. Postgres will take care of pg_hba"
elif [ "$(grep -c -E "^host\s+replication" "$PGDATA"/pg_hba.conf)" != 0 ]; then
echo "Replication config already present in pg_hba. Not changing anything."
else
# Execute the same script we run on DB initialization
/opt/sentry/init_hba.sh
fi
}
bind_wal2json() {
# Copy the file in the right place
cp /opt/sentry/wal2json/wal2json.so $(pg_config --pkglibdir)/wal2json.so
}
echo "Setting up Change Data Capture"
prep_init_db
if [ "$1" = 'postgres' ]; then
cdc_setup_hba_conf
bind_wal2json
fi
exec /usr/local/bin/docker-entrypoint.sh "$@"

View File

@ -4,11 +4,7 @@ set -eu
OLD_VERSION="$1"
NEW_VERSION="$2"
WAL2JSON_VERSION=${WAL2JSON_VERSION:-$(curl -s "https://api.github.com/repos/getsentry/wal2json/releases/latest" | grep -Po '"tag_name": "\K.*?(?=")')}
sed -i -e "s/^WAL2JSON_VERSION=\([^:]\+\):.\+\$/WAL2JSON_VERSION=\1:$WAL2JSON_VERSION/" .env
sed -i -e "s/^\(SENTRY\|SNUBA\|RELAY\|SYMBOLICATOR\|VROOM\)_IMAGE=\([^:]\+\):.\+\$/\1_IMAGE=\2:$NEW_VERSION/" .env
sed -i -e "s/^\# Self-Hosted Sentry .*/# Self-Hosted Sentry $NEW_VERSION/" README.md
echo "New version: $NEW_VERSION"
echo "New wal2json version: $WAL2JSON_VERSION"