Merge ~pjdc/ubuntu-mirror-charm/+git/ubuntu-mirror-charm:unsafe-http into ubuntu-mirror-charm:master

Proposed by Paul Collins
Status: Merged
Approved by: Jay Kuri
Approved revision: ccc254882d6bde8a71d240193d9e07a96e4f036e
Merged at revision: 6134dc9c045eb10b9efda2f679d69c87e0172bde
Proposed branch: ~pjdc/ubuntu-mirror-charm/+git/ubuntu-mirror-charm:unsafe-http
Merge into: ubuntu-mirror-charm:master
Diff against target: 102 lines (+27/-7)
3 files modified
hooks/Config.py (+14/-5)
hooks/hooks.py (+8/-2)
templates/apache-ubuntu.tmpl (+5/-0)
Reviewer Review Type Date Requested Status
Canonical IS Reviewers Pending
Ubuntu Mirror Charm Maintainers Pending
Review via email: mp+382189@code.launchpad.net

Commit message

add support for "ubuntu-unsafe" role, to allow setting HTTPProtocolOptions unsafe

To post a comment you must log in.
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

This merge proposal is being monitored by mergebot. Change the status to Approved to merge.

Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Change successfully merged at revision 6134dc9c045eb10b9efda2f679d69c87e0172bde

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/hooks/Config.py b/hooks/Config.py
2index 60c9928..5303a5f 100755
3--- a/hooks/Config.py
4+++ b/hooks/Config.py
5@@ -112,13 +112,22 @@ class Config:
6 if role in self._mirror_map:
7 return self._mirror_map[role]
8
9+ # Some roles are derived from others, which we handle here
10+ if role == 'ubuntu-unsafe':
11+ base_role = 'ubuntu'
12+ else:
13+ base_role = role
14+
15 # Load the map details
16- map = {}
17+ map = {
18+ 'unsafe': role.endswith('-unsafe'),
19+ 'tmpl_file': str("apache-{}.tmpl".format(base_role)),
20+ }
21 for key in ["name", "aliases", "path", "description", "rsync_log",
22 "command", "source_url", "rsync_auth",
23 "sync_time", "trigger", "apache_late_extra",
24 "apache_early_extra"]:
25- config_key = "mirror_%s_%s" % (role, key)
26+ config_key = "mirror_%s_%s" % (base_role, key)
27 try:
28 value = config(config_key)
29 except ValueError:
30@@ -130,14 +139,14 @@ class Config:
31 try:
32 map[key] = str(base64.b64decode(value))
33 except TypeError:
34- log("CHARM: Unable to decode {} trigger".format(role))
35+ log("CHARM: Unable to decode {} trigger".format(base_role))
36 map[key] = ""
37 elif key in ["aliases", "rsync_auth"]:
38 # List/dict expanson needed
39 try:
40 map[key] = json.loads(str(value))
41 except ValueError:
42- log("CHARM: Unable to decode {} aliases".format(role))
43+ log("CHARM: Unable to decode {} aliases".format(base_role))
44 map[key] = []
45 elif key in ["rsync_log"]:
46 # No conversion needed
47@@ -212,7 +221,7 @@ class Config:
48
49 # This should contain a list of all roles the charm supports
50 def role_list(self):
51- return ["cdimage", "ports", "releases", "ubuntu", "cloud-image", "simple-streams"]
52+ return ["cdimage", "ports", "releases", "ubuntu", "cloud-image", "simple-streams", "ubuntu-unsafe"]
53
54 def roles(self):
55 if not config("role_map"):
56diff --git a/hooks/hooks.py b/hooks/hooks.py
57index db609fb..c42f725 100755
58--- a/hooks/hooks.py
59+++ b/hooks/hooks.py
60@@ -341,18 +341,24 @@ def configure_apache():
61 log("CHARM: Missing details - skipping {}".format(role))
62 else:
63 role_config = get_role_config(roles, hostname, role)
64+ if mirror['unsafe'] and 'addresses' not in role_config:
65+ log("CHARM: {} has no addresses defined - not configuring".format(role))
66+ continue
67 wanted_vhosts.append(role)
68 sites_available = os.path.join(available_dir, role + ".conf")
69 sites_enabled = os.path.join(enabled_dir, role + ".conf")
70 tmpl_data = mirror
71 tmpl_data.update(apache_tls_settings)
72+ if 'name' in role_config:
73+ tmpl_data['name'] = role_config['name']
74+ # If name is overridden then aliases must be too:
75+ tmpl_data['aliases'] = role_config.get('aliases', [])
76 tmpl_data["logdir"] = apache_logdir
77 tmpl_data["addresses"] = role_config.get('addresses', ['*'])
78 all_addresses.update(tmpl_data["addresses"])
79 tmpl_data["ports"] = [80, 443] if role_config.get('https') else [80]
80 all_ports.update(tmpl_data["ports"])
81- tmpl_file = str("apache-{}.tmpl".format(role))
82- file_from_template(tmpl_file, sites_available, tmpl_data)
83+ file_from_template(mirror['tmpl_file'], sites_available, tmpl_data)
84 symlink(sites_available, sites_enabled)
85
86 # And make sure the docroot exists
87diff --git a/templates/apache-ubuntu.tmpl b/templates/apache-ubuntu.tmpl
88index 2c2df87..5dbb4fb 100644
89--- a/templates/apache-ubuntu.tmpl
90+++ b/templates/apache-ubuntu.tmpl
91@@ -11,6 +11,11 @@ ${apache_early_extra}
92 ErrorLog ${logdir}/${name}-error.log
93 LogFormat "%h %p %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined-port
94
95+#if $unsafe
96+ # LP:1868232 (cRT#125271)
97+ HTTPProtocolOptions unsafe
98+
99+#end if
100 #if $port == 443
101 SSLEngine On
102 SSLCertificateFile /etc/apache2/ssl/${name}.crt

Subscribers

People subscribed via source and target branches