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
diff --git a/layer.yaml b/layer.yaml
index c55fa06..018b1ab 100644
--- a/layer.yaml
+++ b/layer.yaml
@@ -1,9 +1,10 @@
1repo: lp:mailman3-web-charm1repo: lp:mailman3-web-charm
2includes:2includes:
3 - 'layer:basic'
4 - 'layer:apt'
3 - 'interface:generic-ip-port-user-pass'5 - 'interface:generic-ip-port-user-pass'
6 - 'interface:nrpe-external-master'
4 - 'interface:pgsql'7 - 'interface:pgsql'
5 - 'layer:apt'
6 - 'layer:basic'
7options:8options:
8 apt:9 apt:
9 packages:10 packages:
diff --git a/reactive/mailman3_web.py b/reactive/mailman3_web.py
index c7880b1..400d459 100644
--- a/reactive/mailman3_web.py
+++ b/reactive/mailman3_web.py
@@ -32,10 +32,12 @@ def write_config():
32def initial_setup():32def initial_setup():
33 db = unitdata.kv()33 db = unitdata.kv()
34 chars = string.ascii_letters + string.digits34 chars = string.ascii_letters + string.digits
35 django_secret_key = ''.join((random.choice(chars)) for x in range(40))35 if not db.get('django_secret_key'):
36 hyperkitty_archiver_key = ''.join((random.choice(chars)) for x in range(40))36 django_secret_key = ''.join((random.choice(chars)) for x in range(40))
37 db.set('django_archiver_key', hyperkitty_archiver_key)37 db.set('django_secret_key', django_secret_key)
38 db.set('django_secret_key', django_secret_key)38 if not db.get('django_archiver_key'):
39 hyperkitty_archiver_key = ''.join((random.choice(chars)) for x in range(40))
40 db.set('django_archiver_key', hyperkitty_archiver_key)
39 db.set('archiver_ip', hookenv.unit_get('private-address'))41 db.set('archiver_ip', hookenv.unit_get('private-address'))
40 set_flag('mailman.configured')42 set_flag('mailman.configured')
4143
@@ -47,6 +49,7 @@ def initial_setup():
47@when('apt.installed.apache2')49@when('apt.installed.apache2')
48@when_not('mailman.apache.configured')50@when_not('mailman.apache.configured')
49def configure_apache2():51def configure_apache2():
52 hookenv.status_set('maintenance', 'updating apache2 configuration')
50 render(source="mailman-apache.tmpl",53 render(source="mailman-apache.tmpl",
51 target="/etc/apache2/conf-available/mailman.conf",54 target="/etc/apache2/conf-available/mailman.conf",
52 context={})55 context={})
@@ -70,6 +73,7 @@ def configure_apache2():
70 # do SSL termination in front of this.73 # do SSL termination in front of this.
71 hookenv.open_port(80)74 hookenv.open_port(80)
72 set_flag('mailman.apache.configured')75 set_flag('mailman.apache.configured')
76 hookenv.status_set('active', 'ready')
7377
7478
75# Ask postgresql to create our DB.79# Ask postgresql to create our DB.
@@ -98,7 +102,9 @@ def configure_database(pgsql):
98@when('db.master.available')102@when('db.master.available')
99@when('config.changed')103@when('config.changed')
100def write_updated_config():104def write_updated_config():
105 hookenv.status_set('maintenance', 'updating configuration')
101 write_config()106 write_config()
107 hookenv.status_set('active', 'ready')
102108
103109
104# We're providing a website relation to whatever does SSL termination in front110# We're providing a website relation to whatever does SSL termination in front
@@ -164,6 +170,8 @@ def clear_mailman3_relation():
164170
165@when_any('endpoint.mailman3.connected')171@when_any('endpoint.mailman3.connected')
166def changed_mailman_data():172def changed_mailman_data():
173 if hookenv.hook_name() == 'update-status':
174 return
167 clear_flag('mailman3.relation.configured')175 clear_flag('mailman3.relation.configured')
168176
169177

Subscribers

People subscribed via source and target branches