Skip to content

Commit

Permalink
Update Patroni and timescaledb versions (#912)
Browse files Browse the repository at this point in the history
* Patroni 3.1.0, timescaledb 2.11.2
* Align with the new Patroni code API
  • Loading branch information
hughcapet authored Sep 8, 2023
1 parent 353270a commit 849a71e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions postgres-appliance/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ARG BASE_IMAGE=ubuntu:22.04
ARG PGVERSION=15
ARG TIMESCALEDB="1.7.5 2.3.1 2.11.1"
ARG TIMESCALEDB="1.7.5 2.3.1 2.11.2"
ARG DEMO=false
ARG COMPRESS=false
ARG ADDITIONAL_LOCALES=
Expand Down Expand Up @@ -77,7 +77,7 @@ COPY --from=dependencies-builder /builddeps/wal-g /usr/local/bin/
COPY build_scripts/patroni_wale.sh build_scripts/compress_build.sh /builddeps/

# Install patroni and wal-e
ENV PATRONIVERSION=3.0.2
ENV PATRONIVERSION=3.1.0
ENV WALE_VERSION=1.1.1

WORKDIR /
Expand Down
11 changes: 7 additions & 4 deletions postgres-appliance/major_upgrade/inplace_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,21 +130,22 @@ def check_patroni_api(self, member):
return logger.error('API request to %s name failed: %r', member.name, e)

def toggle_pause(self, paused):
from patroni.config import get_global_config
from patroni.utils import polling_loop

cluster = self.dcs.get_cluster()
config = cluster.config.data.copy()
if cluster.is_paused() == paused:
if get_global_config(cluster).is_paused == paused:
return logger.error('Cluster is %spaused, can not continue', ('' if paused else 'not '))

config['pause'] = paused
if not self.dcs.set_config_value(json.dumps(config, separators=(',', ':')), cluster.config.index):
if not self.dcs.set_config_value(json.dumps(config, separators=(',', ':')), cluster.config.version):
return logger.error('Failed to pause cluster, can not continue')

self.paused = paused

old = {m.name: m.index for m in cluster.members if m.api_url}
ttl = cluster.config.data.get('ttl', self.dcs.ttl)
ttl = config.get('ttl', self.dcs.ttl)
for _ in polling_loop(ttl + 1):
cluster = self.dcs.get_cluster()
if all(m.data.get('pause', False) == paused for m in cluster.members if m.name in old):
Expand Down Expand Up @@ -202,13 +203,15 @@ def ensure_replica_state(member):
return all(ensure_replica_state(member) for member in cluster.members if member.name != self.postgresql.name)

def sanity_checks(self, cluster):
from patroni.config import get_global_config

if not cluster.initialize:
return logger.error('Upgrade can not be triggered because the cluster is not initialized')

if len(cluster.members) != self.replica_count:
return logger.error('Upgrade can not be triggered because the number of replicas does not match (%s != %s)',
len(cluster.members), self.replica_count)
if cluster.is_paused():
if get_global_config(cluster).is_paused:
return logger.error('Upgrade can not be triggered because Patroni is in maintenance mode')

lock_owner = cluster.leader and cluster.leader.name
Expand Down

0 comments on commit 849a71e

Please sign in to comment.