Merge ~jk0ne/charm-k8s-discourse/+git/charm-k8s-discourse:cmr-db-revision into charm-k8s-discourse:master

Proposed by Jay Kuri
Status: Rejected
Rejected by: Tom Haddon
Proposed branch: ~jk0ne/charm-k8s-discourse/+git/charm-k8s-discourse:cmr-db-revision
Merge into: charm-k8s-discourse:master
Diff against target: 80 lines (+36/-3)
2 files modified
image/markdown-saml/Dockerfile (+21/-0)
src/charm.py (+15/-3)
Reviewer Review Type Date Requested Status
Tom Haddon Needs Fixing
Canonical IS Reviewers Pending
Review via email: mp+393469@code.launchpad.net

Commit message

Adjust db related event handlers to more closely follow what works in the MatterMost charm

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 :

Let's hold off on this until we've got a fix that's actually been tested to be working.

Also, I'm not clear how the new Dockerfile would be used. Ideally this would be something that we could set up a Launchpad OCI Recipe build for but I think this relies on having built the base image as "discourse:v2.5.2". Do we know how Launchpad would reference that? Or is there some way to restructure this so that we inherit the steps from image/Dockerfile when running docker build against this file?

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

In terms of the image build, I think something like https://paste.ubuntu.com/p/J5j5Fct4DF/ should work. I'll test locally, and ask for your feedback later as well.

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

Unmerged commits

2e1c620... by Jay Kuri

Adjust db related event handlers to more closely follow what works in
the MatterMost charm

f6dc0ee... by Jay Kuri

Add markdown-saml subordinate image dockerfile

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/image/markdown-saml/Dockerfile b/image/markdown-saml/Dockerfile
2new file mode 100644
3index 0000000..fe68a4b
4--- /dev/null
5+++ b/image/markdown-saml/Dockerfile
6@@ -0,0 +1,21 @@
7+FROM discourse:v2.5.2
8+
9+# CONTAINER_APP_ROOT is where files related to this application go. This
10+# environment variable is available in the build scripts. This should usually be
11+# a subdirectory of /srv.
12+ENV CONTAINER_APP_ROOT=/srv/discourse
13+
14+# Application specific environment variables go here.
15+ENV GEM_HOME ${CONTAINER_APP_ROOT}/.gem
16+
17+# We don't want packages prompting us during install.
18+ENV DEBIAN_FRONTEND=noninteractive
19+
20+RUN cd ${CONTAINER_APP_ROOT}/app/plugins && git clone https://github.com/discourse/discourse-saml.git
21+RUN cd ${CONTAINER_APP_ROOT}/app/plugins && git clone https://github.com/canonical-web-and-design/discourse-markdown-note.git
22+RUN chown -R ${CONTAINER_APP_USERNAME}:${CONTAINER_APP_GROUP} ${CONTAINER_APP_ROOT}/app/plugins
23+RUN cd ${CONTAINER_APP_ROOT}/app && su -s /bin/bash -c 'bin/bundle install' ${CONTAINER_APP_USERNAME}
24+
25+RUN echo "saml_target_url = https://login.ubuntu.com/+saml" >> /srv/scripts/assets/discourse.conf.tmpl
26+RUN echo "saml_cert_fingerprint = 32:15:20:9F:A4:3C:8E:3E:8E:47:72:62:9A:86:8D:0E:E6:CF:45:D5" >> /srv/scripts/assets/discourse.conf.tmpl
27+RUN echo "saml_full_screen_login = true" >> /srv/scripts/assets/discourse.conf.tmpl
28diff --git a/src/charm.py b/src/charm.py
29index 5bb75ad..55b4cc9 100755
30--- a/src/charm.py
31+++ b/src/charm.py
32@@ -3,9 +3,9 @@
33 # See LICENSE file for licensing details.
34
35 import ops.lib
36-from ops.charm import CharmBase
37+from ops.charm import CharmBase, CharmEvents
38 from ops.main import main
39-from ops.framework import StoredState
40+from ops.framework import StoredState, EventBase, EventSource
41
42 from ops.model import ActiveStatus, BlockedStatus, MaintenanceStatus
43
44@@ -144,8 +144,19 @@ def check_for_missing_config_fields(config):
45 return sorted(missing_fields)
46
47
48+class DiscourseDBMasterAvailableEvent(EventBase):
49+ pass
50+
51+
52+class DiscourseCharmEvents(CharmEvents):
53+ """Custom charm events."""
54+
55+ db_master_available = EventSource(DiscourseDBMasterAvailableEvent)
56+
57+
58 class DiscourseCharm(CharmBase):
59 stored = StoredState()
60+ on = DiscourseCharmEvents()
61
62 def __init__(self, *args):
63 """Initialization.
64@@ -164,6 +175,7 @@ class DiscourseCharm(CharmBase):
65 self.db = pgsql.PostgreSQLClient(self, 'db')
66 self.framework.observe(self.db.on.database_relation_joined, self.on_database_relation_joined)
67 self.framework.observe(self.db.on.master_changed, self.on_database_changed)
68+ self.framework.observe(self.on.db_master_available, self.configure_pod)
69
70 def check_config_is_valid(self, config):
71 """Check that the provided config is valid.
72@@ -252,7 +264,7 @@ class DiscourseCharm(CharmBase):
73 self.stored.db_password = event.master.password
74 self.stored.db_host = event.master.host
75
76- self.configure_pod()
77+ self.on.db_master_available.emit()
78
79
80 if __name__ == '__main__': # pragma: no cover

Subscribers

People subscribed via source and target branches