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
diff --git a/reactive/mailman3_core.py b/reactive/mailman3_core.py
index da3c707..4b870ba 100644
--- a/reactive/mailman3_core.py
+++ b/reactive/mailman3_core.py
@@ -55,6 +55,7 @@ def initial_setup():
55@when('apt.installed.postfix')55@when('apt.installed.postfix')
56@when_not('mailman.postfix.configured')56@when_not('mailman.postfix.configured')
57def configure_postfix():57def configure_postfix():
58 clear_flag('mailman3-core.active')
58 config = hookenv.config()59 config = hookenv.config()
59 hookenv.status_set('maintenance', 'configuring postfix for posts to mailing lists')60 hookenv.status_set('maintenance', 'configuring postfix for posts to mailing lists')
6061
@@ -125,7 +126,25 @@ def configure_postfix():
125 # Open the SMTP port126 # Open the SMTP port
126 hookenv.open_port(25)127 hookenv.open_port(25)
127 set_flag('mailman.postfix.configured')128 set_flag('mailman.postfix.configured')
128 hookenv.status_set('active', 'ready')129
130
131@when('mailman.postfix.configured')
132@when_not('mailman3-core.active')
133def set_active(version_file='version'):
134 revision = ''
135 if os.path.exists(version_file):
136 with open(version_file) as f:
137 line = f.readline().strip()
138 # We only want the first 10 characters, that's enough to tell
139 # which version of the charm we're using. But include the
140 # entire version if it's 'dirty' according to charm build.
141 if len(line) > 10 and not line.endswith('-dirty'):
142 revision = ' (source version/commit {}…)'.format(line[:10])
143 else:
144 revision = ' (source version/commit {})'.format(line)
145
146 hookenv.status.active('Ready{}'.format(revision))
147 set_flag('mailman3-core.active')
129148
130149
131# Configure smtpd_recipient_restrictions depending on if SPF is enabled150# Configure smtpd_recipient_restrictions depending on if SPF is enabled
@@ -243,10 +262,10 @@ def configure_database(pgsql):
243@when('db.master.available')262@when('db.master.available')
244@when('config.changed')263@when('config.changed')
245def write_updated_config():264def write_updated_config():
265 clear_flag('mailman3-core.active')
246 hookenv.status_set('maintenance', 'updating configuration')266 hookenv.status_set('maintenance', 'updating configuration')
247 clear_flag('mailman.postfix.configured')267 clear_flag('mailman.postfix.configured')
248 write_config()268 write_config()
249 hookenv.status_set('active', 'ready')
250269
251270
252# Make sure we've got our REST API creds, then publish our relation data.271# Make sure we've got our REST API creds, then publish our relation data.
@@ -316,6 +335,7 @@ def setup_nagios(nagios):
316 if hookenv.hook_name() == 'update-status':335 if hookenv.hook_name() == 'update-status':
317 return336 return
318337
338 clear_flag('mailman3-core.active')
319 hookenv.status_set('maintenance', 'setting up NRPE checks')339 hookenv.status_set('maintenance', 'setting up NRPE checks')
320 # Ask charmhelpers.contrib.charmsupport's nrpe to work out our hostname340 # Ask charmhelpers.contrib.charmsupport's nrpe to work out our hostname
321 hostname = nrpe.get_nagios_hostname()341 hostname = nrpe.get_nagios_hostname()
@@ -339,7 +359,6 @@ def setup_nagios(nagios):
339 nrpe_setup.add_check('postfix_port', 'Check postfix port', postfix_check)359 nrpe_setup.add_check('postfix_port', 'Check postfix port', postfix_check)
340360
341 nrpe_setup.write()361 nrpe_setup.write()
342 hookenv.status_set('active', 'ready')
343362
344363
345def systemctl(action, service_name):364def systemctl(action, service_name):

Subscribers

People subscribed via source and target branches