← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:charm-assets-fix-build into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:charm-assets-fix-build into launchpad:master.

Commit message:
charm: Fix assets build arrangements

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/445284

`launchpad-assets` needs to build the files it serves (particularly API documentation) with the correct `LPCONFIG` so that they embed the correct host names.  The previous arrangements of simply running `make build` when creating the virtualenv couldn't possibly achieve this, because the necessary configuration file didn't exist yet.  Run `make build` after creating the configuration file instead.

Doing this uncovered various problems with the configuration file we write out: it didn't have enough entries to support running `utilities/create-lp-wadl-and-apidoc.py`.  Also, since the `/srv/launchpad/code` symlink is now changed before all the assets are built, the Apache configuration now has to refer to the most-recently-configured payload directly using its build label rather than using `/srv/launchpad/code` as a shortcut.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:charm-assets-fix-build into launchpad:master.
diff --git a/charm/launchpad-assets/config.yaml b/charm/launchpad-assets/config.yaml
index dd00954..c440578 100644
--- a/charm/launchpad-assets/config.yaml
+++ b/charm/launchpad-assets/config.yaml
@@ -3,6 +3,10 @@ options:
     type: string
     description: Domain name for this instance.
     default: "launchpad.test"
+  domain_xmlrpc_private:
+    type: string
+    description: Domain name for this instance's private XML-RPC service.
+    default: "xmlrpc-private.launchpad.test"
   port:
     type: int
     description: Port for the assets website.
diff --git a/charm/launchpad-assets/layer.yaml b/charm/launchpad-assets/layer.yaml
index 53a6ccf..f7e6593 100644
--- a/charm/launchpad-assets/layer.yaml
+++ b/charm/launchpad-assets/layer.yaml
@@ -8,8 +8,6 @@ options:
     packages:
       - nodejs
       - python3-convoy
-  launchpad-payload:
-    build_target: build
   ols:
     service_name: launchpad-assets
     tarball_payload_name: launchpad
diff --git a/charm/launchpad-assets/reactive/launchpad-assets.py b/charm/launchpad-assets/reactive/launchpad-assets.py
index 331cb58..ee2b74e 100644
--- a/charm/launchpad-assets/reactive/launchpad-assets.py
+++ b/charm/launchpad-assets/reactive/launchpad-assets.py
@@ -95,6 +95,17 @@ def configure():
         group=base.user(),
         perms=0o444,
     )
+    # Build assets now that we have the correct configuration in place.
+    subprocess.run(
+        [
+            "make",
+            "build",
+            f"PYTHON={base.python_bin()}",
+            "LPCONFIG=launchpad-assets",
+        ],
+        cwd=base.code_dir(),
+        check=True,
+    )
     configure_convoy(config)
     set_flag("service.configured")
 
diff --git a/charm/launchpad-assets/templates/launchpad-assets-lazr.conf b/charm/launchpad-assets/templates/launchpad-assets-lazr.conf
index 24637f3..169fc2d 100644
--- a/charm/launchpad-assets/templates/launchpad-assets-lazr.conf
+++ b/charm/launchpad-assets/templates/launchpad-assets-lazr.conf
@@ -7,8 +7,24 @@
 # true, false, and none are treated as True, False, and None.
 
 [meta]
-extends: ../lib/lp/services/config/schema-lazr.conf
+extends: ../../lib/lp/services/config/schema-lazr.conf
+
+[error_reports]
+# ErrorReportingUtility.configure crashes without this.
+error_dir: {{ base_dir }}/oopses
+
+[vhost.mainsite]
+hostname: {{ domain }}
 
 [vhost.api]
 hostname: api.{{ domain }}
 
+[vhost.feeds]
+hostname: feeds.{{ domain }}
+
+[vhost.xmlrpc]
+hostname: xmlrpc.{{ domain }}
+
+[vhost.xmlrpc_private]
+hostname: {{ domain_xmlrpc_private }}
+
diff --git a/charm/launchpad-assets/templates/vhost.conf.j2 b/charm/launchpad-assets/templates/vhost.conf.j2
index 320e7cc..7d427d7 100644
--- a/charm/launchpad-assets/templates/vhost.conf.j2
+++ b/charm/launchpad-assets/templates/vhost.conf.j2
@@ -13,7 +13,7 @@
         Header set Cache-Control "public,max-age=5184000"
         Require all granted
     </Location>
-    Alias "/+apidoc/" "{{ code_dir }}/lib/canonical/launchpad/apidoc/"
+    Alias "/+apidoc/" "{{ payloads_dir }}/{{ build_label }}/lib/canonical/launchpad/apidoc/"
 
     <Location "/+combo/">
         Header set Cache-Control "public,max-age=5184000"
@@ -30,20 +30,20 @@
         Header set Cache-Control "public,max-age=5184000"
         Require all granted
     </Location>
-    Alias "/+icing/" "{{ code_dir }}/lib/canonical/launchpad/icing/"
+    Alias "/+icing/" "{{ payloads_dir }}/{{ build_label }}/lib/canonical/launchpad/icing/"
 
     <Location "/@@/">
         Options MultiViews
         Header set Cache-Control "public,max-age=5184000"
         Require all granted
     </Location>
-    Alias "/@@/" "{{ code_dir }}/lib/canonical/launchpad/images/"
+    Alias "/@@/" "{{ payloads_dir }}/{{ build_label }}/lib/canonical/launchpad/images/"
 
     <LocationMatch "^/favicon\.(?:ico|gif|png)$">
         Header set Cache-Control "public,max-age=5184000"
         Require all granted
     </LocationMatch>
-    AliasMatch "^/favicon\.(?:ico|gif|png)$" "{{ code_dir }}/lib/canonical/launchpad/images/launchpad.png"
+    AliasMatch "^/favicon\.(?:ico|gif|png)$" "{{ payloads_dir }}/{{ build_label }}/lib/canonical/launchpad/images/launchpad.png"
 
     <Location "/_status/check">
         Require all granted