Merge lp:~stub/charms/precise/postgresql/bug-1329816-backup-log-spurious-alert into lp:charms/postgresql

Proposed by Stuart Bishop
Status: Merged
Merged at revision: 101
Proposed branch: lp:~stub/charms/precise/postgresql/bug-1329816-backup-log-spurious-alert
Merge into: lp:charms/postgresql
Prerequisite: lp:~stub/charms/precise/postgresql/tests
Diff against target: 33 lines (+8/-1)
1 file modified
hooks/hooks.py (+8/-1)
To merge this branch: bzr merge lp:~stub/charms/precise/postgresql/bug-1329816-backup-log-spurious-alert
Reviewer Review Type Date Requested Status
Michael Nelson (community) Approve
Review via email: mp+223210@code.launchpad.net

Description of the change

The backup log file does not exist until the first backup runs, causing a spurious nagios alert on a freshly deployed service.

This branch ensures the log file is created on initial installation.

To post a comment you must log in.
Revision history for this message
Michael Nelson (michael.nelson) wrote :

Excellent - thanks Stuart!

review: Approve
142. By Stuart Bishop

revert unnecessary whitespace change

143. By Stuart Bishop

Merged tests into bug-1329816-backup-log-spurious-alert.

144. By Stuart Bishop

Merged tests into bug-1329816-backup-log-spurious-alert.

145. By Stuart Bishop

Merged tests into bug-1329816-backup-log-spurious-alert.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/hooks.py'
2--- hooks/hooks.py 2014-06-05 12:32:17 +0000
3+++ hooks/hooks.py 2014-06-30 13:36:25 +0000
4@@ -1011,6 +1011,12 @@
5 os.path.join(postgresql_scripts_dir, 'pg_backup_job'),
6 backup_job, perms=0755)
7 install_postgresql_crontab(postgresql_crontab)
8+
9+ # Create this empty log file on installation to avoid triggering
10+ # spurious monitoring system alerts, per Bug #1329816.
11+ if not os.path.exists(backup_log):
12+ host.write_file(backup_log, '', 'postgres', 'postgres', 0664)
13+
14 hookenv.open_port(get_service_port())
15
16 # Ensure at least minimal access granted for hooks to run.
17@@ -2202,7 +2208,6 @@
18 .format(get_service_port()))
19 # pgsql backups
20 nrpe_check_file = '/etc/nagios/nrpe.d/check_pgsql_backups.cfg'
21- backup_log = "{}/backups.log".format(postgresql_logs_dir)
22 # XXX: these values _should_ be calculated from the backup schedule
23 # perhaps warn = backup_frequency * 1.5, crit = backup_frequency * 2
24 warn_age = 172800
25@@ -2331,6 +2336,8 @@
26 juju_log_dir = "/var/log/juju"
27 external_volume_mount = "/srv/data"
28
29+backup_log = os.path.join(postgresql_logs_dir, "backups.log")
30+
31
32 if __name__ == '__main__':
33 # Hook and context overview. The various replication and client

Subscribers

People subscribed via source and target branches