Merge ~hloeung/mailman3-core-charm:fixes into mailman3-core-charm:master

Proposed by Haw Loeung
Status: Merged
Approved by: Haw Loeung
Approved revision: bd09fa9b9a7b640489502024e605abddbb4537d5
Merged at revision: 753210244a0b27fa5849bb4a451bbc759604816b
Proposed branch: ~hloeung/mailman3-core-charm:fixes
Merge into: mailman3-core-charm:master
Diff against target: 67 lines (+22/-3)
1 file modified
reactive/mailman3_core.py (+22/-3)
Reviewer Review Type Date Requested Status
🤖 Canonical IS Review Bot Approve
Canonical IS Reviewers Pending
Mailman3 charm maintainers Pending
Review via email: mp+449673@code.launchpad.net

Commit message

Fix setting of active status so it's not stuck with stale/old status; also include commit/revision in status msg

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
🤖 Canonical IS Review Bot (canonical-is-reviewbot) wrote :

Proxy approval for jsimpso

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

Change successfully merged at revision 753210244a0b27fa5849bb4a451bbc759604816b

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/reactive/mailman3_core.py b/reactive/mailman3_core.py
2index da3c707..4b870ba 100644
3--- a/reactive/mailman3_core.py
4+++ b/reactive/mailman3_core.py
5@@ -55,6 +55,7 @@ def initial_setup():
6 @when('apt.installed.postfix')
7 @when_not('mailman.postfix.configured')
8 def configure_postfix():
9+ clear_flag('mailman3-core.active')
10 config = hookenv.config()
11 hookenv.status_set('maintenance', 'configuring postfix for posts to mailing lists')
12
13@@ -125,7 +126,25 @@ def configure_postfix():
14 # Open the SMTP port
15 hookenv.open_port(25)
16 set_flag('mailman.postfix.configured')
17- hookenv.status_set('active', 'ready')
18+
19+
20+@when('mailman.postfix.configured')
21+@when_not('mailman3-core.active')
22+def set_active(version_file='version'):
23+ revision = ''
24+ if os.path.exists(version_file):
25+ with open(version_file) as f:
26+ line = f.readline().strip()
27+ # We only want the first 10 characters, that's enough to tell
28+ # which version of the charm we're using. But include the
29+ # entire version if it's 'dirty' according to charm build.
30+ if len(line) > 10 and not line.endswith('-dirty'):
31+ revision = ' (source version/commit {}…)'.format(line[:10])
32+ else:
33+ revision = ' (source version/commit {})'.format(line)
34+
35+ hookenv.status.active('Ready{}'.format(revision))
36+ set_flag('mailman3-core.active')
37
38
39 # Configure smtpd_recipient_restrictions depending on if SPF is enabled
40@@ -243,10 +262,10 @@ def configure_database(pgsql):
41 @when('db.master.available')
42 @when('config.changed')
43 def write_updated_config():
44+ clear_flag('mailman3-core.active')
45 hookenv.status_set('maintenance', 'updating configuration')
46 clear_flag('mailman.postfix.configured')
47 write_config()
48- hookenv.status_set('active', 'ready')
49
50
51 # Make sure we've got our REST API creds, then publish our relation data.
52@@ -316,6 +335,7 @@ def setup_nagios(nagios):
53 if hookenv.hook_name() == 'update-status':
54 return
55
56+ clear_flag('mailman3-core.active')
57 hookenv.status_set('maintenance', 'setting up NRPE checks')
58 # Ask charmhelpers.contrib.charmsupport's nrpe to work out our hostname
59 hostname = nrpe.get_nagios_hostname()
60@@ -339,7 +359,6 @@ def setup_nagios(nagios):
61 nrpe_setup.add_check('postfix_port', 'Check postfix port', postfix_check)
62
63 nrpe_setup.write()
64- hookenv.status_set('active', 'ready')
65
66
67 def systemctl(action, service_name):

Subscribers

People subscribed via source and target branches