launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #29256
[Merge] ~cjwatson/launchpad:charm-memcached-relation into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:charm-memcached-relation into launchpad:master with ~cjwatson/launchpad:charm-appserver-more-config as a prerequisite.
Commit message:
charm: Implement memcached relation
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/430778
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:charm-memcached-relation into launchpad:master.
diff --git a/charm/launchpad-appserver/layer.yaml b/charm/launchpad-appserver/layer.yaml
index ae77d24..dae6f8a 100644
--- a/charm/launchpad-appserver/layer.yaml
+++ b/charm/launchpad-appserver/layer.yaml
@@ -1,5 +1,6 @@
includes:
- layer:launchpad-base
+ - interface:memcache
repo: https://git.launchpad.net/launchpad
options:
ols-pg:
diff --git a/charm/launchpad-appserver/metadata.yaml b/charm/launchpad-appserver/metadata.yaml
index 7f7b48e..755bcd3 100644
--- a/charm/launchpad-appserver/metadata.yaml
+++ b/charm/launchpad-appserver/metadata.yaml
@@ -16,3 +16,5 @@ subordinate: false
requires:
session-db:
interface: pgsql
+ memcache:
+ interface: memcache
diff --git a/charm/launchpad-appserver/reactive/launchpad-appserver.py b/charm/launchpad-appserver/reactive/launchpad-appserver.py
index 3f68d99..2fcc9b6 100644
--- a/charm/launchpad-appserver/reactive/launchpad-appserver.py
+++ b/charm/launchpad-appserver/reactive/launchpad-appserver.py
@@ -90,9 +90,13 @@ def config_files():
return files
-@when("launchpad.base.configured", "session-db.master.available")
+@when(
+ "launchpad.base.configured",
+ "session-db.master.available",
+ "memcache.available",
+)
@when_not("service.configured")
-def configure(session_db):
+def configure(session_db, memcache):
config = get_service_config()
session_db_primary, _ = postgres.get_db_uris(session_db)
# XXX cjwatson 2022-09-23: Mangle the connection string into a form
@@ -101,6 +105,12 @@ def configure(session_db):
update_pgpass(session_db_primary)
config["db_session"] = strip_dsn_authentication(session_db_primary)
config["db_session_user"] = parse_dsn(session_db_primary)["user"]
+ config["memcache_servers"] = ",".join(
+ sorted(
+ f"({host}:{port},1)"
+ for host, port in memcache.memcache_hosts_ports()
+ )
+ )
configure_lazr(
config,
"launchpad-appserver-lazr.conf",
diff --git a/charm/launchpad-appserver/templates/launchpad-appserver-lazr.conf b/charm/launchpad-appserver/templates/launchpad-appserver-lazr.conf
index 7faa040..b549f1a 100644
--- a/charm/launchpad-appserver/templates/launchpad-appserver-lazr.conf
+++ b/charm/launchpad-appserver/templates/launchpad-appserver-lazr.conf
@@ -27,3 +27,6 @@ cookie: {{ session_cookie_name }}
[mailman]
{{- opt("archive_url_template", mailman_archive_url_template) }}
+[memcache]
+servers: {{ memcache_servers }}
+