[MediaWiki-commits] [Gerrit] Allow X-Wikimedia-Debug header to contain multiple fields - change (operations/puppet)
Ori.livneh has submitted this change and it was merged. Change subject: Allow X-Wikimedia-Debug header to contain multiple fields .. Allow X-Wikimedia-Debug header to contain multiple fields In addition to backend selection, I'd like to be able to enable request profiling via the XWD header. Since there may be other behaviors that we want to be able to control with the header, allow the header to consist of semicolon-separated fields, each of which may either be an attribute name or an attribute name=value pair. The 'backend' attribute may be used to specify the backend. For back-compat, if the header is not well-formed, treat the whole header value as the backend value. Change-Id: If6e20ca7f2bcf1d108f7d46539803358de9c2a24 --- M modules/debug_proxy/templates/debug_proxy.nginx.erb 1 file changed, 15 insertions(+), 3 deletions(-) Approvals: Ori.livneh: Verified; Looks good to me, approved diff --git a/modules/debug_proxy/templates/debug_proxy.nginx.erb b/modules/debug_proxy/templates/debug_proxy.nginx.erb index 90a9a29..db8ee38 100644 --- a/modules/debug_proxy/templates/debug_proxy.nginx.erb +++ b/modules/debug_proxy/templates/debug_proxy.nginx.erb @@ -2,8 +2,20 @@ # application servers that are reserved for debugging, based on # the value of the X-Wikimedia-Debug header. +# The X-Wikimedia-Debug header is made up of semicolon-separated +# fields. Each field may consist of either an attribute name or +# an attribute=value pairs. The block below extracts the value of +# the 'backend' attribute. For backward-compatibility, if the +# header does not contain a well-formed 'backend' attribute, then +# the entire header is used as the backend value. + map $http_x_wikimedia_debug $debug_backend { - <%= @backend_regexp.sub(/^~*/, '~').to_pson %> $http_x_wikimedia_debug; + "~backend=(?[^;]+)" $h; + default $http_x_wikimedia_debug; +} + +map $debug_backend $debug_host { + <%= @backend_regexp.sub(/^~*/, '~').to_pson %> $debug_backend; <%= @backend_aliases.sort.map { |k, v| "#{k.to_pson} #{v.to_pson};" }.join("\n ") %> default 'invalid'; } @@ -16,12 +28,12 @@ resolver <%= @resolver %>; location / { -if ($debug_backend = invalid) { +if ($debug_host = invalid) { return 400; } proxy_buffering off; -proxy_pass $scheme://$debug_backend; +proxy_pass $scheme://$debug_host; proxy_pass_request_headers on; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $host; -- To view, visit https://gerrit.wikimedia.org/r/276100 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: If6e20ca7f2bcf1d108f7d46539803358de9c2a24 Gerrit-PatchSet: 2 Gerrit-Project: operations/puppet Gerrit-Branch: production Gerrit-Owner: Ori.livneh Gerrit-Reviewer: Ori.livneh Gerrit-Reviewer: jenkins-bot <> ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Allow X-Wikimedia-Debug header to contain multiple fields - change (operations/puppet)
Ori.livneh has uploaded a new change for review. https://gerrit.wikimedia.org/r/276100 Change subject: Allow X-Wikimedia-Debug header to contain multiple fields .. Allow X-Wikimedia-Debug header to contain multiple fields In addition to backend selection, I'd like to be able to enable request profiling via the XWD header. Since there may be other behaviors that we want to be able to control with the header, allow the header to consist of semicolon-separated fields, each of which may either be an attribute name or an attribute name=value pair. The 'backend' attribute may be used to specify the backend. For back-compat, if the header is not well-formed, treat the whole header value as the backend value. Change-Id: If6e20ca7f2bcf1d108f7d46539803358de9c2a24 --- M modules/debug_proxy/templates/debug_proxy.nginx.erb 1 file changed, 15 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/operations/puppet refs/changes/00/276100/1 diff --git a/modules/debug_proxy/templates/debug_proxy.nginx.erb b/modules/debug_proxy/templates/debug_proxy.nginx.erb index 90a9a29..db8ee38 100644 --- a/modules/debug_proxy/templates/debug_proxy.nginx.erb +++ b/modules/debug_proxy/templates/debug_proxy.nginx.erb @@ -2,8 +2,20 @@ # application servers that are reserved for debugging, based on # the value of the X-Wikimedia-Debug header. +# The X-Wikimedia-Debug header is made up of semicolon-separated +# fields. Each field may consist of either an attribute name or +# an attribute=value pairs. The block below extracts the value of +# the 'backend' attribute. For backward-compatibility, if the +# header does not contain a well-formed 'backend' attribute, then +# the entire header is used as the backend value. + map $http_x_wikimedia_debug $debug_backend { - <%= @backend_regexp.sub(/^~*/, '~').to_pson %> $http_x_wikimedia_debug; + "~backend=(?[^;]+)" $h; + default $http_x_wikimedia_debug; +} + +map $debug_backend $debug_host { + <%= @backend_regexp.sub(/^~*/, '~').to_pson %> $debug_backend; <%= @backend_aliases.sort.map { |k, v| "#{k.to_pson} #{v.to_pson};" }.join("\n ") %> default 'invalid'; } @@ -16,12 +28,12 @@ resolver <%= @resolver %>; location / { -if ($debug_backend = invalid) { +if ($debug_host = invalid) { return 400; } proxy_buffering off; -proxy_pass $scheme://$debug_backend; +proxy_pass $scheme://$debug_host; proxy_pass_request_headers on; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $host; -- To view, visit https://gerrit.wikimedia.org/r/276100 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If6e20ca7f2bcf1d108f7d46539803358de9c2a24 Gerrit-PatchSet: 1 Gerrit-Project: operations/puppet Gerrit-Branch: production Gerrit-Owner: Ori.livneh ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits