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 Merge Bot (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 Merge Bot (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 Merge Bot (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 Merge Bot (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
diff --git a/hooks/upgrade_charm.py b/hooks/upgrade_charm.py
index 4152e53..91b4b69 100755
--- a/hooks/upgrade_charm.py
+++ b/hooks/upgrade_charm.py
@@ -171,32 +171,33 @@ def fixpath(path):
171171
172172
173def enable_livestatus_config():173def enable_livestatus_config():
174 if enable_livestatus:174 livestatus_dir = os.path.dirname(livestatus_path)
175 hookenv.log("Livestatus is enabled")175 hookenv.log("Livestatus is enabled")
176 fetch.apt_update()176 if not os.path.isdir(livestatus_dir):
177 fetch.apt_install("check-mk-livestatus")177 hookenv.log("Making path for livestatus_dir")
178178 mkdir_p(livestatus_dir)
179 # Make the directory and fix perms on it179 # fix perms on livestatus dir
180 hookenv.log("Fixing perms on livestatus_path")180 hookenv.log("Fixing perms on livestatus_path")
181 livestatus_dir = os.path.dirname(livestatus_path)181 fixpath(livestatus_dir)
182182 fetch.apt_update()
183 if not os.path.isdir(livestatus_dir):183 missing_packages = fetch.filter_installed_packages(["check-mk-livestatus"])
184 hookenv.log("Making path for livestatus_dir")184 if missing_packages:
185 mkdir_p(livestatus_dir)185 fetch.apt_install(missing_packages)
186 fixpath(livestatus_dir)186 # This needs a nagios restart to actually make the socket
187187 host.service_reload("nagios3")
188 # Fix the perms on the socket188
189 hookenv.log("Fixing perms on the socket")189 # Fix the perms on the socket
190 uid = pwd.getpwnam(nagios_user).pw_uid190 hookenv.log("Fixing perms on the socket")
191 gid = grp.getgrnam("www-data").gr_gid191 uid = pwd.getpwnam(nagios_user).pw_uid
192 os.chown(livestatus_path, uid, gid)192 gid = grp.getgrnam("www-data").gr_gid
193 os.chown(livestatus_dir, uid, gid)193 os.chown(livestatus_path, uid, gid)
194 st = os.stat(livestatus_path)194 os.chown(livestatus_dir, uid, gid)
195 os.chmod(livestatus_path, st.st_mode | stat.S_IRGRP)195 st = os.stat(livestatus_path)
196 os.chmod(196 os.chmod(livestatus_path, st.st_mode | stat.S_IRGRP)
197 livestatus_dir,197 os.chmod(
198 st.st_mode | stat.S_IRGRP | stat.S_ISGID | stat.S_IXUSR | stat.S_IXGRP,198 livestatus_dir,
199 )199 st.st_mode | stat.S_IRGRP | stat.S_ISGID | stat.S_IXUSR | stat.S_IXGRP,
200 )
200201
201202
202def enable_pagerduty_config():203def enable_pagerduty_config():
@@ -627,7 +628,6 @@ if ssl_configured():
627enable_pagerduty_config()628enable_pagerduty_config()
628update_contacts()629update_contacts()
629update_config()630update_config()
630enable_livestatus_config()
631update_apache()631update_apache()
632update_localhost()632update_localhost()
633update_cgi_config()633update_cgi_config()
@@ -639,6 +639,8 @@ if password:
639639
640if nagiosadmin != "nagiosadmin":640if nagiosadmin != "nagiosadmin":
641 update_password("nagiosadmin", False)641 update_password("nagiosadmin", False)
642if enable_livestatus:
643 enable_livestatus_config()
642644
643subprocess.call(["scripts/postfix_loopback_only.sh"])645subprocess.call(["scripts/postfix_loopback_only.sh"])
644subprocess.call(["hooks/mymonitors-relation-joined"])646subprocess.call(["hooks/mymonitors-relation-joined"])

Subscribers

People subscribed via source and target branches

to all changes: