Skip to content

Commit

Permalink
wal-e swift support (#247)
Browse files Browse the repository at this point in the history
  • Loading branch information
eamosov authored and CyberDem0n committed Aug 10, 2018
1 parent 16758f1 commit 07ce0cd
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
7 changes: 7 additions & 0 deletions ENVIRONMENT.rst
Expand Up @@ -33,6 +33,13 @@ Environment Configuration Settings
- **WALG_DELTA_MAX_STEPS**, **WALG_DELTA_ORIGIN**, **WALG_DOWNLOAD_CONCURRENCY**, **WALG_UPLOAD_CONCURRENCY**, **WALG_UPLOAD_DISK_CONCURRENCY**: (optional) configuration options for wal-g. If at least of the options is specified, wal-g will be used instead of wal-e.
- **WAL_GCS_BUCKET**: ditto for the Google Cloud Storage (WAL-E supports both S3 and GCS).
- **GOOGLE_APPLICATION_CREDENTIALS**: credentials for WAL-E when running in Google Cloud.
- **WAL_SWIFT_BUCKET**: ditto for the OpenStack Object Storage (Swift)
- **SWIFT_AUTHURL**: see wal-e documentation https://github.com/wal-e/wal-e#swift
- **SWIFT_TENANT**:
- **SWIFT_USER**:
- **SWIFT_PASSWORD**:
- **SWIFT_AUTH_VERSION**:
- **SWIFT_ENDPOINT_TYPE**:
- **CALLBACK_SCRIPT**: the callback script to run on various cluster actions (on start, on stop, on restart, on role change). The script will receive the cluster name, connection string and the current action. See `Patroni <http://patroni.readthedocs.io/en/latest/SETTINGS.html?highlight=callback#postgresql>`__ documentation for details.
- **LOG_S3_BUCKET**: path to the S3 bucket used for PostgreSQL daily log files (i.e. s3://foobar). Spilo will add /spilo/scope/pg_daily_logs to that path. Logs are shipped if this variable is set.
- **LOG_SHIP_SCHEDULE**: cron schedule for shipping compressed logs from ``pg_log``(if this feature is enabled, '00 02 * * *' by default)
Expand Down
12 changes: 10 additions & 2 deletions postgres-appliance/Dockerfile.build
Expand Up @@ -95,6 +95,12 @@ RUN export DEBIAN_FRONTEND=noninteractive \
&& equivs-build perl; \
fi \

&& for p in python3-keyring python3-docutils ieee-data; do \
version=$(apt-cache show $p | sed -n 's/^Version: //p' | sort -rV | head -n 1) \
&& echo "Section: misc\nPriority: optional\nStandards-Version: 3.9.8\nPackage: $p\nVersion: $version\nDescription: $p" > $p \
&& equivs-build $p; \
done \

&& dpkg -i *.deb || apt-get -y -f install \

# install pam_oauth2.so
Expand Down Expand Up @@ -390,9 +396,11 @@ RUN export DEBIAN_FRONTEND=noninteractive \
EXTRAS=",etcd,consul,zookeeper,aws" \
&& apt-get install -y python3-etcd python3-consul python3-kazoo python3-meld3 \
python3-boto python3-gevent python3-greenlet python3-protobuf \
python3-websocket python3-requests-oauthlib \
python3-websocket python3-requests-oauthlib python3-swiftclient \

&& find /usr/share/python-babel-localedata/locale-data -type f ! -name 'en_US*.dat' -delete \

&& pip3 install envdir filechunkio wal-e[aws,google]==$WALE_VERSION \
&& pip3 install envdir filechunkio wal-e[aws,google,swift]==$WALE_VERSION \
'git+https://github.com/Supervisor/supervisor.git@master#egg=supervisor' \
'git+https://github.com/zalando/pg_view.git@master#egg=pg-view' \

Expand Down
12 changes: 11 additions & 1 deletion postgres-appliance/scripts/configure_spilo.py
Expand Up @@ -417,7 +417,7 @@ def get_placeholders(provider):
else:
placeholders['CALLBACK_SCRIPT'] = 'patroni_aws'

placeholders['USE_WALE'] = bool(placeholders.get('WAL_S3_BUCKET') or placeholders.get('WAL_GCS_BUCKET'))
placeholders['USE_WALE'] = bool(placeholders.get('WAL_S3_BUCKET') or placeholders.get('WAL_GCS_BUCKET') or placeholders.get('WAL_SWIFT_BUCKET'))

# Kubernetes requires a callback to change the labels in order to point to the new master
if USE_KUBERNETES:
Expand Down Expand Up @@ -537,6 +537,13 @@ def write_wale_environment(placeholders, provider, prefix, overwrite):
'WAL_BUCKET_SCOPE_SUFFIX',
'WAL_GCS_BUCKET',
'GOOGLE_APPLICATION_CREDENTIALS',
'WAL_SWIFT_BUCKET',
'SWIFT_AUTHURL',
'SWIFT_TENANT',
'SWIFT_USER',
'SWIFT_PASSWORD',
'SWIFT_AUTH_VERSION',
'SWIFT_ENDPOINT_TYPE'
]
})
wale.update({name: placeholders[prefix + name] for name in envdir_names if prefix + name in placeholders})
Expand Down Expand Up @@ -573,6 +580,9 @@ def write_wale_environment(placeholders, provider, prefix, overwrite):
elif wale.get('WAL_GCS_BUCKET'):
wale['WALE_GS_PREFIX'] = 'gs://{WAL_GCS_BUCKET}{BUCKET_PATH}'.format(**wale)
write_envdir_names = ['WALE_GS_PREFIX', 'GOOGLE_APPLICATION_CREDENTIALS']
elif wale.get('WAL_SWIFT_BUCKET'):
wale['WALE_SWIFT_PREFIX'] = 'swift://{WAL_SWIFT_BUCKET}{BUCKET_PATH}'.format(**wale)
write_envdir_names = ['WALE_SWIFT_PREFIX', 'SWIFT_AUTHURL', 'SWIFT_TENANT', 'SWIFT_USER', 'SWIFT_PASSWORD', 'SWIFT_AUTH_VERSION', 'SWIFT_ENDPOINT_TYPE']
else:
return

Expand Down

0 comments on commit 07ce0cd

Please sign in to comment.