Merge ~hloeung/mailman3-web-charm:master into mailman3-web-charm:master

Proposed by Haw Loeung
Status: Merged
Approved by: Tom Haddon
Approved revision: 0b77c8da35ece48426edf7c47ca6a1803af5fd07
Merged at revision: 3379dc14e60412773330e637bc7093c3f92f780a
Proposed branch: ~hloeung/mailman3-web-charm:master
Merge into: mailman3-web-charm:master
Diff against target: 71 lines (+15/-6)
2 files modified
layer.yaml (+3/-2)
reactive/mailman3_web.py (+12/-4)
Reviewer Review Type Date Requested Status
Tom Haddon Approve
Review via email: mp+346440@code.launchpad.net

Commit message

Set proper status - LP: #1772398

Description of the change

Set proper status - LP: #1772398

Also only generate django and hyperkitty secret keys when they don't
already exist.

Finally, don't run changed_mailman_data() on update-status hooks
firing.

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 :

LGTM

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

Change successfully merged at revision 3379dc14e60412773330e637bc7093c3f92f780a

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/layer.yaml b/layer.yaml
2index c55fa06..018b1ab 100644
3--- a/layer.yaml
4+++ b/layer.yaml
5@@ -1,9 +1,10 @@
6 repo: lp:mailman3-web-charm
7 includes:
8+ - 'layer:basic'
9+ - 'layer:apt'
10 - 'interface:generic-ip-port-user-pass'
11+ - 'interface:nrpe-external-master'
12 - 'interface:pgsql'
13- - 'layer:apt'
14- - 'layer:basic'
15 options:
16 apt:
17 packages:
18diff --git a/reactive/mailman3_web.py b/reactive/mailman3_web.py
19index c7880b1..400d459 100644
20--- a/reactive/mailman3_web.py
21+++ b/reactive/mailman3_web.py
22@@ -32,10 +32,12 @@ def write_config():
23 def initial_setup():
24 db = unitdata.kv()
25 chars = string.ascii_letters + string.digits
26- django_secret_key = ''.join((random.choice(chars)) for x in range(40))
27- hyperkitty_archiver_key = ''.join((random.choice(chars)) for x in range(40))
28- db.set('django_archiver_key', hyperkitty_archiver_key)
29- db.set('django_secret_key', django_secret_key)
30+ if not db.get('django_secret_key'):
31+ django_secret_key = ''.join((random.choice(chars)) for x in range(40))
32+ db.set('django_secret_key', django_secret_key)
33+ if not db.get('django_archiver_key'):
34+ hyperkitty_archiver_key = ''.join((random.choice(chars)) for x in range(40))
35+ db.set('django_archiver_key', hyperkitty_archiver_key)
36 db.set('archiver_ip', hookenv.unit_get('private-address'))
37 set_flag('mailman.configured')
38
39@@ -47,6 +49,7 @@ def initial_setup():
40 @when('apt.installed.apache2')
41 @when_not('mailman.apache.configured')
42 def configure_apache2():
43+ hookenv.status_set('maintenance', 'updating apache2 configuration')
44 render(source="mailman-apache.tmpl",
45 target="/etc/apache2/conf-available/mailman.conf",
46 context={})
47@@ -70,6 +73,7 @@ def configure_apache2():
48 # do SSL termination in front of this.
49 hookenv.open_port(80)
50 set_flag('mailman.apache.configured')
51+ hookenv.status_set('active', 'ready')
52
53
54 # Ask postgresql to create our DB.
55@@ -98,7 +102,9 @@ def configure_database(pgsql):
56 @when('db.master.available')
57 @when('config.changed')
58 def write_updated_config():
59+ hookenv.status_set('maintenance', 'updating configuration')
60 write_config()
61+ hookenv.status_set('active', 'ready')
62
63
64 # We're providing a website relation to whatever does SSL termination in front
65@@ -164,6 +170,8 @@ def clear_mailman3_relation():
66
67 @when_any('endpoint.mailman3.connected')
68 def changed_mailman_data():
69+ if hookenv.hook_name() == 'update-status':
70+ return
71 clear_flag('mailman3.relation.configured')
72
73

Subscribers

People subscribed via source and target branches