From c931da1eb3a1a84095cfd3a916ab0bf500944b3f Mon Sep 17 00:00:00 2001 From: GuanqunYang193 <144971563+GuanqunYang193@users.noreply.github.com> Date: Tue, 13 Aug 2024 09:55:58 -0400 Subject: [PATCH] Remove user creation (#2894) It was announced as deprecated in v3.2.0 --- patroni/config.py | 17 ----------------- patroni/postgresql/bootstrap.py | 7 ++----- tests/test_ha.py | 5 ----- 3 files changed, 2 insertions(+), 27 deletions(-) diff --git a/patroni/config.py b/patroni/config.py index 462994c3..eeac3f1f 100644 --- a/patroni/config.py +++ b/patroni/config.py @@ -676,23 +676,6 @@ class Config(object): if dcs in ret: ret[dcs].update(_get_auth(dcs)) - users = {} - for param in list(os.environ.keys()): - if param.startswith(PATRONI_ENV_PREFIX): - name, suffix = (param[len(PATRONI_ENV_PREFIX):].rsplit('_', 1) + [''])[:2] - # PATRONI__PASSWORD=, PATRONI__OPTIONS= - # CREATE USER "" WITH PASSWORD '' - if name and suffix == 'PASSWORD': - password = os.environ.pop(param) - if password: - users[name] = {'password': password} - options = os.environ.pop(param[:-9] + '_OPTIONS', None) # replace "_PASSWORD" with "_OPTIONS" - options = options and _parse_list(options) - if options: - users[name]['options'] = options - if users: - ret['bootstrap']['users'] = users - return ret def _build_effective_configuration(self, dynamic_configuration: Dict[str, Any], diff --git a/patroni/postgresql/bootstrap.py b/patroni/postgresql/bootstrap.py index 47dbacfe..2be038f9 100644 --- a/patroni/postgresql/bootstrap.py +++ b/patroni/postgresql/bootstrap.py @@ -444,11 +444,8 @@ END;$$""".format(f, quote_ident(rewind['username'], postgresql.connection())) postgresql.query(sql) if config.get('users'): - logger.warning('User creation via "bootstrap.users" will be removed in v4.0.0') - - for name, value in (config.get('users') or EMPTY_DICT).items(): - if all(name != a.get('username') for a in (superuser, replication, rewind)): - self.create_or_update_role(name, value.get('password'), value.get('options', [])) + logger.error('User creation is not be supported starting from v4.0.0. ' + 'Please use "boostrap.post_bootstrap" script to create users.') # We were doing a custom bootstrap instead of running initdb, therefore we opened trust # access from certain addresses to be able to reach cluster and change password diff --git a/tests/test_ha.py b/tests/test_ha.py index a07a2681..286c99ed 100644 --- a/tests/test_ha.py +++ b/tests/test_ha.py @@ -119,11 +119,6 @@ class MockPatroni(object): restapi: listen: 0.0.0.0:8008 bootstrap: - users: - replicator: - password: rep-pass - options: - - replication postgresql: name: foo data_dir: data/postgresql0