Skip to content

Commit 550c5d8

Browse files
authored
Sync master with trigger 13-04-26 (#1196)
- Add PostgreSQL 18 and remove PostgreSQL 13: c432557 - Patroni 4.1.0 - WAL-G 3.0.8 - PostGIS 3.6: #1153 - Remove WAL-E and make WAL-G the default backup tool: #1143 - Enable pg_basebackup server compression: #1155 - Update bg_mon, pg_mon, pg_profile, pg_permissions refs - Use pgdg for set_user and pg_permissions Bugfixes - Allow admin selecting from hypopg views: #1162 - Fix logic for keeping timescaledb minor versions: #1173 - Properly setup clean env for ext build across major versions: #1174 - Properly format ipv6 address for rsync: #1187 - Ensure CLONE_HOST is IPv6 compatible: #1190
1 parent 7cb50bd commit 550c5d8

24 files changed

+424
-658
lines changed

ENVIRONMENT.rst

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ Environment Configuration Settings
1111
- **ETCD_KEY**: Etcd client certificate key. Can be empty if the key is part of certificate.
1212
- **PGHOME**: filesystem path where to put PostgreSQL home directory (/home/postgres by default)
1313
- **APIPORT**: TCP port to Patroni API connections (8008 by default)
14-
- **BACKUP_SCHEDULE**: cron schedule for doing backups via WAL-E (if WAL-E is enabled, '00 01 * * *' by default)
14+
- **BACKUP_SCHEDULE**: cron schedule for doing backups via WAL-G ('00 01 * * *' by default)
1515
- **CLONE_TARGET_TIMELINE**: timeline id of the backup for restore, 'latest' by default.
1616
- **CRONTAB**: anything that you want to run periodically as a cron job (empty by default)
1717
- **PGROOT**: a directory where we put the pgdata (by default /home/postgres/pgroot). One may adjust it to point to the mount point of the persistent volume, such as EBS.
18-
- **WALE_TMPDIR**: directory to store WAL-E temporary files. PGROOT/../tmp by default, make sure it has a few GBs of free space.
18+
- **WALE_TMPDIR** or **WALG_TMPDIR**: directory to store WAL-G temporary files. PGROOT/../tmp by default, make sure it has a few GBs of free space.
1919
- **PGDATA**: location of PostgreSQL data directory, by default PGROOT/pgdata.
2020
- **PGUSER_STANDBY**: username for the replication user, 'standby' by default.
2121
- **PGPASSWORD_STANDBY**: a password for the replication user, 'standby' by default.
@@ -47,22 +47,22 @@ Environment Configuration Settings
4747
- **SSL_RESTAPI_PRIVATE_KEY**: content of the REST Api SSL private key in the SSL_PRIVATE_KEY_FILE file (by default /run/certs/server.key).
4848
- **SSL_TEST_RELOAD**: whenever to test for certificate rotation and reloading (by default True if SSL_PRIVATE_KEY_FILE has been set).
4949
- **RESTAPI_CONNECT_ADDRESS**: when you configure Patroni RESTAPI in SSL mode some safe API (i.e. switchover) perform hostname validation. In this case could be convenient configure ````restapi.connect_address````as a hostname instead of IP. For example, you can configure it as "$(POD_NAME).<service name>".
50-
- **WALE_BACKUP_THRESHOLD_MEGABYTES**: maximum size of the WAL segments accumulated after the base backup to consider WAL-E restore instead of pg_basebackup.
51-
- **WALE_BACKUP_THRESHOLD_PERCENTAGE**: maximum ratio (in percents) of the accumulated WAL files to the base backup to consider WAL-E restore instead of pg_basebackup.
52-
- **WALE_ENV_DIR**: directory where to store WAL-E environment variables
50+
- **WALG_BACKUP_THRESHOLD_MEGABYTES** or **WALE_BACKUP_THRESHOLD_MEGABYTES**: maximum size of the WAL segments accumulated after the base backup to consider WAL-G restore instead of pg_basebackup.
51+
- **WALG_BACKUP_THRESHOLD_PERCENTAGE** or **WALE_BACKUP_THRESHOLD_PERCENTAGE**: maximum ratio (in percents) of the accumulated WAL files to the base backup to consider WAL-G restore instead of pg_basebackup.
52+
- **WALG_ENV_DIR** or **WALE_ENV_DIR**: directory where to store WAL-G environment variables
5353
- **WAL_RESTORE_TIMEOUT**: timeout (in seconds) for restoring a single WAL file (at most 16 MB) from the backup location, 0 by default. A duration of 0 disables the timeout.
54-
- **WAL_S3_BUCKET**: (optional) name of the S3 bucket used for WAL-E base backups.
54+
- **WAL_S3_BUCKET**: (optional) name of the S3 bucket used for WAL-G base backups.
5555
- **AWS_ACCESS_KEY_ID**: (optional) aws access key
5656
- **AWS_SECRET_ACCESS_KEY**: (optional) aws secret key
5757
- **AWS_REGION**: (optional) region of S3 bucket
5858
- **AWS_ENDPOINT**: (optional) in format 'https://s3.AWS_REGION.amazonaws.com:443', if not specified will be calculated from AWS_REGION
59-
- **WALE_S3_ENDPOINT**: (optional) in format 'https+path://s3.AWS_REGION.amazonaws.com:443', if not specified will be calculated from AWS_ENDPOINT or AWS_REGION
60-
- **WALE_S3_PREFIX**: (optional) the full path to the backup location on S3 in the format s3://bucket-name/very/long/path. If not specified Spilo will generate it from WAL_S3_BUCKET.
61-
- **WAL_GS_BUCKET**: ditto for the Google Cloud Storage (WAL-E supports both S3 and GCS).
62-
- **WALE_GS_PREFIX**: (optional) the full path to the backup location on the Google Cloud Storage in the format gs://bucket-name/very/long/path. If not specified Spilo will generate it from WAL_GS_BUCKET.
63-
- **GOOGLE_APPLICATION_CREDENTIALS**: credentials for WAL-E when running in Google Cloud.
59+
- **WALG_S3_ENDPOINT** or **WALE_S3_ENDPOINT**: (optional) in format 'https+path://s3.AWS_REGION.amazonaws.com:443', if not specified will be calculated from AWS_ENDPOINT or AWS_REGION
60+
- **WALG_S3_PREFIX** or **WALE_S3_PREFIX**: (optional) the full path to the backup location on S3 in the format s3://bucket-name/very/long/path. If not specified Spilo will generate it from WAL_S3_BUCKET.
61+
- **WAL_GS_BUCKET**: ditto for the Google Cloud Storage (WAL-G supports both S3 and GCS).
62+
- **WALG_GS_PREFIX** or **WALE_GS_PREFIX**: (optional) the full path to the backup location on the Google Cloud Storage in the format gs://bucket-name/very/long/path. If not specified Spilo will generate it from WAL_GS_BUCKET.
63+
- **GOOGLE_APPLICATION_CREDENTIALS**: credentials for WAL-G when running in Google Cloud.
6464
- **WAL_SWIFT_BUCKET**: ditto for the OpenStack Object Storage (Swift)
65-
- **SWIFT_AUTHURL**: see wal-e documentation https://github.com/wal-e/wal-e#swift
65+
- **SWIFT_AUTHURL**: see wal-g documentation https://wal-g.readthedocs.io/STORAGES/#swift
6666
- **SWIFT_TENANT**:
6767
- **SWIFT_TENANT_ID**:
6868
- **SWIFT_USER**:
@@ -79,7 +79,7 @@ Environment Configuration Settings
7979
- **SWIFT_PROJECT_ID**:
8080
- **SWIFT_PROJECT_DOMAIN_NAME**:
8181
- **SWIFT_PROJECT_DOMAIN_ID**:
82-
- **WALE_SWIFT_PREFIX**: (optional) the full path to the backup location on the Swift Storage in the format swift://bucket-name/very/long/path. If not specified Spilo will generate it from WAL_SWIFT_BUCKET.
82+
- **WALG_SWIFT_PREFIX** or **WALE_SWIFT_PREFIX**: (optional) the full path to the backup location on the Swift Storage in the format swift://bucket-name/very/long/path. If not specified Spilo will generate it from WAL_SWIFT_BUCKET.
8383
- **SSH_USERNAME**: (optional) the username for WAL backups.
8484
- **SSH_PORT**: (optional) the ssh port for WAL backups.
8585
- **SSH_PRIVATE_KEY_PATH**: (optional) the path to the private key used for WAL backups.
@@ -109,18 +109,17 @@ Environment Configuration Settings
109109
- **KUBERNETES_BOOTSTRAP_LABELS**: a JSON describing names and values of labels used by Patroni as ``kubernetes.bootstrap_labels``. Default is empty.
110110
- **INITDB_LOCALE**: database cluster's default UTF-8 locale (en_US by default)
111111
- **ENABLE_WAL_PATH_COMPAT**: old Spilo images were generating wal path in the backup store using the following template ``/spilo/{WAL_BUCKET_SCOPE_PREFIX}{SCOPE}{WAL_BUCKET_SCOPE_SUFFIX}/wal/``, while new images adding one additional directory (``{PGVERSION}``) to the end. In order to avoid (unlikely) issues with restoring WALs (from S3/GC/and so on) when switching to ``spilo-13`` please set the ``ENABLE_WAL_PATH_COMPAT=true`` when deploying old cluster with ``spilo-13`` for the first time. After that the environment variable could be removed. Change of the WAL path also mean that backups stored in the old location will not be cleaned up automatically.
112-
- **WALE_DISABLE_S3_SSE**, **WALG_DISABLE_S3_SSE**: by default wal-e/wal-g are configured to encrypt files uploaded to S3. In order to disable it you can set this environment variable to ``true``.
112+
- **WALG_DISABLE_S3_SSE** or **WALE_DISABLE_S3_SSE**: by default wal-g is configured to encrypt files uploaded to S3. In order to disable it you can set this environment variable to ``true``.
113113
- **USE_OLD_LOCALES**: whether to use old locales from Ubuntu 18.04 in the Ubuntu 22.04-based image. Default is false.
114114

115115
wal-g
116116
-----
117117

118-
`wal-g` is used by default for Azure and SSH backups and restore.
119-
In case of S3, `wal-e` is used for backups and `wal-g` for restore.
120-
121-
- **USE_WALG_BACKUP**: (optional) Enforce using `wal-g` instead of `wal-e` for backups (Boolean)
122-
- **USE_WALG_RESTORE**: (optional) Enforce using `wal-g` instead of `wal-e` for restores (Boolean)
123-
118+
wal-g is used everywhere in Spilo to perform backups and restore from them. **Support for wal-e has been removed**.
119+
Backward compatibility is ensured for environment variables containing **WALE**, the env-dir layout, and bootstrap method names.
120+
This allows existing configurations and clusters to continue working without requiring immediate changes.
121+
Regardless of which variable is set, all backups and restores will be performed using wal-g.
122+
However, if both **WALE** and **WALG** variables are present, the latter will take precedence.
124123
- **WALG_DELTA_MAX_STEPS**, **WALG_DELTA_ORIGIN**, **WALG_DOWNLOAD_CONCURRENCY**, **WALG_UPLOAD_CONCURRENCY**, **WALG_UPLOAD_DISK_CONCURRENCY**, **WALG_DISK_RATE_LIMIT**, **WALG_NETWORK_RATE_LIMIT**, **WALG_COMPRESSION_METHOD**, **WALG_BACKUP_COMPRESSION_METHOD**, **WALG_BACKUP_FROM_REPLICA**, **WALG_SENTINEL_USER_DATA**, **WALG_PREVENT_WAL_OVERWRITE**: (optional) configuration options for wal-g.
125124
- **WALG_S3_CA_CERT_FILE**: (optional) TLS CA certificate for wal-g (see [wal-g configuration](https://github.com/wal-g/wal-g#configuration))
126125
- **WALG_SSH_PREFIX**: (optional) the ssh prefix to store WAL backups at in the format ssh://host.example.com/path/to/backups/ See `Wal-g <https://github.com/wal-g/wal-g#configuration>`__ documentation for details.

delivery.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ allow_concurrent_steps: true
33

44
build_env: &BUILD_ENV
55
BASE_IMAGE: container-registry.zalando.net/library/ubuntu-22.04
6-
PGVERSION: 17
6+
PGVERSION: 18
7+
PGOLDVERSIONS: "16 17"
78
MULTI_ARCH_REGISTRY: container-registry-test.zalando.net/acid
89

910
pipeline:
@@ -32,7 +33,7 @@ pipeline:
3233
docker buildx build --platform "linux/amd64,linux/arm64" \
3334
--build-arg PGVERSION="$PGVERSION" \
3435
--build-arg BASE_IMAGE="$BASE_IMAGE" \
35-
--build-arg PGOLDVERSIONS="14 15 16" \
36+
--build-arg PGOLDVERSIONS="$PGOLDVERSIONS" \
3637
-t "$ECR_TEST_IMAGE" \
3738
--push .
3839
@@ -61,7 +62,7 @@ pipeline:
6162
docker buildx build --platform "linux/amd64,linux/arm64" \
6263
--build-arg PGVERSION="$PGVERSION" \
6364
--build-arg BASE_IMAGE="$BASE_IMAGE" \
64-
--build-arg PGOLDVERSIONS="14 15 16" \
65+
--build-arg PGOLDVERSIONS="$PGOLDVERSIONS" \
6566
-t "$ECR_TEST_IMAGE" \
6667
--push .
6768
cdp-promote-image "$ECR_TEST_IMAGE"
@@ -92,7 +93,7 @@ pipeline:
9293
docker buildx build --platform "linux/amd64,linux/arm64" \
9394
--build-arg PGVERSION="$PGVERSION" \
9495
--build-arg BASE_IMAGE="$BASE_IMAGE" \
95-
--build-arg PGOLDVERSIONS="14 15 16" \
96+
--build-arg PGOLDVERSIONS="$PGOLDVERSIONS" \
9697
-t "$ECR_TEST_IMAGE" \
9798
--push .
9899
cdp-promote-image "$ECR_TEST_IMAGE"

postgres-appliance/Dockerfile

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
ARG BASE_IMAGE=ubuntu:22.04
2-
ARG PGVERSION=17
2+
ARG PGVERSION=18
33
ARG DEMO=false
44
ARG COMPRESS=false
55
ARG ADDITIONAL_LOCALES=
@@ -18,7 +18,7 @@ FROM $BASE_IMAGE as dependencies-builder
1818

1919
ARG DEMO
2020

21-
ENV WALG_VERSION=v3.0.5
21+
ENV WALG_VERSION=v3.0.8
2222

2323
COPY build_scripts/dependencies.sh /builddeps/
2424

@@ -46,37 +46,34 @@ ARG PGVERSION
4646
ARG TIMESCALEDB_APACHE_ONLY=true
4747
ARG TIMESCALEDB_TOOLKIT=true
4848
ARG COMPRESS
49-
ARG PGOLDVERSIONS="13 14 15 16"
49+
ARG PGOLDVERSIONS="14 15 16 17"
5050
ARG WITH_PERL=false
5151

5252
ARG DEB_PG_SUPPORTED_VERSIONS="$PGOLDVERSIONS $PGVERSION"
5353

5454
# Install PostgreSQL, extensions and contribs
55-
ENV POSTGIS_VERSION=3.5 \
56-
BG_MON_COMMIT=7f5887218790b263fe3f42f85f4ddc9c8400b154 \
55+
ENV POSTGIS_VERSION=3.6 \
56+
BG_MON_COMMIT=a73c6bcd10dfdf9feaf5eabab7eb6b12d167680d \
5757
PG_AUTH_MON_COMMIT=fe099eef7662cbc85b0b79191f47f52f1e96b779 \
58-
PG_MON_COMMIT=ead1de70794ed62ca1e34d4022f6165ff36e9a91 \
59-
SET_USER=REL4_1_0 \
58+
PG_MON_COMMIT=88ac7b58348aa061c814982defc170644f368f39 \
6059
PLPROFILER=REL4_2_5 \
61-
PG_PROFILE=4.7 \
62-
PAM_OAUTH2=v1.0.1 \
63-
PG_PERMISSIONS_COMMIT=f4b7c18676fa64236a1c8e28d34a35764e4a70e2
60+
PG_PROFILE=4.11 \
61+
PAM_OAUTH2=v1.0.1
6462

6563
WORKDIR /builddeps
6664
RUN bash base.sh
6765

6866
# Install wal-g
6967
COPY --from=dependencies-builder /builddeps/wal-g /usr/local/bin/
7068

71-
COPY build_scripts/patroni_wale.sh build_scripts/compress_build.sh /builddeps/
69+
COPY build_scripts/patroni.sh build_scripts/compress_build.sh /builddeps/
7270

73-
# Install patroni and wal-e
74-
ENV PATRONIVERSION=4.0.4
75-
ENV WALE_VERSION=1.1.1
71+
# Install patroni
72+
ENV PATRONIVERSION=4.1.0
7673

7774
WORKDIR /
7875

79-
RUN bash /builddeps/patroni_wale.sh
76+
RUN bash /builddeps/patroni.sh
8077

8178
RUN if [ "$COMPRESS" = "true" ]; then bash /builddeps/compress_build.sh; fi
8279

@@ -101,7 +98,7 @@ ENV LC_ALL=en_US.utf-8 \
10198
RW_DIR=/run \
10299
DEMO=$DEMO
103100

104-
ENV WALE_ENV_DIR=$RW_DIR/etc/wal-e.d/env \
101+
ENV WALG_ENV_DIR=$RW_DIR/etc/wal-e.d/env \
105102
LOG_ENV_DIR=$RW_DIR/etc/log.d/env \
106103
PGROOT=$PGHOME/pgdata/pgroot
107104

postgres-appliance/bootstrap/clone_with_wale.py renamed to postgres-appliance/bootstrap/clone_with_walg.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def read_configuration():
2525
parser.add_argument('--recovery-target-time',
2626
help='the timestamp up to which recovery will proceed (including time zone)',
2727
dest='recovery_target_time_string')
28-
parser.add_argument('--dry-run', action='store_true', help='find a matching backup and build the wal-e '
28+
parser.add_argument('--dry-run', action='store_true', help='find a matching backup and build the wal-g.'
2929
'command to fetch that backup without running it')
3030
args = parser.parse_args()
3131

@@ -40,8 +40,8 @@ def read_configuration():
4040
return options(args.scope, args.datadir, recovery_target_time, args.dry_run)
4141

4242

43-
def build_wale_command(command, datadir=None, backup=None):
44-
cmd = ['wal-g' if os.getenv('USE_WALG_RESTORE') == 'true' else 'wal-e'] + [command]
43+
def build_walg_command(command, datadir=None, backup=None):
44+
cmd = ['wal-g', command]
4545
if command == 'backup-fetch':
4646
if datadir is None or backup is None:
4747
raise Exception("backup-fetch requires datadir and backup arguments")
@@ -79,7 +79,7 @@ def choose_backup(backup_list, recovery_target_time):
7979

8080

8181
def list_backups(env):
82-
backup_list_cmd = build_wale_command('backup-list')
82+
backup_list_cmd = build_walg_command('backup-list')
8383
output = subprocess.check_output(backup_list_cmd, env=env)
8484
reader = csv.DictReader(fix_output(output), dialect='excel-tab')
8585
return list(reader)
@@ -89,7 +89,7 @@ def get_clone_envdir():
8989
from spilo_commons import get_patroni_config
9090

9191
config = get_patroni_config()
92-
restore_command = shlex.split(config['bootstrap']['clone_with_wale']['recovery_conf']['restore_command'])
92+
restore_command = shlex.split(config['bootstrap']['clone_with_walg']['recovery_conf']['restore_command'])
9393
if len(restore_command) > 4 and restore_command[0] == 'envdir':
9494
return restore_command[1]
9595
raise Exception('Failed to find clone envdir')
@@ -117,10 +117,9 @@ def get_possible_versions():
117117
return [ver for _, ver in sorted(versions.items(), reverse=True)]
118118

119119

120-
def get_wale_environments(env):
121-
use_walg = env.get('USE_WALG_RESTORE') == 'true'
122-
prefix = 'WALG_' if use_walg else 'WALE_'
123-
# len('WALE__PREFIX') = 12
120+
def get_walg_environments(env):
121+
prefix = 'WALG_'
122+
# len('WALG_PREFIX') = 12
124123
names = [name for name in env.keys() if name.endswith('_PREFIX') and name.startswith(prefix) and len(name) > 12]
125124
if len(names) != 1:
126125
raise Exception('Found find {0} {1}*_PREFIX environment variables, expected 1'
@@ -141,7 +140,7 @@ def get_wale_environments(env):
141140

142141
def find_backup(recovery_target_time, env):
143142
old_value = None
144-
for name, value in get_wale_environments(env):
143+
for name, value in get_walg_environments(env):
145144
logger.info('Trying %s for clone', value)
146145
if not old_value:
147146
old_value = env[name]
@@ -164,12 +163,12 @@ def run_clone_from_s3(options):
164163

165164
backup_name, update_envdir = find_backup(options.recovery_target_time, env)
166165

167-
backup_fetch_cmd = build_wale_command('backup-fetch', options.datadir, backup_name)
166+
backup_fetch_cmd = build_walg_command('backup-fetch', options.datadir, backup_name)
168167
logger.info("cloning cluster %s using %s", options.name, ' '.join(backup_fetch_cmd))
169168
if not options.dry_run:
170169
ret = subprocess.call(backup_fetch_cmd, env=env)
171170
if ret != 0:
172-
raise Exception("wal-e backup-fetch exited with exit code {0}".format(ret))
171+
raise Exception("wal-g backup-fetch exited with exit code {0}".format(ret))
173172

174173
if update_envdir: # We need to update file in the clone envdir or restore_command will fail!
175174
envdir = get_clone_envdir()

postgres-appliance/bootstrap/maybe_pg_upgrade.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def perform_pitr(postgresql, cluster_version, bin_version, config):
4040
except Exception:
4141
logs = tail_postgres_logs()
4242
# Spilo has no other locales except en_EN.UTF-8, therefore we are safe here.
43-
if int(cluster_version) >= 13 and 'recovery ended before configured recovery target was reached' in logs:
43+
if 'recovery ended before configured recovery target was reached' in logs:
4444
# Starting from version 13 Postgres stopped promoting when recovery target wasn't reached.
4545
# In order to improve the user experience we reset all possible recovery targets and retry.
4646
recovery_conf = config[config['method']].get('recovery_conf', {})
@@ -103,7 +103,7 @@ def main():
103103
except Exception as e:
104104
logger.error('Failed to update extensions: %r', e)
105105

106-
upgrade.analyze()
106+
upgrade.analyze(bin_version)
107107

108108

109109
def call_maybe_pg_upgrade():

0 commit comments

Comments
 (0)