Merge ~hloeung/content-cache-charm:master into content-cache-charm:master

Proposed by Haw Loeung
Status: Merged
Approved by: Haw Loeung
Approved revision: 545798c4a15626b24ceb2c1aa8c59e56f4e2d509
Merged at revision: e586a2c5e21d3cc2bfac5a40e1e40a28bb56895f
Proposed branch: ~hloeung/content-cache-charm:master
Merge into: content-cache-charm:master
Diff against target: 65 lines (+25/-3)
4 files modified
reactive/content_cache.py (+13/-2)
tests/unit/files/version (+1/-0)
tests/unit/files/version2 (+1/-0)
tests/unit/test_content_cache.py (+10/-1)
Reviewer Review Type Date Requested Status
Tom Haddon Approve
Haw Loeung Needs Resubmitting
Review via email: mp+397395@code.launchpad.net

Commit message

Add showing charm revno/commit in juju status output

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
Tom Haddon (mthaddon) wrote :

This feels pretty cryptic. I know we're trying to keep the status message short - do we have any constraints there? How do communicate to the charm operator what `Ready (uax4glw)` means?

Revision history for this message
Haw Loeung (hloeung) wrote :

> This feels pretty cryptic. I know we're trying to keep the status message
> short - do we have any constraints there? How do communicate to the charm
> operator what `Ready (uax4glw)` means?

Fixed to make it less cryptic - `Ready (charm source version/commit uax4glw)`.

review: Needs Resubmitting
Revision history for this message
Tom Haddon (mthaddon) wrote :

LGTM, I'd say optionally you can go with "Ready (source version/commit uax4glw)" but either way looks good to me.

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

Change successfully merged at revision e586a2c5e21d3cc2bfac5a40e1e40a28bb56895f

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/reactive/content_cache.py b/reactive/content_cache.py
2index bd4a5e1..ec681d6 100644
3--- a/reactive/content_cache.py
4+++ b/reactive/content_cache.py
5@@ -60,9 +60,20 @@ def config_changed():
6
7 @reactive.when('content_cache.haproxy.configured', 'content_cache.nginx.configured', 'content_cache.sysctl.configured')
8 @reactive.when_not('content_cache.active')
9-def set_active():
10+def set_active(version_file='version'):
11 # XXX: Add more info such as nginx and haproxy status
12- status.active('ready')
13+
14+ revision = ''
15+ if os.path.exists(version_file):
16+ with open(version_file) as f:
17+ line = f.readline().strip()
18+ # We only want the first 8 characters, that's enough to tell
19+ # which version of the charm we're using.
20+ if len(line) > 8:
21+ revision = ' (source version/commit {}…)'.format(line[:8])
22+ else:
23+ revision = ' (source version/commit {})'.format(line)
24+ status.active('Ready{}'.format(revision))
25 reactive.set_flag('content_cache.active')
26
27
28diff --git a/tests/unit/files/version b/tests/unit/files/version
29new file mode 100644
30index 0000000..e3b1554
31--- /dev/null
32+++ b/tests/unit/files/version
33@@ -0,0 +1 @@
34+uax4glw
35diff --git a/tests/unit/files/version2 b/tests/unit/files/version2
36new file mode 100644
37index 0000000..7b14704
38--- /dev/null
39+++ b/tests/unit/files/version2
40@@ -0,0 +1 @@
41+somerandomcommitid
42diff --git a/tests/unit/test_content_cache.py b/tests/unit/test_content_cache.py
43index 6f52f08..d8300a9 100644
44--- a/tests/unit/test_content_cache.py
45+++ b/tests/unit/test_content_cache.py
46@@ -143,9 +143,18 @@ class TestCharm(unittest.TestCase):
47 @mock.patch('charms.reactive.set_flag')
48 def test_hook_set_active(self, set_flag):
49 content_cache.set_active()
50- status.active.assert_called()
51+ status.active.assert_called_once_with('Ready')
52 set_flag.assert_called_once_with('content_cache.active')
53
54+ status.active.reset_mock()
55+ # git - "uax4glw"
56+ content_cache.set_active(os.path.join(self.charm_dir, 'tests/unit/files/version'))
57+ status.active.assert_called_once_with('Ready (source version/commit uax4glw)')
58+
59+ status.active.reset_mock()
60+ content_cache.set_active(os.path.join(self.charm_dir, 'tests/unit/files/version2'))
61+ status.active.assert_called_once_with('Ready (source version/commit somerand…)')
62+
63 @mock.patch('charmhelpers.core.host.service_running')
64 @mock.patch('charmhelpers.core.host.service_reload')
65 @mock.patch('charmhelpers.core.host.service_start')

Subscribers

People subscribed via source and target branches