Skip to content

Commit 2bf045e

Browse files
committed
address feedback
1 parent 2042704 commit 2bf045e

File tree

4 files changed

+10
-11
lines changed

4 files changed

+10
-11
lines changed

ENVIRONMENT.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ wal-g
116116
-----
117117

118118
wal-g is used everywhere in Spilo to perform backups and restore from them. **Support for wal-e has been removed**.
119-
For backward compatibility, Spilo will still recognize environment variables containing **WALE**.
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.
120121
Regardless of which variable is set, all backups and restores will be performed using wal-g.
121122
However, if both **WALE** and **WALG** variables are present, the latter will take precedence.
122123
- **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.

postgres-appliance/bootstrap/clone_with_walg.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ def get_possible_versions():
119119

120120
def get_walg_environments(env):
121121
prefix = 'WALG_'
122+
# len('WALG_PREFIX') = 12
122123
names = [name for name in env.keys() if name.endswith('_PREFIX') and name.startswith(prefix) and len(name) > 12]
123124
if len(names) != 1:
124125
raise Exception('Found find {0} {1}*_PREFIX environment variables, expected 1'

postgres-appliance/scripts/configure_spilo.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ def get_placeholders(provider):
527527
placeholders = {}
528528
for key, value in os.environ.items():
529529
if "WALE" in key:
530-
new_key = key.replace("WALE", "WALG")
530+
new_key = key.replace("WALE", "WALG") # backward compatibility
531531
if new_key in os.environ:
532532
# skip, because a real WALG env already exists
533533
continue
@@ -616,6 +616,7 @@ def get_placeholders(provider):
616616
else:
617617
placeholders['LOG_SHIP_HOURLY'] = ''
618618

619+
# use namespaces to set WAL bucket prefix scope naming the folder namespace-clustername for non-default namespace
619620
placeholders.setdefault('LOG_BUCKET_SCOPE_PREFIX', '{0}-'.format(placeholders['NAMESPACE'])
620621
if placeholders['NAMESPACE'] not in ('default', '') else '')
621622

@@ -654,7 +655,7 @@ def get_placeholders(provider):
654655

655656
# check if we have enough parameters to enable WAL-G
656657
placeholders['USE_WALG'] = any(placeholders.get(n) for n in AUTO_ENABLE_WALG_RESTORE +
657-
('WAL_SWIFT_BUCKET', 'WAL_GCS_BUCKET', 'WAL_GS_BUCKET', 'WALG_GS_PREFIX'))
658+
('WAL_SWIFT_BUCKET', 'WAL_GS_BUCKET', 'WALG_GS_PREFIX'))
658659

659660
if placeholders.get('WALG_BACKUP_FROM_REPLICA'):
660661
placeholders['WALG_BACKUP_FROM_REPLICA'] = str(placeholders['WALG_BACKUP_FROM_REPLICA']).lower()
@@ -857,7 +858,7 @@ def write_walg_environment(placeholders, prefix, overwrite):
857858

858859
walg = defaultdict(lambda: '')
859860
for name in ['PGVERSION', 'PGPORT', 'WALG_ENV_DIR', 'SCOPE', 'WAL_BUCKET_SCOPE_PREFIX', 'WAL_BUCKET_SCOPE_SUFFIX',
860-
'WAL_S3_BUCKET', 'WAL_GCS_BUCKET', 'WAL_GS_BUCKET', 'WAL_SWIFT_BUCKET', 'BACKUP_NUM_TO_RETAIN',
861+
'WAL_S3_BUCKET', 'WAL_GS_BUCKET', 'WAL_SWIFT_BUCKET', 'BACKUP_NUM_TO_RETAIN',
861862
'ENABLE_WAL_PATH_COMPAT'] + s3_names + swift_names + gs_names + walg_names + azure_names + \
862863
azure_auth_names + ssh_names:
863864
walg[name] = placeholders.get(prefix + name, '')
@@ -910,12 +911,9 @@ def write_walg_environment(placeholders, prefix, overwrite):
910911
walg[name] = placeholders.get(name)
911912

912913
write_envdir_names = s3_names + walg_names + aws_imds_names
913-
elif walg.get('WAL_GCS_BUCKET') or walg.get('WAL_GS_BUCKET') or\
914-
walg.get('WALG_GS_PREFIX'):
915-
if walg.get('WAL_GCS_BUCKET'):
916-
walg['WAL_GS_BUCKET'] = walg['WAL_GCS_BUCKET']
914+
elif walg.get('WAL_GS_BUCKET') or walg.get('WALG_GS_PREFIX'):
917915
write_envdir_names = gs_names + walg_names
918-
elif walg.get('WAL_SWIFT_BUCKET'):
916+
elif walg.get('WAL_SWIFT_BUCKET') or walg.get('WALG_SWIFT_BUCKET'):
919917
write_envdir_names = swift_names
920918
elif walg.get("WALG_AZ_PREFIX"):
921919
azure_auth = []

postgres-appliance/tests/test_spilo.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,7 @@ function test_successful_inplace_upgrade_to_14() {
136136
}
137137

138138
function test_envdir_suffix() {
139-
docker_exec "$1" "cat /run/etc/wal-e.d/env/WALG_S3_PREFIX" | grep -q "$2$" \
140-
&& docker_exec "$1" "cat /run/etc/wal-e.d/env/WALG_S3_PREFIX" | grep -q "$2$"
139+
docker_exec "$1" "cat /run/etc/wal-e.d/env/WALG_S3_PREFIX" | grep -q "$2$"
141140
}
142141

143142
function test_envdir_updated_to_x() {

0 commit comments

Comments
 (0)