Merge ~arturo-seijas/postgresql-charm:fix-unknown-option-wal-keep-segments into postgresql-charm:master

Proposed by Arturo Enrique Seijas Fernández
Status: Merged
Approved by: Tom Haddon
Approved revision: 5d3809d92c1402bf85894aef4413bba2b328c190
Merged at revision: f95c875da4280b477a97c0e1f86911d2ba69c0f7
Proposed branch: ~arturo-seijas/postgresql-charm:fix-unknown-option-wal-keep-segments
Merge into: postgresql-charm:master
Diff against target: 45 lines (+10/-9)
1 file modified
reactive/postgresql/service.py (+10/-9)
Reviewer Review Type Date Requested Status
Tom Haddon Approve
Canonical IS Reviewers Pending
Review via email: mp+440226@code.launchpad.net

Commit message

Fix unknown option was_keep_segments in Jammy

Description of the change

was_keep_segments and replicated_wal_keep_segments have been renamed to wal_keep_size and replicated_wal_keep_size and in PostgreSQL 14

To post a comment you must log in.
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

This merge proposal is being monitored by mergebot. Change the status to Approved to merge.

Revision history for this message
Tom Haddon (mthaddon) wrote :

I'd be surprised if this works - you're referencing `config["replicated_wal_keep_size"]` but I don't see that as a config option (in `config.yaml`) - only `replicated_wal_keep_segments`.

Can you test and confirm?

Revision history for this message
Tom Haddon (mthaddon) wrote :

LGTM, thx

review: Approve
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Change successfully merged at revision f95c875da4280b477a97c0e1f86911d2ba69c0f7

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/reactive/postgresql/service.py b/reactive/postgresql/service.py
2index d42cbbf..d1a7f62 100644
3--- a/reactive/postgresql/service.py
4+++ b/reactive/postgresql/service.py
5@@ -20,22 +20,16 @@ import subprocess
6 import textwrap
7 import time
8
9+import context
10 import yaml
11-
12 from charmhelpers.core import hookenv, host, sysctl, templating, unitdata
13 from charmhelpers.core.hookenv import DEBUG, WARNING
14 from charms import apt, coordinator, reactive
15 from charms.reactive import hook, when, when_any, when_not
16-
17-import context
18 from everyhook import everyhook
19
20+from reactive.postgresql import helpers, nagios, postgresql, replication, wal_e
21 from reactive.workloadstatus import status_set
22-from reactive.postgresql import helpers
23-from reactive.postgresql import nagios
24-from reactive.postgresql import postgresql
25-from reactive.postgresql import replication
26-from reactive.postgresql import wal_e
27
28
29 @hook("install")
30@@ -732,7 +726,14 @@ def ensure_viable_postgresql_conf(opts):
31
32 # Having two config options for the one setting is confusing. Perhaps
33 # we should deprecate this.
34- if num_standbys and (int(config["replicated_wal_keep_segments"]) > int(opts.get("wal_keep_segments", 0))):
35+ # PostgreSQL 14 renames wal_keep_segments to wal_keep_size and
36+ # replicated_wal_keep_segments to replicated_wal_keep_size.
37+ # Note that for version 14 the charm does not set a default for these configs.
38+ if (
39+ not postgresql.has_version("14")
40+ and num_standbys
41+ and (int(config["replicated_wal_keep_segments"]) > int(opts.get("wal_keep_segments", 0)))
42+ ):
43 force(wal_keep_segments=config["replicated_wal_keep_segments"])
44
45 # Log shipping with WAL-E.

Subscribers

People subscribed via source and target branches