Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ENVIRONMENT.rst
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ Environment Configuration Settings
- **KUBERNETES_STANDBY_LEADER_LABEL_VALUE**: value of the pod label if Postgres role is standby_leader when running on Kubernetes. Default is 'master'.
- **KUBERNETES_SCOPE_LABEL**: name of the label containing cluster name. Default is 'version'.
- **KUBERNETES_LABELS**: a JSON describing names and values of other labels used by Patroni on Kubernetes to locate its metadata. Default is '{"application": "spilo"}'.
- **KUBERNETES_BOOTSTRAP_LABELS**: a JSON describing names and values of labels used by Patroni as ``kubernetes.bootstrap_labels``. Default is empty.
- **INITDB_LOCALE**: database cluster's default UTF-8 locale (en_US by default)
- **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.
- **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``.
Expand Down
24 changes: 16 additions & 8 deletions postgres-appliance/scripts/configure_spilo.py
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,7 @@ def get_placeholders(provider):
placeholders.setdefault('KUBERNETES_LABELS', KUBERNETES_DEFAULT_LABELS)
placeholders.setdefault('KUBERNETES_USE_CONFIGMAPS', '')
placeholders.setdefault('KUBERNETES_BYPASS_API_SERVICE', 'true')
placeholders.setdefault('KUBERNETES_BOOTSTRAP_LABELS', '')
placeholders.setdefault('USE_PAUSE_AT_RECOVERY_TARGET', False)
placeholders.setdefault('CLONE_METHOD', '')
placeholders.setdefault('CLONE_WITH_WALE', '')
Expand Down Expand Up @@ -741,13 +742,15 @@ def get_dcs_config(config, placeholders):

if USE_KUBERNETES and placeholders.get('DCS_ENABLE_KUBERNETES_API'):
config = {'kubernetes': dcs_configs['kubernetes']}
try:
kubernetes_labels = json.loads(config['kubernetes'].get('labels'))
except (TypeError, ValueError) as e:
logging.warning("could not parse kubernetes labels as a JSON: %r, "
"reverting to the default: %s", e, KUBERNETES_DEFAULT_LABELS)
kubernetes_labels = json.loads(KUBERNETES_DEFAULT_LABELS)
config['kubernetes']['labels'] = kubernetes_labels

for param, default_val in (('labels', KUBERNETES_DEFAULT_LABELS), ('bootstrap_labels', '{}')):
try:
kubernetes_labels = json.loads(config['kubernetes'].get(param))
except (TypeError, ValueError) as e:
logging.warning("could not parse kubernetes %s as a JSON: %r, "
"reverting to the default: %s", param, e, default_val)
kubernetes_labels = json.loads(default_val)
config['kubernetes'][param] = kubernetes_labels

if not config['kubernetes'].pop('use_configmaps'):
config['kubernetes'].update({'use_endpoints': True,
Expand Down Expand Up @@ -792,7 +795,12 @@ def write_log_environment(placeholders):
if not os.path.exists(log_env['LOG_ENV_DIR']):
os.makedirs(log_env['LOG_ENV_DIR'])

tags = json.loads(os.getenv('LOG_S3_TAGS'))
try:
tags = json.loads(os.getenv('LOG_S3_TAGS'))
except (TypeError, ValueError) as e:
logging.warning("could not parse LOG_S3_TAGS as a JSON: %r, reverting to the default empty dict", e)
tags = {}
Comment on lines +798 to +802
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unrelated to the bootstrap-label changes, but makes a lot of sense to be more careful with parsing those strings.


log_env['LOG_S3_TAGS'] = "&".join(f"{key}={os.getenv(value)}" for key, value in tags.items())

for var in ('LOG_TMPDIR',
Expand Down