Skip to content

Commit 062bb81

Browse files
committed
fixes for spilo and exporter
1 parent 9f3d092 commit 062bb81

File tree

6 files changed

+43
-21
lines changed

6 files changed

+43
-21
lines changed

Makefile

-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ pgbackrest-build:
7171
pgbackrest: pgbackrest-build;
7272

7373
postgres-build:
74-
7574
docker build $(ROOTPATH) \
7675
--file $(ROOTPATH)/docker/postgres/Dockerfile \
7776
--tag cybertec-pg-container/postgres:$(IMAGE_TAG) \

docker/postgres-gis/Dockerfile

+10-2
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ RUN ${PACKAGER} -y update && ${PACKAGER} -y install --nodocs --noplugins --setop
5757
dumb-init \
5858
libicu \
5959
pgbackrest-${PGBACKREST_VERSION} \
60+
cronie \
6061
&& ${PACKAGER} -y clean all;
6162

6263
# install etcdctl
@@ -65,6 +66,7 @@ RUN curl -L https://github.com/coreos/etcd/releases/download/v${ETCD_VERSION}/et
6566
ENV PATHBACKUP = $PATH
6667

6768
RUN wget https://smarden.org/runit/runit-2.1.2.tar.gz -P /package/
69+
COPY cron_unprivileged.c /package/
6870

6971
# Install pam_oauth2.so
7072
#RUN #git clone -b $PAM_OAUTH2 --recurse-submodules https://github.com/zalando-pg/pam-oauth2.git \
@@ -73,7 +75,12 @@ RUN wget https://smarden.org/runit/runit-2.1.2.tar.gz -P /package/
7375
#&& curl -sL https://github.com/zalando-pg/pg_auth_mon/archive/$PG_AUTH_MON_COMMIT.tar.gz | tar xz \
7476

7577
RUN pip3 install 'PyYAML<6.0' setuptools pystache loader kazoo meld3 boto python-etcd psutil requests cdiff ydiff --upgrade \
76-
&& pip3 install patroni[kubernetes$EXTRAS]==$PATRONI_VERSION --upgrade \
78+
&& if [[ $PATRONI_VERSION == "multisite-"* ]]; then \
79+
git clone -b $PATRONI_VERSION https://github.com/cybertec-postgresql/patroni; \
80+
pip3 install ./patroni[kubernetes,etcd,etcd3]; \
81+
else \
82+
pip3 install patroni[kubernetes$EXTRAS]==$PATRONI_VERSION --upgrade; \
83+
fi \
7784
&& mkdir /usr/lib/postgresql \
7885
&& git clone -b $PG_PERMISSIONS https://github.com/cybertec-postgresql/pg_permissions.git \
7986
&& git clone -b $SET_USER https://github.com/pgaudit/set_user.git \
@@ -113,13 +120,14 @@ RUN pip3 install 'PyYAML<6.0' setuptools pystache loader kazoo meld3 boto python
113120
done \
114121
&& ${PACKAGER} -y install --nodocs --noplugins --setopt=install_weak_deps=0 glibc-static \
115122
&& ${PACKAGER} -y clean all;
123+
RUN gcc -s -shared -fPIC -o /usr/local/lib/cron_unprivileged.so /package/cron_unprivileged.c
116124

117125
RUN cd /package && tar -xvzf runit-2.1.2.tar.gz && rm runit-2.1.2.tar.gz \
118126
&& cd admin/runit-2.1.2 && package/install \
119127
&& ln -s /usr/local/bin/runsvdir /usr/bin/runsvdir \
120128
&& rm -rf /pg_permissions /pgextwlist /pg_stat_kcache /pgnodemx /timescaledb /set_user /pam-oauth2 \
121129
&& rm /etc/pgbackrest.conf && rm -rf /var/spool/pgbackrest \
122-
&& ${PACKAGER} -y remove python3-pip python3-wheel python3-dev python3-setuptools git patchutils flatpak glibc-static gcc glibc-devel \
130+
&& ${PACKAGER} -y remove $(rpm -qa "*devel*") python3-pip python3-wheel python3-dev python3-setuptools git patchutils flatpak glibc-static gcc glibc-devel \
123131
&& ${PACKAGER} -y autoremove \
124132
&& ${PACKAGER} -y clean dbcache \
125133
&& ${PACKAGER} -y clean all;

launcher/exporter/launch.sh

+22-9
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,31 @@
33

44
EXPORTER_DIR='/postgres_exporter'
55
QUERIE_FOLDER="$EXPORTER_DIR/queries"
6+
VERSION_SPECIFIC_FOLDER="$EXPORTER_DIR/version_specific/$PGVERSION"
67
FILES="${QUERIE_FOLDER}/*"
7-
touch /tmp/cpo_queries.yaml
8+
TEMP_QUERY_FILE='/tmp/cpo_queries.yaml'
9+
10+
> $TEMP_QUERY_FILE
11+
812
for file in $FILES
913
do
10-
if [[ -f ${file?} ]]
11-
then
12-
cat ${file?} >> /tmp/cpo_queries.yaml
13-
else
14-
echo ${FILES}
15-
echo "Query file ${file?} does not exist (it should).."
16-
exit 1
17-
fi
14+
if [[ -f "$file" ]]; then
15+
cat "$file" >> "$TEMP_QUERY_FILE"
16+
else
17+
echo "Query file $file does not exist (it should).."
18+
exit 1
19+
fi
1820
done
1921

22+
# VERSION_FILES="${VERSION_SPECIFIC_FOLDER}/*"
23+
# for version_file in $VERSION_FILES
24+
# do
25+
# if [[ -f "$version_file" ]]; then
26+
# cat "$version_file" >> "$TEMP_QUERY_FILE"
27+
# else
28+
# echo "Version-specific query file $version_file does not exist for PGVERSION $PGVERSION (it should).."
29+
# exit 1
30+
# fi
31+
# done
32+
2033
/bin/postgres_exporter --extend.query-path=/tmp/cpo_queries.yaml #--auto-discover-databases

scripts/configure_spilo.py

+5-9
Original file line numberDiff line numberDiff line change
@@ -1200,18 +1200,14 @@ def main():
12001200
if 'extwlist.extensions' not in user_config.get('postgresql', {}).get('parameters', {}):
12011201
config['postgresql']['parameters']['extwlist.extensions'] =\
12021202
append_extensions(config['postgresql']['parameters']['extwlist.extensions'], version, True)
1203-
if placeholders['cpo_monitoring_stack']:
1204-
current_libraries = config['postgresql']['parameters'].get('shared_preload_libraries', '')
1205-
1203+
12061204
# Check if cpo_monitoring is enabled
1207-
if 'pgnodemx' not in current_libraries.split(','):
1205+
if placeholders['cpo_monitoring_stack']:
12081206
current_libraries = config['postgresql']['parameters'].get('shared_preload_libraries', '')
1209-
if current_libraries and 'pgnodemx' not in current_libraries.split(','):
1210-
config['postgresql']['parameters']['shared_preload_libraries'] = current_libraries + ',' + 'pgnodemx'
1211-
else:
1207+
if not current_libraries:
12121208
config['postgresql']['parameters']['shared_preload_libraries'] = 'pgnodemx'
1213-
1214-
1209+
elif current_libraries and 'pgnodemx' not in current_libraries.split(','):
1210+
config['postgresql']['parameters']['shared_preload_libraries'] = current_libraries + ',' + 'pgnodemx'
12151211

12161212
# Ensure replication is available
12171213
if 'pg_hba' in config['bootstrap'] and not any(['replication' in i for i in config['bootstrap']['pg_hba']]):

scripts/exporter/queries/queries_pgbackrest.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
# This file adds Queries to monitor pgbackrest
2+
cpo_lastcheck_update_pgbackrest_info:
3+
query: "SELECT now() as last_check from exporter.update_pgbackrest_info();"
4+
metrics:
5+
- last_check:
6+
usage: "GAUGE"
7+
description: "last_check"
28

39
cpo_pgbackrest_time_since_backup:
410
query: "WITH backups AS (

0 commit comments

Comments
 (0)