Merge ~cjwatson/launchpad:charm-appserver-fixes into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: eb115424d7380c22ae8b17c4dcf0777a6960233f
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:charm-appserver-fixes
Merge into: launchpad:master
Diff against target: 70 lines (+17/-6)
3 files modified
charm/launchpad-appserver/reactive/launchpad-appserver.py (+6/-2)
charm/layer/launchpad-base/reactive/launchpad-base.py (+10/-1)
charm/layer/launchpad-base/templates/launchpad-base-lazr.conf (+1/-3)
Reviewer Review Type Date Requested Status
Jürgen Gmach Approve
Review via email: mp+429652@code.launchpad.net

Commit message

Fix various problems with the appserver charm

Description of the change

On redeploying the `launchpad-appserver` charm, I found a collection of problems that prevented the result from working.

To post a comment you must log in.
Revision history for this message
Jürgen Gmach (jugmac00) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/charm/launchpad-appserver/reactive/launchpad-appserver.py b/charm/launchpad-appserver/reactive/launchpad-appserver.py
2index c5fac0e..f34d40d 100644
3--- a/charm/launchpad-appserver/reactive/launchpad-appserver.py
4+++ b/charm/launchpad-appserver/reactive/launchpad-appserver.py
5@@ -27,7 +27,9 @@ def enable_service(service):
6 {
7 "/etc/rsyslog.d/22-launchpad.conf": ["rsyslog"],
8 "/lib/systemd/system/launchpad.service": ["launchpad"],
9- config_file_path("gunicorn.conf.py"): ["launchpad"],
10+ config_file_path("launchpad-appserver/gunicorn.conf.py"): [
11+ "launchpad"
12+ ],
13 },
14 restart_functions={
15 "rsyslog": reload_or_restart,
16@@ -40,7 +42,9 @@ def configure_gunicorn(config):
17 if config["wsgi_workers"] == 0:
18 config["wsgi_workers"] = cpu_count() * 2 + 1
19 templating.render(
20- "gunicorn.conf.py.j2", config_file_path("gunicorn.conf.j2"), config
21+ "gunicorn.conf.py.j2",
22+ config_file_path("launchpad-appserver/gunicorn.conf.py"),
23+ config,
24 )
25 templating.render(
26 "launchpad.service.j2", "/lib/systemd/system/launchpad.service", config
27diff --git a/charm/layer/launchpad-base/reactive/launchpad-base.py b/charm/layer/launchpad-base/reactive/launchpad-base.py
28index e5e90ea..8dd3b69 100644
29--- a/charm/layer/launchpad-base/reactive/launchpad-base.py
30+++ b/charm/layer/launchpad-base/reactive/launchpad-base.py
31@@ -9,7 +9,7 @@ from charms.launchpad.base import (
32 ensure_lp_directories,
33 get_service_config,
34 )
35-from charms.reactive import remove_state, set_state, when, when_not
36+from charms.reactive import hook, remove_state, set_state, when, when_not
37 from ols import base
38
39
40@@ -49,6 +49,15 @@ def configure():
41 set_state("launchpad.base.configured")
42
43
44+@hook("upgrade-charm")
45+def upgrade_charm():
46+ # The ols layer takes care of removing the ols.service.installed,
47+ # ols.configured, and service.configured states. Remove
48+ # launchpad.base.configured as well so that we have an opportunity to
49+ # rewrite base configuration files.
50+ remove_state("launchpad.base.configured")
51+
52+
53 @when("config.changed.build_label")
54 def build_label_changed():
55 remove_state("ols.service.installed")
56diff --git a/charm/layer/launchpad-base/templates/launchpad-base-lazr.conf b/charm/layer/launchpad-base/templates/launchpad-base-lazr.conf
57index f0b4aeb..e66d6ec 100644
58--- a/charm/layer/launchpad-base/templates/launchpad-base-lazr.conf
59+++ b/charm/layer/launchpad-base/templates/launchpad-base-lazr.conf
60@@ -16,9 +16,7 @@ pid_dir: {{ var_dir }}
61 [database]
62 db_statement_timeout: 15000
63 rw_main_primary: {{ db_primary }}
64-{%- if db_standby %}
65-rw_main_standby: {{ db_standby }}
66-{%- endif %}
67+rw_main_standby: {{ db_standby or db_primary }}
68 soft_request_timeout: 8000
69
70 [error_reports]

Subscribers

People subscribed via source and target branches

to status/vote changes: