Merge ~barryprice/postgresql-charm/+git/postgresql-charm:master into postgresql-charm:master

Proposed by Barry Price
Status: Merged
Merged at revision: 7f35008bca9fcd37d3ea37fcdccdd32c4c32e142
Proposed branch: ~barryprice/postgresql-charm/+git/postgresql-charm:master
Merge into: postgresql-charm:master
Diff against target: 39 lines (+9/-3)
2 files modified
config.yaml (+1/-1)
reactive/postgresql/nagios.py (+8/-2)
Reviewer Review Type Date Requested Status
Stuart Bishop (community) Approve
Review via email: mp+363823@code.launchpad.net

Commit message

Fix mis-named config variable, guard against empty wal-e backup thershold charm config (use the default values if we get a None)

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
Stuart Bishop (stub) wrote :

Yup

review: Approve
Revision history for this message
Stuart Bishop (stub) wrote :

I don't think it is possible to get a None value with current juju and the corrected config.yaml, because the type is int and Juju enforces this. But better safe than sorry.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/config.yaml b/config.yaml
2index 94daff9..1c5565a 100644
3--- a/config.yaml
4+++ b/config.yaml
5@@ -170,7 +170,7 @@ options:
6 You need enough space for this many backups plus one more, as
7 an old backup will only be removed after a new one has been
8 successfully made to replace it.
9- wal_e_backup_stale_warn_threshold:
10+ wal_e_backup_stale_crit_threshold:
11 type: int
12 default: 300
13 description: >
14diff --git a/reactive/postgresql/nagios.py b/reactive/postgresql/nagios.py
15index 7fe3134..415e687 100644
16--- a/reactive/postgresql/nagios.py
17+++ b/reactive/postgresql/nagios.py
18@@ -126,13 +126,19 @@ def update_nrpe_config():
19 user='postgres', group='postgres')
20
21 # retrieve the threshold values from the charm config
22- check_warn_threshold = helpers.config_yaml().get(
23+ check_warn_threshold = hookenv.config().get(
24 'wal_e_backup_stale_warn_threshold'
25 )
26- check_crit_threshold = helpers.config_yaml().get(
27+ check_crit_threshold = hookenv.config().get(
28 'wal_e_backup_stale_crit_threshold'
29 )
30
31+ # deal with empty stale backup thresholds
32+ if check_crit_threshold is None:
33+ check_crit_threshold = 300
34+ if check_warn_threshold is None:
35+ check_warn_threshold = 600
36+
37 # create the cron job to run the above
38 check_cron = "*/2 * * * * postgres {}".format(check_script_path)
39 check_cron_path = '/etc/cron.d/postgres-stale-wal-e-check'

Subscribers

People subscribed via source and target branches

to all changes: