Merge charm-juju-controller:bug/1922292 into charm-juju-controller:master

Proposed by Adam Dyess
Status: Merged
Approved by: Xav Paice
Approved revision: b440406a08f930c8fd55d2a0d92f4b26b75d3a16
Merged at revision: a49a21f0cba41f349c6a52ea1703a7c91cef90c5
Proposed branch: charm-juju-controller:bug/1922292
Merge into: charm-juju-controller:master
Diff against target: 60 lines (+20/-3)
2 files modified
src/lib/lib_juju_controller.py (+5/-1)
src/tests/unit/test_lib_juju_controller.py (+15/-2)
Reviewer Review Type Date Requested Status
Xav Paice (community) Approve
🤖 prod-jenkaas-bootstack (community) continuous-integration Approve
Paul Goins Approve
Review via email: mp+406258@code.launchpad.net

Commit message

Add Monitoring for juju-db installed by snap

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
Paul Goins (vultaire) wrote :

LGTM, +1

review: Approve
Revision history for this message
Xav Paice (xavpaice) wrote :

Fails lint, unfortunately. I've put the lint differences inline.

I'll work on getting this into CI shortly.

review: Needs Fixing
Revision history for this message
🤖 prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote :

A CI job is currently in progress. A follow up comment will be added when it completes.

Revision history for this message
🤖 prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
🤖 prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote :

A CI job is currently in progress. A follow up comment will be added when it completes.

Revision history for this message
🤖 prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote :
review: Approve (continuous-integration)
Revision history for this message
Xav Paice (xavpaice) wrote :

LGTM

review: Approve
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Change successfully merged at revision a49a21f0cba41f349c6a52ea1703a7c91cef90c5

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/lib/lib_juju_controller.py b/src/lib/lib_juju_controller.py
2index 6432c3c..08eb0b7 100644
3--- a/src/lib/lib_juju_controller.py
4+++ b/src/lib/lib_juju_controller.py
5@@ -11,6 +11,7 @@ import yaml
6 AGENTDIRGLOB = "/var/lib/juju/agents/machine-*"
7 CACERTPATH = "/run/juju-controller-ca.crt"
8 PUBAGENTCONFPATH = "/run/juju-controller-public-agent.conf"
9+SNAP_JUJU_DB_SVC = "/etc/systemd/system/snap.juju-db.daemon.service"
10
11
12 class JujuControllerHelper:
13@@ -55,7 +56,10 @@ class JujuControllerHelper:
14 @property
15 def services(self):
16 """Return the list of juju services on this machine."""
17- return ["juju-db", "jujud-machine-{}".format(self._machine_id())]
18+ return [
19+ "snap.juju-db.daemon" if os.path.exists(SNAP_JUJU_DB_SVC) else "juju-db",
20+ "jujud-machine-{}".format(self._machine_id()),
21+ ]
22
23 @property
24 def agent_conf_path(self):
25diff --git a/src/tests/unit/test_lib_juju_controller.py b/src/tests/unit/test_lib_juju_controller.py
26index 03bae5b..a40ddd0 100644
27--- a/src/tests/unit/test_lib_juju_controller.py
28+++ b/src/tests/unit/test_lib_juju_controller.py
29@@ -1,6 +1,8 @@
30 #!/usr/bin/python3
31 """Pytest test cases for lib_juju_controller.py."""
32
33+import mock
34+
35 EXPECTED = {
36 "machine-id": "99",
37 "services": ["juju-db", "jujud-machine-99"],
38@@ -44,9 +46,20 @@ class TestJujuControllerLib:
39 """Test parsing the machine id."""
40 assert jujucontroller._machine_id() == EXPECTED["machine-id"]
41
42- def test_services(self, jujucontroller):
43+ def test_services_snap(self, jujucontroller):
44+ """Test collecting all juju services."""
45+ with mock.patch("os.path.exists", autospec=True) as path_exists:
46+ path_exists.return_value = True
47+ expected = list(EXPECTED["services"])
48+ expected.remove("juju-db")
49+ expected.insert(0, "snap.juju-db.daemon")
50+ assert jujucontroller.services == expected
51+
52+ def test_services_apt(self, jujucontroller):
53 """Test collecting all juju services."""
54- assert jujucontroller.services == EXPECTED["services"]
55+ with mock.patch("os.path.exists", autospec=True) as path_exists:
56+ path_exists.return_value = False
57+ assert jujucontroller.services == EXPECTED["services"]
58
59 def test_version(self, jujucontroller):
60 """Test reporting the controller version."""

Subscribers

No one subscribed via source and target branches