Relax requirements on superuser credentials (#930)

libpq allows opening connection without explicitly specifying neither username nor password. Depending on situation it would rely either on `pgpass` file or trust authentication method in pg_hba.conf.

Since pg_rewind is also using libpq, it could work the same way.

Fixes https://github.com/zalando/patroni/issues/928
This commit is contained in:
Alexander Kukushkin
2019-01-15 11:15:35 +01:00
committed by GitHub
parent e080ded44b
commit cf34fb3934
+3 -2
View File
@@ -392,7 +392,7 @@ class Postgresql(object):
we have either wal_log_hints or checksums turned on
"""
# low-hanging fruit: check if pg_rewind configuration is there
if not (self.config.get('use_pg_rewind') and all(self._superuser.get(n) for n in ('username', 'password'))):
if not self.config.get('use_pg_rewind'):
return False
cmd = [self._pgcommand('pg_rewind'), '--help']
@@ -1673,7 +1673,8 @@ $$""".format(name, ' '.join(options)), name, password, password)
def post_bootstrap(self, config, task):
try:
self.create_or_update_role(self._superuser['username'], self._superuser['password'], ['SUPERUSER'])
if 'username' in self._superuser and 'password' in self._superuser:
self.create_or_update_role(self._superuser['username'], self._superuser['password'], ['SUPERUSER'])
task.complete(self.run_bootstrap_post_init(config))
if task.result: