Skip to content

Commit c624ff8

Browse files
committed
Properly handle patroni bootstrap_labels config
1 parent bb39d81 commit c624ff8

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

ENVIRONMENT.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ Environment Configuration Settings
106106
- **KUBERNETES_STANDBY_LEADER_LABEL_VALUE**: value of the pod label if Postgres role is standby_leader when running on Kubernetes. Default is 'master'.
107107
- **KUBERNETES_SCOPE_LABEL**: name of the label containing cluster name. Default is 'version'.
108108
- **KUBERNETES_LABELS**: a JSON describing names and values of other labels used by Patroni on Kubernetes to locate its metadata. Default is '{"application": "spilo"}'.
109+
- **KUBERNETES_BOOTSTRAP_LABELS**: a JSON describing names and values of labels used by Patroni as ``kubernetes.bootstrap_labels``. Default is empty.
109110
- **INITDB_LOCALE**: database cluster's default UTF-8 locale (en_US by default)
110111
- **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.
111112
- **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``.

postgres-appliance/scripts/configure_spilo.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,7 @@ def get_placeholders(provider):
585585
placeholders.setdefault('KUBERNETES_LABELS', KUBERNETES_DEFAULT_LABELS)
586586
placeholders.setdefault('KUBERNETES_USE_CONFIGMAPS', '')
587587
placeholders.setdefault('KUBERNETES_BYPASS_API_SERVICE', 'true')
588+
placeholders.setdefault('KUBERNETES_BOOTSTRAP_LABELS', '')
588589
placeholders.setdefault('USE_PAUSE_AT_RECOVERY_TARGET', False)
589590
placeholders.setdefault('CLONE_METHOD', '')
590591
placeholders.setdefault('CLONE_WITH_WALE', '')
@@ -741,13 +742,15 @@ def get_dcs_config(config, placeholders):
741742

742743
if USE_KUBERNETES and placeholders.get('DCS_ENABLE_KUBERNETES_API'):
743744
config = {'kubernetes': dcs_configs['kubernetes']}
744-
try:
745-
kubernetes_labels = json.loads(config['kubernetes'].get('labels'))
746-
except (TypeError, ValueError) as e:
747-
logging.warning("could not parse kubernetes labels as a JSON: %r, "
748-
"reverting to the default: %s", e, KUBERNETES_DEFAULT_LABELS)
749-
kubernetes_labels = json.loads(KUBERNETES_DEFAULT_LABELS)
750-
config['kubernetes']['labels'] = kubernetes_labels
745+
746+
for param, default_val in (('labels', KUBERNETES_DEFAULT_LABELS), ('bootstrap_labels', '')):
747+
try:
748+
kubernetes_labels = json.loads(config['kubernetes'].get(param))
749+
except (TypeError, ValueError) as e:
750+
logging.warning("could not parse kubernetes %s as a JSON: %r, "
751+
"reverting to the default: %s", param, e, default_val)
752+
kubernetes_labels = json.loads(default_val)
753+
config['kubernetes'][param] = kubernetes_labels
751754

752755
if not config['kubernetes'].pop('use_configmaps'):
753756
config['kubernetes'].update({'use_endpoints': True,

0 commit comments

Comments
 (0)