Skip to content

Commit

Permalink
Patroni 1.4.1 (#205)
Browse files Browse the repository at this point in the history
In addition to that use a Patroni configfile for patronictl. It contains cluster name and therefore makes optional specifying it for some of the patronictl commands like `list`, `edit-config` `pause` and so on.
  • Loading branch information
CyberDem0n committed Jan 19, 2018
1 parent 98a9d32 commit 4e287b0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion postgres-appliance/Dockerfile.build
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ RUN export DEBIAN_FRONTEND=noninteractive \
/usr/lib/postgresql/*/bin/pltcl_*

# Install patroni and WAL-e
ENV PATRONIVERSION=1.4
ENV PATRONIVERSION=1.4.1
ENV WALE_VERSION=1.1.0
RUN export DEBIAN_FRONTEND=noninteractive \
&& set -ex \
Expand Down
24 changes: 15 additions & 9 deletions postgres-appliance/configure_spilo.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,10 +432,10 @@ def get_placeholders(provider):

def write_file(config, filename, overwrite):
if not overwrite and os.path.exists(filename):
logging.warning('File {} already exists, not overwriting. (Use option --force if necessary)'.format(filename))
logging.warning('File %s already exists, not overwriting. (Use option --force if necessary)', filename)
else:
with open(filename, 'w') as f:
logging.info('Writing to file {}'.format(filename))
logging.info('Writing to file %s', filename)
f.write(config)


Expand Down Expand Up @@ -641,18 +641,24 @@ def main():
format(config['postgresql']['authentication']['replication']['username'])
config['bootstrap']['pg_hba'].insert(0, rep_hba)

patroni_configfile = os.path.join(placeholders['PGHOME'], 'postgres.yml')

for section in args['sections']:
logging.info('Configuring {}'.format(section))
if section == 'patroni':
patroni_configfile = os.path.join(placeholders['PGHOME'], 'postgres.yml')
write_file(yaml.dump(config, default_flow_style=False, width=120), patroni_configfile, args['force'])
elif section == 'patronictl':
patronictl_config = {k: v for k, v in config.items()
if k in ['exhibitor', 'zookeeper', 'etcd', 'consul', 'kubernetes']}
patronictl_configfile = os.path.join(placeholders['PGHOME'], '.config', 'patroni', 'patronictl.yaml')
if not os.path.exists(os.path.dirname(patronictl_configfile)):
os.makedirs(os.path.dirname(patronictl_configfile))
write_file(yaml.dump(patronictl_config), patronictl_configfile, args['force'])
configdir = os.path.join(placeholders['PGHOME'], '.config', 'patroni')
patronictl_configfile = os.path.join(configdir, 'patronictl.yaml')
if not os.path.exists(configdir):
os.makedirs(configdir)
if os.path.exists(patronictl_configfile):
if not args['force']:
logging.warning('File %s already exists, not overriding. (Use option --force if necessary)',
patronictl_configfile)
continue
os.unlink(patronictl_configfile)
os.symlink(patroni_configfile, patronictl_configfile)
elif section == 'wal-e':
if placeholders['USE_WALE']:
write_wale_environment(placeholders, provider, '', args['force'])
Expand Down

0 comments on commit 4e287b0

Please sign in to comment.