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
=== modified file 'hooks/hooks.py'
--- hooks/hooks.py 2014-06-05 12:32:17 +0000
+++ hooks/hooks.py 2014-06-30 13:36:25 +0000
@@ -1011,6 +1011,12 @@
1011 os.path.join(postgresql_scripts_dir, 'pg_backup_job'),1011 os.path.join(postgresql_scripts_dir, 'pg_backup_job'),
1012 backup_job, perms=0755)1012 backup_job, perms=0755)
1013 install_postgresql_crontab(postgresql_crontab)1013 install_postgresql_crontab(postgresql_crontab)
1014
1015 # Create this empty log file on installation to avoid triggering
1016 # spurious monitoring system alerts, per Bug #1329816.
1017 if not os.path.exists(backup_log):
1018 host.write_file(backup_log, '', 'postgres', 'postgres', 0664)
1019
1014 hookenv.open_port(get_service_port())1020 hookenv.open_port(get_service_port())
10151021
1016 # Ensure at least minimal access granted for hooks to run.1022 # Ensure at least minimal access granted for hooks to run.
@@ -2202,7 +2208,6 @@
2202 .format(get_service_port()))2208 .format(get_service_port()))
2203 # pgsql backups2209 # pgsql backups
2204 nrpe_check_file = '/etc/nagios/nrpe.d/check_pgsql_backups.cfg'2210 nrpe_check_file = '/etc/nagios/nrpe.d/check_pgsql_backups.cfg'
2205 backup_log = "{}/backups.log".format(postgresql_logs_dir)
2206 # XXX: these values _should_ be calculated from the backup schedule2211 # XXX: these values _should_ be calculated from the backup schedule
2207 # perhaps warn = backup_frequency * 1.5, crit = backup_frequency * 22212 # perhaps warn = backup_frequency * 1.5, crit = backup_frequency * 2
2208 warn_age = 1728002213 warn_age = 172800
@@ -2331,6 +2336,8 @@
2331juju_log_dir = "/var/log/juju"2336juju_log_dir = "/var/log/juju"
2332external_volume_mount = "/srv/data"2337external_volume_mount = "/srv/data"
23332338
2339backup_log = os.path.join(postgresql_logs_dir, "backups.log")
2340
23342341
2335if __name__ == '__main__':2342if __name__ == '__main__':
2336 # Hook and context overview. The various replication and client2343 # Hook and context overview. The various replication and client

Subscribers

People subscribed via source and target branches