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
diff --git a/lib/haproxy.py b/lib/haproxy.py
index 9f7691c..1dfa3e4 100644
--- a/lib/haproxy.py
+++ b/lib/haproxy.py
@@ -119,6 +119,7 @@ listen {name}
119{indent}capture request header X-Cache-Request-ID len 60119{indent}capture request header X-Cache-Request-ID len 60
120{redirect_config}{backend_config}{default_backend}"""120{redirect_config}{backend_config}{default_backend}"""
121 backend_conf = '{indent}use_backend backend-{backend} if {{ hdr(Host) -i {site_name} }}\n'121 backend_conf = '{indent}use_backend backend-{backend} if {{ hdr(Host) -i {site_name} }}\n'
122 backend_conf_no_logging = '{indent}http-request set-log-level silent if {{ hdr(Host) -i {site_name} }}\n'
122 redirect_conf = '{indent}redirect scheme https code 301 if {{ hdr(Host) -i {site_name} }} !{{ ssl_fc }}\n'123 redirect_conf = '{indent}redirect scheme https code 301 if {{ hdr(Host) -i {site_name} }} !{{ ssl_fc }}\n'
123124
124 rendered_output = []125 rendered_output = []
@@ -153,6 +154,9 @@ listen {name}
153 if tls_path:154 if tls_path:
154 tls_cert_bundle_paths.append(tls_path)155 tls_cert_bundle_paths.append(tls_path)
155156
157 if site_conf.get('disable_logging'):
158 backend_config.append(backend_conf_no_logging.format(site_name=site_name, indent=INDENT))
159
156 # HTTP -> HTTPS redirect160 # HTTP -> HTTPS redirect
157 if redirect_http_to_https:161 if redirect_http_to_https:
158 redirect_config.append(redirect_conf.format(site_name=site_name, indent=INDENT))162 redirect_config.append(redirect_conf.format(site_name=site_name, indent=INDENT))
diff --git a/reactive/content_cache.py b/reactive/content_cache.py
index 9e7e0ad..910cac8 100644
--- a/reactive/content_cache.py
+++ b/reactive/content_cache.py
@@ -286,6 +286,8 @@ def configure_haproxy(): # NOQA: C901 LP#1825084
286 except ValueError as e:286 except ValueError as e:
287 hookenv.log('Only integer ports are supported: {}'.format(e))287 hookenv.log('Only integer ports are supported: {}'.format(e))
288288
289 new_conf[cached_site]['disable_logging'] = site_conf.get('disable-logging')
290
289 # XXX: Reduce complexity here291 # XXX: Reduce complexity here
290292
291 for location, loc_conf in site_conf.get('locations', {}).items():293 for location, loc_conf in site_conf.get('locations', {}).items():
diff --git a/tests/unit/files/content_cache_rendered_haproxy_test_output.txt b/tests/unit/files/content_cache_rendered_haproxy_test_output.txt
index a37a6c8..224a2cc 100644
--- a/tests/unit/files/content_cache_rendered_haproxy_test_output.txt
+++ b/tests/unit/files/content_cache_rendered_haproxy_test_output.txt
@@ -90,6 +90,7 @@ listen combined-80
90 use_backend backend-cached-site6-local if { hdr(Host) -i site6.local }90 use_backend backend-cached-site6-local if { hdr(Host) -i site6.local }
91 use_backend backend-cached-site9-local if { hdr(Host) -i site9.local }91 use_backend backend-cached-site9-local if { hdr(Host) -i site9.local }
92 use_backend backend-cached-site10-local if { hdr(Host) -i site10.local }92 use_backend backend-cached-site10-local if { hdr(Host) -i site10.local }
93 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 use_backend backend-cached-site11-local if { hdr(Host) -i site11.local }
94 default_backend backend-cached-site3-local95 default_backend backend-cached-site3-local
9596
diff --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
index ed69e91..4e159f5 100644
--- 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
@@ -90,6 +90,7 @@ listen combined-80
90 use_backend backend-cached-site6-local if { hdr(Host) -i site6.local }90 use_backend backend-cached-site6-local if { hdr(Host) -i site6.local }
91 use_backend backend-cached-site9-local if { hdr(Host) -i site9.local }91 use_backend backend-cached-site9-local if { hdr(Host) -i site9.local }
92 use_backend backend-cached-site10-local if { hdr(Host) -i site10.local }92 use_backend backend-cached-site10-local if { hdr(Host) -i site10.local }
93 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 use_backend backend-cached-site11-local if { hdr(Host) -i site11.local }
94 default_backend backend-cached-site3-local95 default_backend backend-cached-site3-local
9596
diff --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
index b1e58f1..7d96410 100644
--- 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
@@ -90,6 +90,7 @@ listen combined-80
90 use_backend backend-cached-site6-local if { hdr(Host) -i site6.local }90 use_backend backend-cached-site6-local if { hdr(Host) -i site6.local }
91 use_backend backend-cached-site9-local if { hdr(Host) -i site9.local }91 use_backend backend-cached-site9-local if { hdr(Host) -i site9.local }
92 use_backend backend-cached-site10-local if { hdr(Host) -i site10.local }92 use_backend backend-cached-site10-local if { hdr(Host) -i site10.local }
93 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 use_backend backend-cached-site11-local if { hdr(Host) -i site11.local }
94 default_backend backend-cached-site3-local95 default_backend backend-cached-site3-local
9596
diff --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
index bb18c43..6ea422b 100644
--- 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
@@ -91,6 +91,7 @@ listen combined-80
91 use_backend backend-cached-site6-local if { hdr(Host) -i site6.local }91 use_backend backend-cached-site6-local if { hdr(Host) -i site6.local }
92 use_backend backend-cached-site9-local if { hdr(Host) -i site9.local }92 use_backend backend-cached-site9-local if { hdr(Host) -i site9.local }
93 use_backend backend-cached-site10-local if { hdr(Host) -i site10.local }93 use_backend backend-cached-site10-local if { hdr(Host) -i site10.local }
94 http-request set-log-level silent if { hdr(Host) -i site11.local }
94 use_backend backend-cached-site11-local if { hdr(Host) -i site11.local }95 use_backend backend-cached-site11-local if { hdr(Host) -i site11.local }
95 default_backend backend-cached-site3-local96 default_backend backend-cached-site3-local
9697
diff --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
index a788d15..d6b3c48 100644
--- 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
@@ -90,6 +90,7 @@ listen combined-80
90 use_backend backend-cached-site6-local if { hdr(Host) -i site6.local }90 use_backend backend-cached-site6-local if { hdr(Host) -i site6.local }
91 use_backend backend-cached-site9-local if { hdr(Host) -i site9.local }91 use_backend backend-cached-site9-local if { hdr(Host) -i site9.local }
92 use_backend backend-cached-site10-local if { hdr(Host) -i site10.local }92 use_backend backend-cached-site10-local if { hdr(Host) -i site10.local }
93 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 use_backend backend-cached-site11-local if { hdr(Host) -i site11.local }
94 default_backend backend-cached-site3-local95 default_backend backend-cached-site3-local
9596

Subscribers

People subscribed via source and target branches