Merge ~hloeung/content-cache-charm:logging into content-cache-charm:master

Proposed by Haw Loeung
Status: Merged
Approved by: James Simpson
Approved revision: 776b7afb1a9248e360da0ed70336cd58286ad3f0
Merged at revision: 02c5c69d57f5d9504a93d558f12e52946ba4fa49
Proposed branch: ~hloeung/content-cache-charm:logging
Merge into: content-cache-charm:master
Diff against target: 94 lines (+11/-0)
7 files modified
lib/haproxy.py (+4/-0)
reactive/content_cache.py (+2/-0)
tests/unit/files/content_cache_rendered_haproxy_test_output.txt (+1/-0)
tests/unit/files/content_cache_rendered_haproxy_test_output_auto_maxconns.txt (+1/-0)
tests/unit/files/content_cache_rendered_haproxy_test_output_load_balancing_algorithm.txt (+1/-0)
tests/unit/files/content_cache_rendered_haproxy_test_output_processes_and_threads.txt (+1/-0)
tests/unit/files/content_cache_rendered_haproxy_test_output_processes_and_threads_haproxy2.txt (+1/-0)
Reviewer Review Type Date Requested Status
James Simpson Approve
Canonical IS Reviewers Pending
Review via email: mp+434461@code.launchpad.net

Commit message

Updated so HAProxy also doesn't log if disabled for specific sites

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
James Simpson (jsimpso) wrote :

LGTM

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

Change successfully merged at revision 02c5c69d57f5d9504a93d558f12e52946ba4fa49

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/haproxy.py b/lib/haproxy.py
2index 9f7691c..1dfa3e4 100644
3--- a/lib/haproxy.py
4+++ b/lib/haproxy.py
5@@ -119,6 +119,7 @@ listen {name}
6 {indent}capture request header X-Cache-Request-ID len 60
7 {redirect_config}{backend_config}{default_backend}"""
8 backend_conf = '{indent}use_backend backend-{backend} if {{ hdr(Host) -i {site_name} }}\n'
9+ backend_conf_no_logging = '{indent}http-request set-log-level silent if {{ hdr(Host) -i {site_name} }}\n'
10 redirect_conf = '{indent}redirect scheme https code 301 if {{ hdr(Host) -i {site_name} }} !{{ ssl_fc }}\n'
11
12 rendered_output = []
13@@ -153,6 +154,9 @@ listen {name}
14 if tls_path:
15 tls_cert_bundle_paths.append(tls_path)
16
17+ if site_conf.get('disable_logging'):
18+ backend_config.append(backend_conf_no_logging.format(site_name=site_name, indent=INDENT))
19+
20 # HTTP -> HTTPS redirect
21 if redirect_http_to_https:
22 redirect_config.append(redirect_conf.format(site_name=site_name, indent=INDENT))
23diff --git a/reactive/content_cache.py b/reactive/content_cache.py
24index 9e7e0ad..910cac8 100644
25--- a/reactive/content_cache.py
26+++ b/reactive/content_cache.py
27@@ -286,6 +286,8 @@ def configure_haproxy(): # NOQA: C901 LP#1825084
28 except ValueError as e:
29 hookenv.log('Only integer ports are supported: {}'.format(e))
30
31+ new_conf[cached_site]['disable_logging'] = site_conf.get('disable-logging')
32+
33 # XXX: Reduce complexity here
34
35 for location, loc_conf in site_conf.get('locations', {}).items():
36diff --git a/tests/unit/files/content_cache_rendered_haproxy_test_output.txt b/tests/unit/files/content_cache_rendered_haproxy_test_output.txt
37index a37a6c8..224a2cc 100644
38--- a/tests/unit/files/content_cache_rendered_haproxy_test_output.txt
39+++ b/tests/unit/files/content_cache_rendered_haproxy_test_output.txt
40@@ -90,6 +90,7 @@ listen combined-80
41 use_backend backend-cached-site6-local if { hdr(Host) -i site6.local }
42 use_backend backend-cached-site9-local if { hdr(Host) -i site9.local }
43 use_backend backend-cached-site10-local if { hdr(Host) -i site10.local }
44+ http-request set-log-level silent if { hdr(Host) -i site11.local }
45 use_backend backend-cached-site11-local if { hdr(Host) -i site11.local }
46 default_backend backend-cached-site3-local
47
48diff --git a/tests/unit/files/content_cache_rendered_haproxy_test_output_auto_maxconns.txt b/tests/unit/files/content_cache_rendered_haproxy_test_output_auto_maxconns.txt
49index ed69e91..4e159f5 100644
50--- a/tests/unit/files/content_cache_rendered_haproxy_test_output_auto_maxconns.txt
51+++ b/tests/unit/files/content_cache_rendered_haproxy_test_output_auto_maxconns.txt
52@@ -90,6 +90,7 @@ listen combined-80
53 use_backend backend-cached-site6-local if { hdr(Host) -i site6.local }
54 use_backend backend-cached-site9-local if { hdr(Host) -i site9.local }
55 use_backend backend-cached-site10-local if { hdr(Host) -i site10.local }
56+ http-request set-log-level silent if { hdr(Host) -i site11.local }
57 use_backend backend-cached-site11-local if { hdr(Host) -i site11.local }
58 default_backend backend-cached-site3-local
59
60diff --git a/tests/unit/files/content_cache_rendered_haproxy_test_output_load_balancing_algorithm.txt b/tests/unit/files/content_cache_rendered_haproxy_test_output_load_balancing_algorithm.txt
61index b1e58f1..7d96410 100644
62--- a/tests/unit/files/content_cache_rendered_haproxy_test_output_load_balancing_algorithm.txt
63+++ b/tests/unit/files/content_cache_rendered_haproxy_test_output_load_balancing_algorithm.txt
64@@ -90,6 +90,7 @@ listen combined-80
65 use_backend backend-cached-site6-local if { hdr(Host) -i site6.local }
66 use_backend backend-cached-site9-local if { hdr(Host) -i site9.local }
67 use_backend backend-cached-site10-local if { hdr(Host) -i site10.local }
68+ http-request set-log-level silent if { hdr(Host) -i site11.local }
69 use_backend backend-cached-site11-local if { hdr(Host) -i site11.local }
70 default_backend backend-cached-site3-local
71
72diff --git a/tests/unit/files/content_cache_rendered_haproxy_test_output_processes_and_threads.txt b/tests/unit/files/content_cache_rendered_haproxy_test_output_processes_and_threads.txt
73index bb18c43..6ea422b 100644
74--- a/tests/unit/files/content_cache_rendered_haproxy_test_output_processes_and_threads.txt
75+++ b/tests/unit/files/content_cache_rendered_haproxy_test_output_processes_and_threads.txt
76@@ -91,6 +91,7 @@ listen combined-80
77 use_backend backend-cached-site6-local if { hdr(Host) -i site6.local }
78 use_backend backend-cached-site9-local if { hdr(Host) -i site9.local }
79 use_backend backend-cached-site10-local if { hdr(Host) -i site10.local }
80+ http-request set-log-level silent if { hdr(Host) -i site11.local }
81 use_backend backend-cached-site11-local if { hdr(Host) -i site11.local }
82 default_backend backend-cached-site3-local
83
84diff --git a/tests/unit/files/content_cache_rendered_haproxy_test_output_processes_and_threads_haproxy2.txt b/tests/unit/files/content_cache_rendered_haproxy_test_output_processes_and_threads_haproxy2.txt
85index a788d15..d6b3c48 100644
86--- a/tests/unit/files/content_cache_rendered_haproxy_test_output_processes_and_threads_haproxy2.txt
87+++ b/tests/unit/files/content_cache_rendered_haproxy_test_output_processes_and_threads_haproxy2.txt
88@@ -90,6 +90,7 @@ listen combined-80
89 use_backend backend-cached-site6-local if { hdr(Host) -i site6.local }
90 use_backend backend-cached-site9-local if { hdr(Host) -i site9.local }
91 use_backend backend-cached-site10-local if { hdr(Host) -i site10.local }
92+ http-request set-log-level silent if { hdr(Host) -i site11.local }
93 use_backend backend-cached-site11-local if { hdr(Host) -i site11.local }
94 default_backend backend-cached-site3-local
95

Subscribers

People subscribed via source and target branches