Merge ~ines-almeida/launchpad:update-ppa-charms-configuration into launchpad:master

Proposed by Ines Almeida
Status: Merged
Approved by: Ines Almeida
Approved revision: 440c26cfe1804519c7ec335ae7dd1611a6d934c0
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~ines-almeida/launchpad:update-ppa-charms-configuration
Merge into: launchpad:master
Diff against target: 125 lines (+40/-25)
4 files modified
charm/launchpad-ppa-publisher/config.yaml (+19/-3)
charm/launchpad-ppa-publisher/reactive/launchpad-ppa-publisher.py (+14/-15)
charm/launchpad-ppa-publisher/templates/vhosts/ppa.conf.j2 (+5/-5)
charm/launchpad-ppa-publisher/templates/vhosts/private-ppa.conf.j2 (+2/-2)
Reviewer Review Type Date Requested Status
Guruprasad Approve
Colin Watson (community) Approve
Review via email: mp+450161@code.launchpad.net

Commit message

Update PPA Publisher charm to allow setting PPA domains separately

This will allow specifying public and private domains for the PPA service in each environment, and an alias alternative (which we want to allow for legacy purposes)

Description of the change

This will be useful for setting a different PPA domain for qastaging, for example. We want to set it to `qastaging.content.paddev.net` instead of the general domain `qastaging.paddev.net`

To post a comment you must log in.
Revision history for this message
Guruprasad (lgp171188) :
review: Needs Fixing
Revision history for this message
Colin Watson (cjwatson) :
Revision history for this message
Ines Almeida (ines-almeida) wrote :

These changes will require a change to the mojo specs MP, which I will do after this one is merged in

Revision history for this message
Colin Watson (cjwatson) :
review: Approve
Revision history for this message
Guruprasad (lgp171188) :
review: Approve
Revision history for this message
Ines Almeida (ines-almeida) :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/charm/launchpad-ppa-publisher/config.yaml b/charm/launchpad-ppa-publisher/config.yaml
2index 6c40160..9829bf2 100644
3--- a/charm/launchpad-ppa-publisher/config.yaml
4+++ b/charm/launchpad-ppa-publisher/config.yaml
5@@ -3,12 +3,28 @@ options:
6 type: boolean
7 default: true
8 description: If true, enable jobs that may change the database.
9- domain_alternate:
10+ domain_ppa_private:
11+ type: string
12+ default: private-ppa.launchpad.test
13+ description: |
14+ Domain for private PPA requests.
15+ domain_ppa_private_alt:
16+ type: string
17+ default:
18+ description: |
19+ If set, the requests to this alternative domain will also be allowed for
20+ accessing private PPAs.
21+ domain_ppa_public:
22+ type: string
23+ default: ppa.launchpad.test
24+ description: |
25+ Domain for public PPA requests.
26+ domain_ppa_public_alt:
27 type: string
28 default:
29 description: |
30- If set, extra PPA apache configuration will be created for this extra
31- domain.
32+ If set, the requests to this alternative domain will also be allowed for
33+ accessing public PPAs.
34 domain_ppa_buildd:
35 type: string
36 default:
37diff --git a/charm/launchpad-ppa-publisher/reactive/launchpad-ppa-publisher.py b/charm/launchpad-ppa-publisher/reactive/launchpad-ppa-publisher.py
38index 89a4445..e3c5b75 100644
39--- a/charm/launchpad-ppa-publisher/reactive/launchpad-ppa-publisher.py
40+++ b/charm/launchpad-ppa-publisher/reactive/launchpad-ppa-publisher.py
41@@ -126,26 +126,24 @@ def memcache_relation_changed(memcache):
42 @when("apache-website.available", "service.configured")
43 @when_not("service.apache-website.configured")
44 def configure_apache_website():
45- apache_website = endpoint_from_flag("apache-website.available")
46 config = get_service_config()
47+ if not (config["domain_ppa_public"] and config["domain_ppa_private"]):
48+ hookenv.status_set(
49+ "blocked",
50+ "Apache configuration requires `domain_ppa_public` and "
51+ "`domain_ppa_private`",
52+ )
53+ return
54+
55 config["data_dir"] = get_data_dir()
56 config["ppa_archive_root"] = ppa_archive_root()
57 config["ppa_archive_private_root"] = ppa_archive_private()
58
59- domain = config["domain"]
60- config["domain_ppa"] = f"ppa.{domain}"
61- config["domain_ppa_private"] = f"private-ppa.{domain}"
62-
63- # If "domain_alternate" is set, we set a server alias for the alternate
64- # domain. This is mainly for legacy reasons: we want to keep vhost
65- # configurations for "(private-)ppa.launchpadcontent.net" along side
66- # "ppa.launchpad.net".
67+ # If the config value for "domain_ppa_<public/private>_alt" are set, we set
68+ # a server alias for the alternative domain in the Apache configuration.
69+ # This is mainly for legacy reasons: we want to keep vhost configurations
70+ # for "(private-)ppa.launchpadcontent.net" along side "ppa.launchpad.net".
71 # See https://blog.launchpad.net/ppa/new-domain-names-for-ppas.
72- alt_domain = config["domain_alternate"]
73- if alt_domain:
74- config["domain_ppa_alternate"] = f"ppa.{alt_domain}"
75- config["domain_ppa_private_alternate"] = f"private-ppa.{alt_domain}"
76-
77 site_configs = []
78 site_configs.append(templating.render("vhosts/ppa.conf.j2", None, config))
79 site_configs.append(
80@@ -158,8 +156,9 @@ def configure_apache_website():
81 )
82 )
83
84+ apache_website = endpoint_from_flag("apache-website.available")
85 apache_website.set_remote(
86- domain=domain,
87+ domain=config["domain"],
88 enabled="true",
89 ports="80",
90 site_config="\n".join(site_configs),
91diff --git a/charm/launchpad-ppa-publisher/templates/vhosts/ppa.conf.j2 b/charm/launchpad-ppa-publisher/templates/vhosts/ppa.conf.j2
92index d6c8e42..f74ba78 100644
93--- a/charm/launchpad-ppa-publisher/templates/vhosts/ppa.conf.j2
94+++ b/charm/launchpad-ppa-publisher/templates/vhosts/ppa.conf.j2
95@@ -1,12 +1,12 @@
96 <VirtualHost *:80>
97- ServerName {{ domain_ppa }}
98-{%- if domain_alternate %}
99- ServerAlias {{ domain_ppa_alternate }}
100+ ServerName {{ domain_ppa_public }}
101+{%- if domain_ppa_public_alt %}
102+ ServerAlias {{ domain_ppa_public_alt }}
103 {%- endif %}
104 DocumentRoot {{ ppa_archive_root }}/
105
106- CustomLog /var/log/apache2/{{ domain_ppa }}-access.log combined
107- ErrorLog /var/log/apache2/{{ domain_ppa }}-error.log
108+ CustomLog /var/log/apache2/{{ domain_ppa_public }}-access.log combined
109+ ErrorLog /var/log/apache2/{{ domain_ppa_public }}-error.log
110
111 <Files ~ "Release(\.gpg)?|InRelease|Packages\.(xz|bz2|gz)|Sources\.(xz|bz2|gz)?$">
112 ExpiresActive On
113diff --git a/charm/launchpad-ppa-publisher/templates/vhosts/private-ppa.conf.j2 b/charm/launchpad-ppa-publisher/templates/vhosts/private-ppa.conf.j2
114index 9009aed..e983fc1 100644
115--- a/charm/launchpad-ppa-publisher/templates/vhosts/private-ppa.conf.j2
116+++ b/charm/launchpad-ppa-publisher/templates/vhosts/private-ppa.conf.j2
117@@ -1,7 +1,7 @@
118 <VirtualHost *:80>
119 ServerName {{ domain_ppa_private }}
120-{%- if domain_alternate %}
121- ServerAlias {{ domain_ppa_private_alternate }}
122+{%- if domain_ppa_private_alt %}
123+ ServerAlias {{ domain_ppa_private_alt }}
124 {%- endif %}
125 DocumentRoot {{ ppa_archive_private_root }}/
126

Subscribers

People subscribed via source and target branches

to status/vote changes: