launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #29262
[Merge] ~cjwatson/launchpad:charm-rabbitmq-relation into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:charm-rabbitmq-relation into launchpad:master.
Commit message:
charm: Implement rabbitmq relation
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/430829
This doesn't yet implement high availability by configuring multiple broker URLs; that will need some changes to Launchpad itself first.
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:charm-rabbitmq-relation into launchpad:master.
diff --git a/charm/layer/launchpad-base/config.yaml b/charm/layer/launchpad-base/config.yaml
index b0f96f5..4f2b83b 100644
--- a/charm/layer/launchpad-base/config.yaml
+++ b/charm/layer/launchpad-base/config.yaml
@@ -206,6 +206,10 @@ options:
type: string
description: External base URL for private PPAs.
default: http://private-ppa.launchpad.test/
+ rabbitmq_user:
+ type: string
+ description: Username to use with RabbitMQ.
+ default: test
session_cookie_name:
type: string
description: The ID of the cookie used to store the session token.
diff --git a/charm/layer/launchpad-base/layer.yaml b/charm/layer/launchpad-base/layer.yaml
index 0a62526..9ef3fe4 100644
--- a/charm/layer/launchpad-base/layer.yaml
+++ b/charm/layer/launchpad-base/layer.yaml
@@ -1,6 +1,7 @@
includes:
- layer:basic
- layer:ols-pg
+ - interface:rabbitmq
options:
apt:
packages:
diff --git a/charm/layer/launchpad-base/metadata.yaml b/charm/layer/launchpad-base/metadata.yaml
index 6de4a93..eafdcc0 100644
--- a/charm/layer/launchpad-base/metadata.yaml
+++ b/charm/layer/launchpad-base/metadata.yaml
@@ -1,3 +1,5 @@
requires:
db:
interface: pgsql
+ rabbitmq:
+ interface: rabbitmq
diff --git a/charm/layer/launchpad-base/reactive/launchpad-base.py b/charm/layer/launchpad-base/reactive/launchpad-base.py
index 71b2196..8e0d8d1 100644
--- a/charm/layer/launchpad-base/reactive/launchpad-base.py
+++ b/charm/layer/launchpad-base/reactive/launchpad-base.py
@@ -3,6 +3,7 @@
import subprocess
+from charmhelpers.core import hookenv
from charms.launchpad.base import (
configure_lazr,
configure_rsync,
@@ -28,9 +29,15 @@ def create_virtualenv(wheels_dir, codedir, python_exe):
base.create_virtualenv = create_virtualenv
-@when("ols.configured", "db.master.available")
+@when("rabbitmq.connected")
+def prepare_rabbitmq(rabbitmq):
+ config = hookenv.config()
+ rabbitmq.request_access(config["rabbitmq_user"], config["domain"])
+
+
+@when("ols.configured", "db.master.available", "rabbitmq.available")
@when_not("launchpad.base.configured")
-def configure(db):
+def configure(db, rabbitmq):
ensure_lp_directories()
config = get_service_config()
db_primary, db_standby = postgres.get_db_uris(db)
@@ -47,6 +54,14 @@ def configure(db):
# specific to the appserver. We need to teach Launchpad to be able to
# log in as one role and then switch to another.
config["db_user"] = parse_dsn(db_primary)["user"]
+ # XXX cjwatson 2022-09-29: How do we implement HA? Looks like we'd need
+ # code changes to let us configure multiple broker URLs. (At the moment
+ # we rely on round-robin DNS on production, but that probably doesn't
+ # provide very good HA either.)
+ config["rabbitmq_host"] = rabbitmq.private_address()
+ config["rabbitmq_username"] = rabbitmq.username()
+ config["rabbitmq_password"] = rabbitmq.password()
+ config["rabbitmq_vhost"] = rabbitmq.vhost()
configure_lazr(
config,
"launchpad-base-lazr.conf",
diff --git a/charm/layer/launchpad-base/templates/launchpad-base-lazr.conf b/charm/layer/launchpad-base/templates/launchpad-base-lazr.conf
index 9e597f5..4ea639e 100644
--- a/charm/layer/launchpad-base/templates/launchpad-base-lazr.conf
+++ b/charm/layer/launchpad-base/templates/launchpad-base-lazr.conf
@@ -82,6 +82,11 @@ authentication_endpoint: http://{{ domain_xmlrpc_private }}:{{ port_xmlrpc }}/au
buglist_batch_size: {{ default_batch_size }}
bugmail_error_from_address: noreply@bugs.{{ domain }}
+[rabbitmq]
+host: {{ rabbitmq_host }}
+userid: {{ rabbitmq_username }}
+virtual_host: {{ rabbitmq_vhost }}
+
{%- if statsd_environment %}
[statsd]
host: 127.0.0.1
diff --git a/charm/layer/launchpad-base/templates/launchpad-base-secrets-lazr.conf b/charm/layer/launchpad-base/templates/launchpad-base-secrets-lazr.conf
index a01a72d..1d5ff79 100644
--- a/charm/layer/launchpad-base/templates/launchpad-base-secrets-lazr.conf
+++ b/charm/layer/launchpad-base/templates/launchpad-base-secrets-lazr.conf
@@ -13,3 +13,6 @@
[mailman]
{{- opt("shared_secret", mailman_shared_secret) }}
+[rabbitmq]
+password: {{ rabbitmq_password }}
+
References