Merge ~cjwatson/launchpad:charmcraft-fetch-dependencies into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: ba250c6841928066f5bb792be0f9bd9a557885df
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:charmcraft-fetch-dependencies
Merge into: launchpad:master
Diff against target: 1023 lines (+86/-32)
6 files modified
charm/.gitignore (+0/-1)
charm/Makefile (+1/-14)
charm/launchpad-appserver/charmcraft.yaml (+42/-5)
charm/launchpad/charmcraft.yaml (+43/-5)
charm/packages.txt (+0/-1)
dev/null (+0/-6)
Reviewer Review Type Date Requested Status
Guruprasad Approve
Review via email: mp+438897@code.launchpad.net

Commit message

charm: Fetch dependencies using charmcraft

Description of the change

Now that `ols-layers` is open-source, we can fetch it directly using `charmcraft`, which is much simpler and should let us use Launchpad charm recipes.

I had to split out `charm/layer/` to a separate https://git.launchpad.net/launchpad-layers project, because `charmcraft` can't deal with referencing the parent directory from one of a charm's parts. That separation isn't ideal, but the benefits of being able to use charm recipes should outweigh the costs.

To post a comment you must log in.
Revision history for this message
Guruprasad (lgp171188) wrote :

LGTM 👍

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/charm/.gitignore b/charm/.gitignore
2index de07da3..da831d3 100644
3--- a/charm/.gitignore
4+++ b/charm/.gitignore
5@@ -1,5 +1,4 @@
6 *.charm
7 bundle.yaml
8 dist
9-layer/*/codetree-collect-info.yaml
10 tmp
11diff --git a/charm/Makefile b/charm/Makefile
12index 2e659ca..24ac014 100644
13--- a/charm/Makefile
14+++ b/charm/Makefile
15@@ -5,8 +5,6 @@ APP_NAME := launchpad
16
17 BUILDDIR := $(CURDIR)/dist
18 TMPDIR := $(CURDIR)/tmp
19-CHARM_LAYERS_DIR := $(TMPDIR)/deps/ols-layers/layer
20-CHARM_INTERFACES_DIR := $(TMPDIR)/deps/ols-layers/interface
21
22 CHARM_SERIES ?= 20.04
23 ARCH := $(shell dpkg --print-architecture)
24@@ -28,23 +26,13 @@ help: ## display this help message
25 $(BUILDDIR) $(TMPDIR):
26 @mkdir -p $@
27
28-# We have to clone our dependencies by hand rather than letting charmcraft
29-# do it, since some of them are in private repositories and charmcraft
30-# doesn't have suitable credentials.
31-CHARM_DEPS := $(CHARM_LAYERS_DIR)/.done $(CHARM_INTERFACES_DIR)/.done
32-$(CHARM_DEPS): $(CURDIR)/dependencies.txt | $(TMPDIR)
33- @echo "Fetching dependencies..."
34- @mkdir -p $(TMPDIR)/deps
35- @cd $(TMPDIR)/deps && codetree $<
36- @touch $(CHARM_DEPS)
37-
38 build: ## build all the charms
39 build: $(foreach charm,$(CHARMS),build-$(charm))
40
41 build-launchpad-appserver: ## build the launchpad-appserver charm
42 build-launchpad-appserver: dist/$(call charm_file,launchpad-appserver)
43
44-dist/%_ubuntu-$(CHARM_SERIES)-$(ARCH).charm: $(CHARM_DEPS) | $(BUILDDIR)
45+dist/%_ubuntu-$(CHARM_SERIES)-$(ARCH).charm: $(BUILDDIR)
46 echo "Building $*..."
47 rm -rf $*/tmp
48 cp -a tmp $*/tmp
49@@ -58,7 +46,6 @@ clean: $(foreach charm,$(CHARMS),clean-$(charm))
50 @find . -name \*.pyc -delete
51 @find . -depth -name '__pycache__' -exec rm -rf '{}' \;
52 @rm -f bundle.yaml
53- @rm -f layer/*/codetree-collect-info.yaml
54 @rm -rf $(BUILDDIR) $(TMPDIR)
55
56 clean-%:
57diff --git a/charm/dependencies.txt b/charm/dependencies.txt
58deleted file mode 100644
59index 1ca5896..0000000
60--- a/charm/dependencies.txt
61+++ /dev/null
62@@ -1,2 +0,0 @@
63-ols-layers git+ssh://git.launchpad.net/~ubuntuone-pqm-team/ols-charm-deps/+git/ols-layers;revno=c2faacbd
64-charm-wheels git+ssh://git.launchpad.net/~ubuntuone-hackers/ols-charm-deps/+git/wheels;revno=fe523e25
65diff --git a/charm/launchpad-appserver/charmcraft.yaml b/charm/launchpad-appserver/charmcraft.yaml
66index ff2bada..4f764a5 100644
67--- a/charm/launchpad-appserver/charmcraft.yaml
68+++ b/charm/launchpad-appserver/charmcraft.yaml
69@@ -7,15 +7,52 @@ bases:
70 - name: ubuntu
71 channel: "20.04"
72 parts:
73+ charm-wheels:
74+ source: https://git.launchpad.net/~ubuntuone-hackers/ols-charm-deps/+git/wheels
75+ source-commit: "fe523e25521254c2034eea96e2fde079034b593a"
76+ source-submodules: []
77+ source-type: git
78+ plugin: dump
79+ organize:
80+ "*": charm-wheels/
81+ prime:
82+ - "-charm-wheels"
83+ ols-layers:
84+ source: https://git.launchpad.net/ols-charm-deps
85+ source-commit: "c2faacbd6d227b2ae40ee57ab162b28691e88ca6"
86+ source-submodules: []
87+ source-type: git
88+ plugin: dump
89+ organize:
90+ "*": layers/
91+ stage:
92+ - layers
93+ prime:
94+ - "-layers"
95+ launchpad-layers:
96+ after:
97+ - ols-layers
98+ source: https://git.launchpad.net/launchpad-layers
99+ source-commit: "624df58b5b21a34f8931bba12931e1e3a37ac7b5"
100+ source-submodules: []
101+ source-type: git
102+ plugin: dump
103+ organize:
104+ launchpad-base: layers/layer/launchpad-base
105+ stage:
106+ - layers
107+ prime:
108+ - "-layers"
109 launchpad-appserver:
110+ after:
111+ - charm-wheels
112+ - launchpad-layers
113 source: .
114 plugin: reactive
115 build-snaps: [charm/2.x/stable]
116 build-packages: [libpq-dev]
117 build-environment:
118- - CHARM_LAYERS_DIR: tmp/deps/ols-layers/layer
119- - CHARM_INTERFACES_DIR: tmp/deps/ols-layers/interface
120+ - CHARM_LAYERS_DIR: $CRAFT_STAGE/layers/layer
121+ - CHARM_INTERFACES_DIR: $CRAFT_STAGE/layers/interface
122 - PIP_NO_INDEX: "true"
123- - PIP_FIND_LINKS: tmp/deps/charm-wheels
124- stage:
125- - -tmp
126+ - PIP_FIND_LINKS: $CRAFT_STAGE/charm-wheels
127diff --git a/charm/launchpad/charmcraft.yaml b/charm/launchpad/charmcraft.yaml
128index 0c3d3f2..ca6d9c8 100644
129--- a/charm/launchpad/charmcraft.yaml
130+++ b/charm/launchpad/charmcraft.yaml
131@@ -7,14 +7,52 @@ bases:
132 - name: ubuntu
133 channel: "20.04"
134 parts:
135+ charm-wheels:
136+ source: https://git.launchpad.net/~ubuntuone-hackers/ols-charm-deps/+git/wheels
137+ source-commit: "fe523e25521254c2034eea96e2fde079034b593a"
138+ source-submodules: []
139+ source-type: git
140+ plugin: dump
141+ organize:
142+ "*": charm-wheels/
143+ prime:
144+ - "-charm-wheels"
145+ ols-layers:
146+ source: https://git.launchpad.net/ols-charm-deps
147+ source-commit: "c2faacbd6d227b2ae40ee57ab162b28691e88ca6"
148+ source-submodules: []
149+ source-type: git
150+ plugin: dump
151+ organize:
152+ "*": layers/
153+ stage:
154+ - layers
155+ prime:
156+ - "-layers"
157+ launchpad-layers:
158+ after:
159+ - ols-layers
160+ source: https://git.launchpad.net/launchpad-layers
161+ source-commit: "624df58b5b21a34f8931bba12931e1e3a37ac7b5"
162+ source-submodules: []
163+ source-type: git
164+ plugin: dump
165+ organize:
166+ launchpad-base: layers/layer/launchpad-base
167+ stage:
168+ - layers
169+ prime:
170+ - "-layers"
171 launchpad:
172+ after:
173+ - charm-wheels
174+ - launchpad-layers
175 source: .
176 plugin: reactive
177 build-snaps: [charm/2.x/stable]
178+ build-packages: [libpq-dev]
179 build-environment:
180- - CHARM_LAYERS_DIR: tmp/deps/ols-layers/layer
181- - CHARM_INTERFACES_DIR: tmp/deps/ols-layers/interface
182+ - CHARM_LAYERS_DIR: $CRAFT_STAGE/layers/layer
183+ - CHARM_INTERFACES_DIR: $CRAFT_STAGE/layers/interface
184 - PIP_NO_INDEX: "true"
185- - PIP_FIND_LINKS: tmp/deps/charm-wheels
186- stage:
187- - -tmp
188+ - PIP_FIND_LINKS: $CRAFT_STAGE/charm-wheels
189diff --git a/charm/layer/launchpad-base/config.yaml b/charm/layer/launchpad-base/config.yaml
190deleted file mode 100644
191index 4f2b83b..0000000
192--- a/charm/layer/launchpad-base/config.yaml
193+++ /dev/null
194@@ -1,267 +0,0 @@
195-options:
196- bounce_address:
197- type: string
198- description: Envelope sender address for outgoing email.
199- default: "noreply@launchpad.test"
200- bzr_imports_root_url:
201- type: string
202- description: >
203- Internal URL prefix for Bazaar branches imported from other revision
204- control systems, used by the branch puller.
205- default:
206- bzr_lp_prefix:
207- type: string
208- description: >
209- URL prefix used to address Bazaar branches on this instance.
210- default: lp://dev/
211- bzr_lp_url_hosts:
212- type: string
213- description: >
214- Comma-separated list of hosts which may be used to refer to this
215- server's branches in "lp:" URLs.
216- default: dev
217- candid_service_root:
218- type: string
219- description: >
220- URL to the Candid service, used to discharge certain kinds of
221- macaroons.
222- default:
223- charmhub_secrets_public_key:
224- type: string
225- description: >
226- Base64-encoded NaCl public key for encrypting Charmhub upload tokens.
227- default:
228- charmhub_storage_url:
229- type: string
230- description: Charmhub's storage URL endpoint.
231- default:
232- charmhub_url:
233- type: string
234- description: Charmhub's primary URL endpoint.
235- default:
236- cron_control_url:
237- type: string
238- description: URL of file used to control whether cron scripts run.
239- default: "file:cronscripts.ini"
240- databases:
241- type: string
242- description: >
243- YAML-encoded information about database relations, overriding the
244- defaults. For example, setting this to "db: {name: launchpad_prod}"
245- changes the name of the database used by the "db" relation.
246- default: ""
247- db_statement_timeout:
248- type: int
249- description: SQL statement timeout in milliseconds.
250- default:
251- default_batch_size:
252- type: int
253- description: The default size used in a batched listing of results.
254- default: 50
255- domain:
256- type: string
257- description: Domain name for this instance.
258- default: "launchpad.test"
259- domain_bzr:
260- type: string
261- description: Domain name for this instance's Bazaar service, if any.
262- default:
263- domain_git:
264- type: string
265- description: Domain name for this instance's Git service, if any.
266- default:
267- domain_lists:
268- type: string
269- description: >
270- Domain name for this instance's mailing list service, if any.
271- default:
272- domain_xmlrpc_private:
273- type: string
274- description: Domain name for this instance's private XML-RPC service.
275- default: "xmlrpc-private.launchpad.test"
276- geoip_database:
277- type: string
278- description: >
279- The database used by our GeoIP library. Only GeoIP2/GeoLite2 Country
280- databases are supported.
281- default:
282- git_loose_objects_threshold:
283- type: int
284- description: >
285- Threshold for the number of loose objects that triggers automatic
286- repacking of Git repositories.
287- default:
288- git_packs_threshold:
289- type: int
290- description: >
291- Threshold for the number of pack files that triggers automatic
292- repacking of Git repositories.
293- default:
294- gpg_upload_keys:
295- type: boolean
296- description: Should we allow uploading keys to the keyserver?
297- default: false
298- is_demo:
299- type: boolean
300- description: >
301- Should pages be styled to indicate the use of a demo system?
302- default: true
303- http_proxy:
304- type: string
305- description: Proxy to be used when issuing HTTP requests.
306- default:
307- internal_bzr_api_endpoint:
308- type: string
309- description: The URL of the internal Bazaar hosting API endpoint.
310- default:
311- librarian_download_host:
312- type: string
313- description: Host the Librarian is listening on for HTTP requests.
314- default:
315- librarian_download_port:
316- type: int
317- description: >
318- Port number the Librarian listens for HTTP GET and HEAD requests on.
319- default:
320- librarian_download_url:
321- type: string
322- description: The base URL used to generate URLs to the Library contents.
323- default:
324- librarian_restricted_download_host:
325- type: string
326- description: >
327- Host the Restricted Librarian is listening on for HTTP requests.
328- default:
329- librarian_restricted_download_port:
330- type: int
331- description: >
332- Port number the Restricted Librarian listens for HTTP GET and HEAD
333- requests on.
334- default:
335- librarian_restricted_download_url:
336- type: string
337- description: >
338- The base URL used to generate URLs to the Restricted Library contents.
339- default:
340- librarian_restricted_upload_host:
341- type: string
342- description: >
343- Host the Restricted Librarian is listening on for storage requests.
344- default:
345- librarian_restricted_upload_port:
346- type: int
347- description: >
348- Port number the Restricted Librarian listens for storage requests on.
349- default:
350- librarian_upload_host:
351- type: string
352- description: Host the Librarian is listening on for storage requests.
353- default:
354- librarian_upload_port:
355- type: int
356- description: >
357- Port number the Librarian listens for storage requests on.
358- default:
359- log_hosts_allow:
360- type: string
361- description: >
362- Hosts that should be allowed to rsync logs. Note that this relies on
363- the nrpe subordinate charm to set up /etc/rsyncd.conf properly.
364- default: ""
365- mailman_shared_secret:
366- type: string
367- description: >
368- Shared secret used to pre-approve Launchpad-generated messages to
369- Launchpad mailing lists.
370- default:
371- oci_registry_credentials_public_key:
372- type: string
373- description: >
374- Base64-encoded NaCl public key for encrypting OCI registry upload
375- credentials.
376- default:
377- oops_prefix:
378- type: string
379- description: A prefix for OOPS codes for this instance.
380- default: "TEST"
381- openid_alternate_provider_roots:
382- type: string
383- description: >
384- Comma-separated list of additional URLs to recognise as valid prefixes
385- for our accounts' OpenID identifiers.
386- default:
387- openid_provider_root:
388- type: string
389- description: URL to the OpenID provider to authenticate against.
390- default: https://testopenid.test/
391- port_xmlrpc:
392- type: int
393- description: Port for the XML-RPC application server.
394- default: 8087
395- ppa_base_url:
396- type: string
397- description: External base URL for PPAs.
398- default: http://ppa.launchpad.test/
399- ppa_private_base_url:
400- type: string
401- description: External base URL for private PPAs.
402- default: http://private-ppa.launchpad.test/
403- rabbitmq_user:
404- type: string
405- description: Username to use with RabbitMQ.
406- default: test
407- session_cookie_name:
408- type: string
409- description: The ID of the cookie used to store the session token.
410- default: launchpad_dev
411- site_message:
412- type: string
413- description: >
414- If provided, this message will appear in the site status bar at the
415- top of every page.
416- default:
417- snap_store_secrets_public_key:
418- type: string
419- description: >
420- Base64-encoded NaCl public key for encrypting snap store upload
421- tokens.
422- default:
423- snap_store_upload_url:
424- type: string
425- description: The snap store's upload URL endpoint.
426- default:
427- snap_store_url:
428- type: string
429- description: The snap store's primary URL endpoint.
430- default:
431- soft_request_timeout:
432- type: int
433- description: Soft request timeout in milliseconds.
434- default:
435- statsd_environment:
436- type: string
437- description: Statsd environment name.
438- default:
439- ubuntu_disable_filebug:
440- type: boolean
441- description: Should +filebug be disabled for Ubuntu?
442- default: false
443- uploader_default_recipient:
444- type: string
445- description: Default email recipient for package upload notifications.
446- default:
447- uploader_default_sender:
448- type: string
449- description: Default email sender for package upload notifications.
450- default:
451- webhooks_proxy_url:
452- type: string
453- description: Outbound webhook request proxy URL.
454- default:
455- # layer-apt
456- install_sources:
457- default: |
458- - ppa:launchpad/ppa
459- install_keys:
460- default: |
461- - null # PPA keys securely added via Launchpad.
462diff --git a/charm/layer/launchpad-base/icon.svg b/charm/layer/launchpad-base/icon.svg
463deleted file mode 100644
464index b2889cc..0000000
465--- a/charm/layer/launchpad-base/icon.svg
466+++ /dev/null
467@@ -1 +0,0 @@
468-<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 165.39062 165.39062"><defs><style>.cls-1{fill:#e9500e;}.cls-2{fill:#fff;}</style></defs><rect class="cls-1" width="165.39062" height="165.39062"/><path class="cls-2" d="M29.63876,57.97189C43.189,67.692,61.13456,69.25577,77.65457,62.15038c16.25576-6.87157,27.74036-21.43444,29.97828-38.0075.04663-.34331.11016-.81367-1.59861-1.24044l-10.10934-2.197c-.3254-.04494-.79136-.04967-1.15258,1.22455C91.37844,36.07384,84.34062,45.04243,72.6347,50.1123c-11.77316,5.10029-23.18748,4.05279-35.91893-3.29386-.58119-.27843-.91909-.26086-1.45568.52577l-5.77947,8.65163A1.34512,1.34512,0,0,0,29.63876,57.97189Z" transform="translate(0.39062 0.39062)"/><path class="cls-2" d="M79.86106,139.66026l10.3631.565c1.74155.03446,1.79122-.42981,1.83717-.77312,2.23826-16.5734-4.97222-33.66107-18.81739-44.59422C59.196,83.62132,41.47815,80.36935,25.83365,86.14747a1.33956,1.33956,0,0,0-.67918,1.85373l3.28,9.88226c.30952.90153.62816,1.011,1.26443.89409,14.22464-3.70543,25.50717-1.68748,35.50635,6.3512,9.94174,7.9934,14.34865,18.50754,13.86883,33.08867C79.08524,139.50144,79.53735,139.615,79.86106,139.66026Z" transform="translate(0.39062 0.39062)"/><path class="cls-2" d="M86.50488,70.59048a10.50817,10.50817,0,0,0-1.39587-.09461A9.35237,9.35237,0,0,0,79.39915,72.382a9.61981,9.61981,0,1,0,7.10573-1.79156Z" transform="translate(0.39062 0.39062)"/><path class="cls-2" d="M138.26869,53.18923,133.457,43.97736c-.68628-1.51583-1.22793-1.36985-1.79594-1.17657-15.382,6.63165-25.99848,21.22156-28.40434,39.03776-2.40755,17.82971,3.97169,34.72681,17.0647,45.19906a1.177,1.177,0,0,0,.90794.32844,1.48362,1.48362,0,0,0,.99546-.54l6.76175-8.11166c.62342-.78393.35783-1.18333.0321-1.52461-10.60639-10.44454-14.5764-20.81677-12.84905-33.60769,1.73682-12.86121,8.51918-22.08254,21.34457-29.019C138.52854,53.95289,138.36533,53.421,138.26869,53.18923Z" transform="translate(0.39062 0.39062)"/></svg>
469\ No newline at end of file
470diff --git a/charm/layer/launchpad-base/layer.yaml b/charm/layer/launchpad-base/layer.yaml
471deleted file mode 100644
472index 9ef3fe4..0000000
473--- a/charm/layer/launchpad-base/layer.yaml
474+++ /dev/null
475@@ -1,16 +0,0 @@
476-includes:
477- - layer:basic
478- - layer:ols-pg
479- - interface:rabbitmq
480-options:
481- apt:
482- packages:
483- - launchpad-dependencies
484- ols:
485- service_name: launchpad
486- config_filename: service.conf
487- user: launchpad
488- tarball_payload: true
489- symlink_switch_payload: true
490- python_bin: /usr/bin/python3
491-repo: https://git.launchpad.net/launchpad
492diff --git a/charm/layer/launchpad-base/lib/charms/launchpad/base.py b/charm/layer/launchpad-base/lib/charms/launchpad/base.py
493deleted file mode 100644
494index 71f0dbe..0000000
495--- a/charm/layer/launchpad-base/lib/charms/launchpad/base.py
496+++ /dev/null
497@@ -1,195 +0,0 @@
498-# Copyright 2022 Canonical Ltd. This software is licensed under the
499-# GNU Affero General Public License version 3 (see the file LICENSE).
500-
501-import grp
502-import os.path
503-import pwd
504-import re
505-from dataclasses import dataclass
506-from email.utils import parseaddr
507-
508-from charmhelpers.core import hookenv, host, templating
509-from ols import base
510-from psycopg2.extensions import make_dsn, parse_dsn
511-
512-
513-def home_dir():
514- return os.path.join("/home", base.user())
515-
516-
517-def oopses_dir():
518- return os.path.join(base.base_dir(), "oopses")
519-
520-
521-def secrets_dir():
522- return os.path.join(base.base_dir(), "secrets")
523-
524-
525-def var_dir():
526- return os.path.join(base.base_dir(), "var")
527-
528-
529-def ensure_lp_directories():
530- for dirpath in oopses_dir(), var_dir():
531- host.mkdir(dirpath, group=base.user(), perms=0o775)
532- host.mkdir(secrets_dir(), group=base.user(), perms=0o750)
533- host.mkdir(home_dir(), owner=base.user(), group=base.user(), perms=0o755)
534-
535-
536-def get_service_config():
537- config = dict(hookenv.config())
538- config.update(
539- {
540- "base_dir": base.base_dir(),
541- "code_dir": base.code_dir(),
542- "logs_dir": base.logs_dir(),
543- "oopses_dir": oopses_dir(),
544- # Used by some templates.
545- "parseaddr": parseaddr,
546- "secrets_dir": secrets_dir(),
547- "user": base.user(),
548- "var_dir": var_dir(),
549- }
550- )
551- return config
552-
553-
554-def config_file_path(name, secret=False):
555- if secret:
556- config_dir = os.path.join(base.base_dir(), "secrets")
557- else:
558- config_dir = os.path.join(base.code_dir(), "production-configs")
559- return os.path.join(config_dir, name)
560-
561-
562-def configure_lazr(config, template, name, secret=False):
563- hookenv.log("Writing service configuration.")
564- templating.render(
565- template,
566- config_file_path(name, secret=secret),
567- config,
568- owner="root",
569- group=base.user(),
570- perms=0o440 if secret else 0o444,
571- )
572-
573-
574-def lazr_config_files():
575- return [
576- config_file_path("launchpad-base-lazr.conf"),
577- config_file_path("launchpad-base-secrets-lazr.conf", secret=True),
578- ]
579-
580-
581-def configure_rsync(config, template, name):
582- hookenv.log("Writing rsync configuration.")
583- rsync_path = os.path.join("/etc/rsync-juju.d", name)
584- if config["log_hosts_allow"]:
585- templating.render(template, rsync_path, config, perms=0o644)
586- elif os.path.exists(rsync_path):
587- os.unlink(rsync_path)
588-
589-
590-@dataclass
591-class PgPassLine:
592- hostname: str
593- port: str
594- database: str
595- username: str
596- password: str
597-
598-
599-def update_pgpass(dsn):
600- # See https://www.postgresql.org/docs/current/libpq-pgpass.html.
601-
602- def unescape(entry):
603- return re.sub(r"\\(.)", r"\1", entry)
604-
605- def escape(entry):
606- return re.sub(r"([:\\])", r"\\\1", entry)
607-
608- parsed_dsn = parse_dsn(dsn)
609- pgpass_path = os.path.join(home_dir(), ".pgpass")
610- pgpass = []
611- try:
612- with open(pgpass_path) as f:
613- for line in f:
614- if line.startswith("#"):
615- continue
616- match = re.match(
617- r"""
618- ^
619- (?P<hostname>(?:[^:\\]|\\.)*):
620- (?P<port>(?:[^:\\]|\\.)*):
621- (?P<database>(?:[^:\\]|\\.)*):
622- (?P<username>(?:[^:\\]|\\.)*):
623- (?P<password>(?:[^:\\]|\\.)*)
624- $
625- """,
626- line.rstrip("\n"),
627- flags=re.X,
628- )
629- if match is None:
630- continue
631- pgpass.append(
632- PgPassLine(
633- hostname=unescape(match.group("hostname")),
634- port=unescape(match.group("port")),
635- database=unescape(match.group("database")),
636- username=unescape(match.group("username")),
637- password=unescape(match.group("password")),
638- )
639- )
640- except OSError:
641- pass
642-
643- modified = False
644- for line in pgpass:
645- if (
646- line.hostname in ("*", parsed_dsn["host"])
647- and line.port in ("*", parsed_dsn["port"])
648- and line.database in ("*", parsed_dsn["dbname"])
649- and line.username in ("*", parsed_dsn["user"])
650- ):
651- if line.password != parsed_dsn["password"]:
652- line.password = parsed_dsn["password"]
653- modified = True
654- break
655- else:
656- pgpass.append(
657- PgPassLine(
658- hostname=parsed_dsn["host"],
659- port=parsed_dsn["port"],
660- database=parsed_dsn["dbname"],
661- username=parsed_dsn["user"],
662- password=parsed_dsn["password"],
663- )
664- )
665- modified = True
666-
667- if modified:
668- uid = pwd.getpwnam(base.user()).pw_uid
669- gid = grp.getgrnam(base.user()).gr_gid
670- with open(pgpass_path, "w") as f:
671- for line in pgpass:
672- print(
673- ":".join(
674- [
675- escape(line.hostname),
676- escape(line.port),
677- escape(line.database),
678- escape(line.username),
679- escape(line.password),
680- ]
681- ),
682- file=f,
683- )
684- os.fchown(f.fileno(), uid, gid)
685- os.fchmod(f.fileno(), 0o600)
686-
687-
688-def strip_dsn_authentication(dsn):
689- parsed_dsn = parse_dsn(dsn)
690- parsed_dsn.pop("user", None)
691- parsed_dsn.pop("password", None)
692- return make_dsn(**parsed_dsn)
693diff --git a/charm/layer/launchpad-base/metadata.yaml b/charm/layer/launchpad-base/metadata.yaml
694deleted file mode 100644
695index eafdcc0..0000000
696--- a/charm/layer/launchpad-base/metadata.yaml
697+++ /dev/null
698@@ -1,5 +0,0 @@
699-requires:
700- db:
701- interface: pgsql
702- rabbitmq:
703- interface: rabbitmq
704diff --git a/charm/layer/launchpad-base/reactive/launchpad-base.py b/charm/layer/launchpad-base/reactive/launchpad-base.py
705deleted file mode 100644
706index a3473f7..0000000
707--- a/charm/layer/launchpad-base/reactive/launchpad-base.py
708+++ /dev/null
709@@ -1,114 +0,0 @@
710-# Copyright 2022 Canonical Ltd. This software is licensed under the
711-# GNU Affero General Public License version 3 (see the file LICENSE).
712-
713-import subprocess
714-
715-from charmhelpers.core import hookenv
716-from charms.launchpad.base import (
717- configure_lazr,
718- configure_rsync,
719- ensure_lp_directories,
720- get_service_config,
721- strip_dsn_authentication,
722- update_pgpass,
723-)
724-from charms.reactive import hook, remove_state, set_state, when, when_not
725-from ols import base, postgres
726-from psycopg2.extensions import parse_dsn
727-
728-
729-# Monkey-patch layer:ols.
730-def create_virtualenv(wheels_dir, codedir, python_exe):
731- subprocess.run(
732- ["make", "compile", "PYTHON={}".format(python_exe)],
733- cwd=codedir,
734- check=True,
735- )
736-
737-
738-base.create_virtualenv = create_virtualenv
739-
740-
741-@when("rabbitmq.connected")
742-def prepare_rabbitmq(rabbitmq):
743- config = hookenv.config()
744- rabbitmq.request_access(config["rabbitmq_user"], config["domain"])
745-
746-
747-def get_rabbitmq_uris(rabbitmq):
748- for conversation in rabbitmq.conversations():
749- for relation_id in conversation.relation_ids:
750- for unit in hookenv.related_units(relation_id):
751- hostname = hookenv.relation_get(
752- "private-address", unit, relation_id
753- )
754- vhost = rabbitmq.vhost()
755- username = rabbitmq.username()
756- password = rabbitmq.password()
757- yield f"amqp://{username}:{password}@{hostname}/{vhost}"
758-
759-
760-@when("ols.configured", "db.master.available", "rabbitmq.available")
761-@when_not("launchpad.base.configured")
762-def configure(db, rabbitmq):
763- ensure_lp_directories()
764- config = get_service_config()
765- db_primary, db_standby = postgres.get_db_uris(db)
766- # XXX cjwatson 2022-09-23: Mangle the connection strings into forms
767- # Launchpad understands. In the long term it would be better to have
768- # Launchpad be able to consume unmodified connection strings.
769- for dsn in [db_primary] + db_standby:
770- update_pgpass(dsn)
771- config["db_primary"] = strip_dsn_authentication(db_primary)
772- config["db_standby"] = ",".join(
773- strip_dsn_authentication(dsn) for dsn in db_standby
774- )
775- # XXX cjwatson 2022-09-23: This is a layering violation, since it's
776- # specific to the appserver. We need to teach Launchpad to be able to
777- # log in as one role and then switch to another.
778- config["db_user"] = parse_dsn(db_primary)["user"]
779- config["rabbitmq_broker_urls"] = sorted(get_rabbitmq_uris(rabbitmq))
780- configure_lazr(
781- config,
782- "launchpad-base-lazr.conf",
783- "launchpad-base-lazr.conf",
784- )
785- configure_lazr(
786- config,
787- "launchpad-base-secrets-lazr.conf",
788- "launchpad-base-secrets-lazr.conf",
789- secret=True,
790- )
791- configure_rsync(
792- config, "launchpad-base-rsync.conf", "010-launchpad-base.conf"
793- )
794- set_state("launchpad.base.configured")
795-
796-
797-@hook("upgrade-charm")
798-def upgrade_charm():
799- # The ols layer takes care of removing the ols.service.installed,
800- # ols.configured, and service.configured states. Remove
801- # launchpad.base.configured as well so that we have an opportunity to
802- # rewrite base configuration files.
803- remove_state("launchpad.base.configured")
804-
805-
806-@when("config.changed.build_label")
807-def build_label_changed():
808- remove_state("ols.service.installed")
809- remove_state("ols.configured")
810- remove_state("launchpad.base.configured")
811- remove_state("service.configured")
812-
813-
814-@when("config.changed")
815-def config_changed():
816- remove_state("launchpad.base.configured")
817- remove_state("service.configured")
818-
819-
820-@hook("{requires:rabbitmq}-relation-changed")
821-def rabbitmq_relation_changed(rabbitmq):
822- remove_state("launchpad.base.configured")
823- remove_state("service.configured")
824diff --git a/charm/layer/launchpad-base/templates/launchpad-base-lazr.conf b/charm/layer/launchpad-base/templates/launchpad-base-lazr.conf
825deleted file mode 100644
826index 9e597f5..0000000
827--- a/charm/layer/launchpad-base/templates/launchpad-base-lazr.conf
828+++ /dev/null
829@@ -1,136 +0,0 @@
830-# Public configuration data. The contents of this file may be freely shared
831-# with developers if needed for debugging.
832-
833-# A schema's sections, keys, and values are automatically inherited, except
834-# for '.optional' sections. Update this config to override key values.
835-# Values are strings, except for numbers that look like ints. The tokens
836-# true, false, and none are treated as True, False, and None.
837-
838-{% from "macros.j2" import opt -%}
839-
840-[meta]
841-extends: ../lib/lp/services/config/schema-lazr.conf
842-
843-[answertracker]
844-email_domain: answers.{{ domain }}
845-
846-[canonical]
847-bounce_address: {{ bounce_address }}
848-cron_control_url: {{ cron_control_url }}
849-pid_dir: {{ var_dir }}
850-
851-[charms]
852-{{- opt("charmhub_secrets_public_key", charmhub_secrets_public_key) }}
853-{{- opt("charmhub_storage_url", charmhub_storage_url) }}
854-{{- opt("charmhub_url", charmhub_url) }}
855-
856-[codehosting]
857-{%- if domain_bzr %}
858-authentication_endpoint: http://{{ domain_xmlrpc_private }}:{{ port_xmlrpc }}/authserver
859-bzr_lp_prefix: {{ bzr_lp_prefix }}
860-codehosting_endpoint: http://{{ domain_xmlrpc_private }}:{{ port_xmlrpc }}/codehosting
861-{{- opt("internal_bzr_api_endpoint", internal_bzr_api_endpoint) }}
862-lp_url_hosts: {{ bzr_lp_url_hosts }}
863-secure_codebrowse_root: https://{{ domain_bzr }}/
864-supermirror_root: http://{{ domain_bzr }}
865-{%- endif %}
866-{%- if domain_git %}
867-internal_git_api_endpoint: http://{{ domain_git }}:19417/
868-git_anon_root: git://{{ domain_git }}/
869-git_browse_root: https://{{ domain_git }}/
870-git_ssh_root: git+ssh://{{ domain_git }}/
871-{{- opt("loose_objects_threshold", git_loose_objects_threshold) }}
872-{{- opt("packs_threshold", git_packs_threshold) }}
873-{%- endif %}
874-
875-[database]
876-{{- opt("db_statement_timeout", db_statement_timeout) }}
877-rw_main_primary: {{ db_primary }}
878-rw_main_standby: {{ db_standby or db_primary }}
879-{{- opt("soft_request_timeout", soft_request_timeout) }}
880-
881-[error_reports]
882-error_dir: {{ oopses_dir }}
883-oops_prefix: {{ oops_prefix }}
884-
885-[gpghandler]
886-upload_keys: {{ gpg_upload_keys }}
887-
888-[launchpad]
889-bugs_domain: bugs.{{ domain }}
890-{{- opt("bzr_imports_root_url", bzr_imports_root_url) }}
891-{{- opt("candid_service_root", candid_service_root) }}
892-code_domain: code.{{ domain }}
893-config_overlay_dir: {{ secrets_dir }}
894-dbuser: {{ db_user }}
895-default_batch_size: {{ default_batch_size }}
896-{{- opt("geoip_database", geoip_database) }}
897-{{- opt("http_proxy", http_proxy) }}
898-is_demo: {{ is_demo }}
899-{{- opt("openid_alternate_provider_roots", openid_alternate_provider_roots) }}
900-openid_provider_root: {{ openid_provider_root }}
901-{{- opt("site_message", site_message) }}
902-
903-[librarian]
904-authentication_endpoint: http://{{ domain_xmlrpc_private }}:{{ port_xmlrpc }}/authserver
905-{{- opt("download_host", librarian_download_host) }}
906-
907-[mailman]
908-{{- opt("build_host_name", domain_lists) }}
909-
910-[malone]
911-buglist_batch_size: {{ default_batch_size }}
912-bugmail_error_from_address: noreply@bugs.{{ domain }}
913-
914-{%- if statsd_environment %}
915-[statsd]
916-host: 127.0.0.1
917-port: 8125
918-prefix: lp
919-environment: {{ statsd_environment }}
920-{%- endif %}
921-
922-[uploader]
923-{%- if uploader_default_recipient %}
924-default_recipient_address: {{ parseaddr(uploader_default_recipient)[1] }}
925-default_recipient_name: {{ parseaddr(uploader_default_recipient)[0] }}
926-{%- endif %}
927-{%- if uploader_default_sender %}
928-default_sender_address: {{ parseaddr(uploader_default_sender)[1] }}
929-default_sender_name: {{ parseaddr(uploader_default_sender)[0] }}
930-{%- endif %}
931-
932-[vhost.mainsite]
933-hostname: {{ domain }}
934-althostnames: localhost, www.{{ domain }}
935-openid_delegate_profile: true
936-
937-[vhost.answers]
938-hostname: answers.{{ domain }}
939-
940-[vhost.api]
941-hostname: api.{{ domain }}
942-
943-[vhost.blueprints]
944-hostname: blueprints.{{ domain }}
945-
946-[vhost.bugs]
947-hostname: bugs.{{ domain }}
948-
949-[vhost.code]
950-hostname: code.{{ domain }}
951-
952-[vhost.feeds]
953-hostname: feeds.{{ domain }}
954-# Don't link to HTTPS for feeds.
955-rooturl: http://feeds.{{ domain }}/
956-
957-[vhost.translations]
958-hostname: translations.{{ domain }}
959-
960-[vhost.xmlrpc]
961-hostname: xmlrpc.{{ domain }}
962-
963-[vhost.xmlrpc_private]
964-hostname: {{ domain_xmlrpc_private }}
965-
966diff --git a/charm/layer/launchpad-base/templates/launchpad-base-rsync.conf b/charm/layer/launchpad-base/templates/launchpad-base-rsync.conf
967deleted file mode 100644
968index 2921300..0000000
969--- a/charm/layer/launchpad-base/templates/launchpad-base-rsync.conf
970+++ /dev/null
971@@ -1,8 +0,0 @@
972-
973-[lp-logs]
974- path = {{ logs_dir }}
975- comment = LP Logs
976- list = false
977- read only = true
978- hosts allow = {{ log_hosts_allow }}
979-
980diff --git a/charm/layer/launchpad-base/templates/launchpad-base-secrets-lazr.conf b/charm/layer/launchpad-base/templates/launchpad-base-secrets-lazr.conf
981deleted file mode 100644
982index 5b45030..0000000
983--- a/charm/layer/launchpad-base/templates/launchpad-base-secrets-lazr.conf
984+++ /dev/null
985@@ -1,18 +0,0 @@
986-# Secret configuration data. This is stored in an overlay directory, mainly
987-# to avoid accidental information leaks from the public configuration file.
988-# Entries in this file should not be shared with developers, although the
989-# structure of the file is not secret, only configuration values.
990-
991-# A schema's sections, keys, and values are automatically inherited, except
992-# for '.optional' sections. Update this config to override key values.
993-# Values are strings, except for numbers that look like ints. The tokens
994-# true, false, and none are treated as True, False, and None.
995-
996-{% from "macros.j2" import opt -%}
997-
998-[mailman]
999-{{- opt("shared_secret", mailman_shared_secret) }}
1000-
1001-[rabbitmq]
1002-broker_urls: {{ rabbitmq_broker_urls|join(" ") }}
1003-
1004diff --git a/charm/layer/launchpad-base/templates/macros.j2 b/charm/layer/launchpad-base/templates/macros.j2
1005deleted file mode 100644
1006index 8cddb14..0000000
1007--- a/charm/layer/launchpad-base/templates/macros.j2
1008+++ /dev/null
1009@@ -1,6 +0,0 @@
1010-{#- An optional configuration entry. #}
1011-{%- macro opt(name, value) %}
1012-{%- if value is defined and value is not none %}
1013-{{ name }}: {{ value }}
1014-{%- endif %}
1015-{%- endmacro %}
1016diff --git a/charm/packages.txt b/charm/packages.txt
1017index c33fce5..7cd3faf 100644
1018--- a/charm/packages.txt
1019+++ b/charm/packages.txt
1020@@ -1,3 +1,2 @@
1021 flake8
1022-python-codetree
1023 squashfuse

Subscribers

People subscribed via source and target branches

to status/vote changes: