Merge ~afreiberger/charm-nagios:bug/1819537 into charm-nagios:master

Proposed by Drew Freiberger
Status: Merged
Merged at revision: a715bfeae4da12644fc7475f551f701077487bf7
Proposed branch: ~afreiberger/charm-nagios:bug/1819537
Merge into: charm-nagios:master
Diff against target: 81 lines (+29/-27)
1 file modified
hooks/upgrade_charm.py (+29/-27)
Reviewer Review Type Date Requested Status
Drew Freiberger (community) Approve
James Hebden Pending
Joe Guo Pending
Review via email: mp+393049@code.launchpad.net

This proposal supersedes a proposal from 2020-10-01.

Commit message

Add restart after livestatus installation

Restarts Nagios after installing mklivestatus so that the socket gets created.

Fixes-bug: LP: #1819537

To post a comment you must log in.
Revision history for this message
Joe Guo (guoqiao) wrote : Posted in a previous version of this proposal

2 inline comments, only the 2nd one matters.

review: Needs Fixing
Revision history for this message
Xav Paice (xavpaice) wrote : Posted in a previous version of this proposal

Thanks for that, have updated and am re-running functional testing now.

I'm concerned that a glaring hole like not installing the package didn't get pulled up by functests, might need to add a bug for that.

Revision history for this message
Xav Paice (xavpaice) wrote : Posted in a previous version of this proposal

Ah... the functest has enable livestatus enabled at install, and hooks/install does the package install for that.

Revision history for this message
Joe Guo (guoqiao) wrote : Posted in a previous version of this proposal

LGTM, +1.

review: Approve
Revision history for this message
James Hebden (ec0) wrote : Posted in a previous version of this proposal

LGTM, +1

review: Approve
Revision history for this message
Canonical IS Mergebot (canonical-is-mergebot) wrote : Posted in a previous version of this proposal

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

Revision history for this message
Canonical IS Mergebot (canonical-is-mergebot) wrote : Posted in a previous version of this proposal

Unable to determine commit message from repository - please click "Set commit message" and enter the commit message manually.

Revision history for this message
Canonical IS Mergebot (canonical-is-mergebot) wrote : Posted in a previous version of this proposal

Change has no commit message, setting status to needs review.

Revision history for this message
Canonical IS Mergebot (canonical-is-mergebot) wrote : Posted in a previous version of this proposal

Change successfully merged at revision 2b3fdea5aa0aa1c6cccb89d0f18b8b226ea593ea

Revision history for this message
Drew Freiberger (afreiberger) wrote :

This was merged to the wrong master branch. resubmit under ~llama-charmers

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/hooks/upgrade_charm.py b/hooks/upgrade_charm.py
2index 4152e53..91b4b69 100755
3--- a/hooks/upgrade_charm.py
4+++ b/hooks/upgrade_charm.py
5@@ -171,32 +171,33 @@ def fixpath(path):
6
7
8 def enable_livestatus_config():
9- if enable_livestatus:
10- hookenv.log("Livestatus is enabled")
11- fetch.apt_update()
12- fetch.apt_install("check-mk-livestatus")
13-
14- # Make the directory and fix perms on it
15- hookenv.log("Fixing perms on livestatus_path")
16- livestatus_dir = os.path.dirname(livestatus_path)
17-
18- if not os.path.isdir(livestatus_dir):
19- hookenv.log("Making path for livestatus_dir")
20- mkdir_p(livestatus_dir)
21- fixpath(livestatus_dir)
22-
23- # Fix the perms on the socket
24- hookenv.log("Fixing perms on the socket")
25- uid = pwd.getpwnam(nagios_user).pw_uid
26- gid = grp.getgrnam("www-data").gr_gid
27- os.chown(livestatus_path, uid, gid)
28- os.chown(livestatus_dir, uid, gid)
29- st = os.stat(livestatus_path)
30- os.chmod(livestatus_path, st.st_mode | stat.S_IRGRP)
31- os.chmod(
32- livestatus_dir,
33- st.st_mode | stat.S_IRGRP | stat.S_ISGID | stat.S_IXUSR | stat.S_IXGRP,
34- )
35+ livestatus_dir = os.path.dirname(livestatus_path)
36+ hookenv.log("Livestatus is enabled")
37+ if not os.path.isdir(livestatus_dir):
38+ hookenv.log("Making path for livestatus_dir")
39+ mkdir_p(livestatus_dir)
40+ # fix perms on livestatus dir
41+ hookenv.log("Fixing perms on livestatus_path")
42+ fixpath(livestatus_dir)
43+ fetch.apt_update()
44+ missing_packages = fetch.filter_installed_packages(["check-mk-livestatus"])
45+ if missing_packages:
46+ fetch.apt_install(missing_packages)
47+ # This needs a nagios restart to actually make the socket
48+ host.service_reload("nagios3")
49+
50+ # Fix the perms on the socket
51+ hookenv.log("Fixing perms on the socket")
52+ uid = pwd.getpwnam(nagios_user).pw_uid
53+ gid = grp.getgrnam("www-data").gr_gid
54+ os.chown(livestatus_path, uid, gid)
55+ os.chown(livestatus_dir, uid, gid)
56+ st = os.stat(livestatus_path)
57+ os.chmod(livestatus_path, st.st_mode | stat.S_IRGRP)
58+ os.chmod(
59+ livestatus_dir,
60+ st.st_mode | stat.S_IRGRP | stat.S_ISGID | stat.S_IXUSR | stat.S_IXGRP,
61+ )
62
63
64 def enable_pagerduty_config():
65@@ -627,7 +628,6 @@ if ssl_configured():
66 enable_pagerduty_config()
67 update_contacts()
68 update_config()
69-enable_livestatus_config()
70 update_apache()
71 update_localhost()
72 update_cgi_config()
73@@ -639,6 +639,8 @@ if password:
74
75 if nagiosadmin != "nagiosadmin":
76 update_password("nagiosadmin", False)
77+if enable_livestatus:
78+ enable_livestatus_config()
79
80 subprocess.call(["scripts/postfix_loopback_only.sh"])
81 subprocess.call(["hooks/mymonitors-relation-joined"])

Subscribers

People subscribed via source and target branches