Giuseppe Lavagetto has uploaded a new change for review. https://gerrit.wikimedia.org/r/179468
Change subject: varnish: fix scope warnings in templates ...................................................................... varnish: fix scope warnings in templates Change-Id: I349b5328d504d75f2c71a33fd16713f5d1e03875 Signed-off-by: Giuseppe Lavagetto <[email protected]> --- M modules/varnish/templates/vcl/wikimedia.vcl.erb M templates/varnish/bits.inc.vcl.erb M templates/varnish/mobile-backend.inc.vcl.erb M templates/varnish/mobile-frontend.inc.vcl.erb M templates/varnish/text-backend.inc.vcl.erb M templates/varnish/text-frontend.inc.vcl.erb M templates/varnish/upload-backend.inc.vcl.erb M templates/varnish/upload-frontend.inc.vcl.erb 8 files changed, 29 insertions(+), 29 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/operations/puppet refs/changes/68/179468/1 diff --git a/modules/varnish/templates/vcl/wikimedia.vcl.erb b/modules/varnish/templates/vcl/wikimedia.vcl.erb index 4e23b6f..9ebf172 100644 --- a/modules/varnish/templates/vcl/wikimedia.vcl.erb +++ b/modules/varnish/templates/vcl/wikimedia.vcl.erb @@ -360,15 +360,15 @@ if (resp.http.X-Cache) { if (obj.hits > 0) { - set resp.http.X-Cache = resp.http.X-Cache + ", <%= @hostname + (name.empty? ? "" : " " + name) %> hit (" + obj.hits + ")"; + set resp.http.X-Cache = resp.http.X-Cache + ", <%= @hostname + (@name.empty? ? "" : " " + @name) %> hit (" + obj.hits + ")"; } else { - set resp.http.X-Cache = resp.http.X-Cache + ", <%= @hostname + (name.empty? ? "" : " " + name) %> miss (0)"; + set resp.http.X-Cache = resp.http.X-Cache + ", <%= @hostname + (@name.empty? ? "" : " " + @name) %> miss (0)"; } } else { if (obj.hits > 0) { - set resp.http.X-Cache = "<%= @hostname + (name.empty? ? "" : " " + name) %> hit (" + obj.hits + ")"; + set resp.http.X-Cache = "<%= @hostname + (@name.empty? ? "" : " " + @name) %> hit (" + obj.hits + ")"; } else { - set resp.http.X-Cache = "<%= @hostname + (name.empty? ? "" : " " + name) %> miss (0)"; + set resp.http.X-Cache = "<%= @hostname + (@name.empty? ? "" : " " + @name) %> miss (0)"; } } diff --git a/templates/varnish/bits.inc.vcl.erb b/templates/varnish/bits.inc.vcl.erb index 18d24da..f6424fc 100644 --- a/templates/varnish/bits.inc.vcl.erb +++ b/templates/varnish/bits.inc.vcl.erb @@ -3,18 +3,18 @@ include "errorpage.inc.vcl"; include "hhvm.inc.vcl"; -<% if vcl_config.fetch("cluster_tier", "1") == "1" -%> +<% if @vcl_config.fetch("cluster_tier", "1") == "1" -%> sub mangle_request { /* transform backend url: /<sitename>/load.php -> /w/load.php set host header for backend to <sitename> */ - if ( req.url ~ "^/([a-zA-Z0-9-]+\.)?([a-zA-Z0-9-]+\.)?([a-zA-Z0-9-]+)\.<%= Regexp.escape( cluster_options.fetch( "top_domain", "org" ) ) %>/load\.php" ) { + if ( req.url ~ "^/([a-zA-Z0-9-]+\.)?([a-zA-Z0-9-]+\.)?([a-zA-Z0-9-]+)\.<%= Regexp.escape( @cluster_options.fetch( "top_domain", "org" ) ) %>/load\.php" ) { set bereq.http.host = regsub( req.url, "^/([^/]+)/(.*)$", "\1" ); set bereq.url = regsub( req.url, "^/([^/]+)/load\.php(.*)?", "/w/load.php\2" ); -<% if cluster_options.fetch( "test_hostname", false ) -%> +<% if @cluster_options.fetch( "test_hostname", false ) -%> # Send test.wikipedia.org to the right backend server - if ( req.url ~ "^/<%= Regexp.escape( cluster_options.fetch( "test_hostname" ) ) %>/load\.php" ) { + if ( req.url ~ "^/<%= Regexp.escape( @cluster_options.fetch( "test_hostname" ) ) %>/load\.php" ) { set req.backend = test_wikipedia; } <% end -%> @@ -39,15 +39,15 @@ error 403 "HTTP method not allowed."; } - if (req.http.host == "<%= cluster_options.fetch( "bits_domain", "bits.wikimedia.org" )%>") { + if (req.http.host == "<%= @cluster_options.fetch( "bits_domain", "bits.wikimedia.org" )%>") { /* For https-only wikis, the redirect from http to https for bits assets should occur in varnish instead of apache, since the apache redirect and mediawiki doesn't vary by protocol. This can result in a redirect loop and assets not loading. */ if ( req.url ~ "^/(auditcom|boardgovcom|board|chair|chapcom|checkuser|collab|donate|exec|fdc|grants|internal|movementroles|nomcom|office|otrs-wiki|searchcom|spcom|steward|wikimaniateam)\.wikimedia\.org/" && req.http.X-Forwarded-Proto != "https" ) { - error 301 "https://<%= cluster_options.fetch( "bits_domain", "bits.wikimedia.org" )%>" + req.url; + error 301 "https://<%= @cluster_options.fetch( "bits_domain", "bits.wikimedia.org" )%>" + req.url; } -<% if cluster_options.fetch( "enable_geoiplookup", false ) -%> +<% if @cluster_options.fetch( "enable_geoiplookup", false ) -%> if (req.url == "/geoiplookup") { error 666 "geoiplookup"; } else { @@ -57,7 +57,7 @@ return (lookup); <% end -%> } -<% if cluster_options.fetch( "enable_geoiplookup", false ) -%> +<% if @cluster_options.fetch( "enable_geoiplookup", false ) -%> else if (req.http.host == "geoiplookup.wikimedia.org" ) { error 666 "geoiplookup"; } @@ -81,13 +81,13 @@ return (deliver); } -<% if vcl_config.fetch("cluster_tier", "1") == "1" -%> +<% if @vcl_config.fetch("cluster_tier", "1") == "1" -%> sub vcl_miss { call mangle_request; } <% end -%> -<% if vcl_config.fetch("cluster_tier", "1") == "1" -%> +<% if @vcl_config.fetch("cluster_tier", "1") == "1" -%> /* vcl_pass gets called by hit_for_pass objects in place of vcl_miss, so we need to mangle the request object here as well. Actually, vcl_miss @@ -99,7 +99,7 @@ <% end -%> sub vcl_error { -<% if cluster_options.fetch( "enable_geoiplookup", false ) -%> +<% if @cluster_options.fetch( "enable_geoiplookup", false ) -%> /* Support geoiplookup */ if (obj.status == 666) { call geoip_lookup; @@ -125,7 +125,7 @@ return(deliver); } -<% if vcl_config.fetch("cluster_tier", "1") == "1" -%> +<% if @vcl_config.fetch("cluster_tier", "1") == "1" -%> sub vcl_deliver { call php_mark_engine; } diff --git a/templates/varnish/mobile-backend.inc.vcl.erb b/templates/varnish/mobile-backend.inc.vcl.erb index 36e7ca4..a62f432 100644 --- a/templates/varnish/mobile-backend.inc.vcl.erb +++ b/templates/varnish/mobile-backend.inc.vcl.erb @@ -8,12 +8,12 @@ /* FIXME: restrict access */ if ( req.http.host ~ "^test\." ) { -<% if vcl_config.fetch("cluster_tier", "1") == "1" -%> +<% if @vcl_config.fetch("cluster_tier", "1") == "1" -%> set req.backend = test_wikipedia; <% end -%> return (pass); } -<% if vcl_config.fetch("cluster_tier", "1") == "1" -%> +<% if @vcl_config.fetch("cluster_tier", "1") == "1" -%> if (req.url ~ "^/w/api\.php") { set req.backend = api; } diff --git a/templates/varnish/mobile-frontend.inc.vcl.erb b/templates/varnish/mobile-frontend.inc.vcl.erb index 1c5d386..349cbb3 100644 --- a/templates/varnish/mobile-frontend.inc.vcl.erb +++ b/templates/varnish/mobile-frontend.inc.vcl.erb @@ -103,7 +103,7 @@ set req.hash_ignore_busy = true; unset req.http.Surrogate-Capability; -<% if cluster_options.fetch( "enable_esi", false ) -%> +<% if @cluster_options.fetch( "enable_esi", false ) -%> if (req.http.X-CS == "-TEST") { set req.http.Surrogate-Capability = "frontend=ESI/1.0"; } @@ -122,7 +122,7 @@ } sub vcl_fetch { -<% if cluster_options.fetch( "enable_esi", false ) -%> +<% if @cluster_options.fetch( "enable_esi", false ) -%> if (beresp.http.Surrogate-Control ~ "ESI/1.0") { set beresp.do_esi = true; } @@ -184,7 +184,7 @@ call php_mark_engine; /* TODO: this block of VCL code is copypasta from text-frontend. Some consolidation is in order. */ - <% if cluster_options.fetch( "enable_geoiplookup", false ) -%> + <% if @cluster_options.fetch( "enable_geoiplookup", false ) -%> /* Perform GeoIP look-up and send the result as a session cookie */ if (req.http.X-Orig-Cookie !~ "(^|;\s*)GeoIP=[^;]" && req.http.Orig-Cookie !~ "(^|;\s*)GeoIP=[^;]" diff --git a/templates/varnish/text-backend.inc.vcl.erb b/templates/varnish/text-backend.inc.vcl.erb index 30f23e3..5d0e8f4 100644 --- a/templates/varnish/text-backend.inc.vcl.erb +++ b/templates/varnish/text-backend.inc.vcl.erb @@ -27,7 +27,7 @@ call vcl_recv_purge; call restrict_access; -<% if vcl_config.fetch("cluster_tier", "1") == "1" -%> +<% if @vcl_config.fetch("cluster_tier", "1") == "1" -%> if (req.url ~ "^/w/api\.php") { set req.backend = api; } else if (req.url ~ "^/w/thumb(_handler)?\.php") { @@ -41,7 +41,7 @@ call pass_requests; if (req.request == "POST" || req.url ~ "^/wiki/Special:CentralAutoLogin/") { -<% if vcl_config.fetch("cluster_tier", "1") != "1" -%> +<% if @vcl_config.fetch("cluster_tier", "1") != "1" -%> set req.backend = <%= @vcl_config.fetch("default_backend", "backend") %>_random; <% end -%> set req.hash_ignore_busy = true; diff --git a/templates/varnish/text-frontend.inc.vcl.erb b/templates/varnish/text-frontend.inc.vcl.erb index 2c38700..3a9689d 100644 --- a/templates/varnish/text-frontend.inc.vcl.erb +++ b/templates/varnish/text-frontend.inc.vcl.erb @@ -152,7 +152,7 @@ set resp.http.Cache-Control = "private, s-maxage=0, max-age=0, must-revalidate"; } call php_mark_engine; -<% if cluster_options.fetch( "enable_geoiplookup", false ) -%> +<% if @cluster_options.fetch( "enable_geoiplookup", false ) -%> /* Perform GeoIP look-up and send the result as a session cookie */ if (req.http.Orig-Cookie !~ "(^|;\s*)GeoIP=[^;]" && req.http.Cookie !~ "(^|;\s*)GeoIP=[^;]") { diff --git a/templates/varnish/upload-backend.inc.vcl.erb b/templates/varnish/upload-backend.inc.vcl.erb index 56d30da..ce1b538 100644 --- a/templates/varnish/upload-backend.inc.vcl.erb +++ b/templates/varnish/upload-backend.inc.vcl.erb @@ -18,7 +18,7 @@ } } -<% if vcl_config.fetch("cluster_tier", "1") == "1" -%> +<% if @vcl_config.fetch("cluster_tier", "1") == "1" -%> sub radosgw_rewrite { if (req.restarts == 0) { if (req.url ~ "^/[^/]+/[^/]+/((transcoded|thumb|temp)/)?((temp|archive)/)?[0-9a-f]/[0-9a-f]{2}(/.+)?$") { @@ -64,7 +64,7 @@ else { if (req.backend == rendering && req.url ~ "^/[^-/]+/[^/]+/thumb/(.+)$") { set bereq.url = regsub(req.url, "^/[^-/]+/[^/]+/thumb/(.+)$", "/w/thumb_handler.php/\1"); - set bereq.http.host = regsub(req.url, "^/([^-/]+)/([^/]+)/thumb/.+$", "\2.\1.<%= Regexp.escape(cluster_options.fetch('top_domain', 'org')) %>"); + set bereq.http.host = regsub(req.url, "^/([^-/]+)/([^/]+)/thumb/.+$", "\2.\1.<%= Regexp.escape(@cluster_options.fetch('top_domain', 'org')) %>"); set bereq.http.X-Original-URI = req.url; # Exceptions @@ -87,7 +87,7 @@ call vcl_recv_purge; call restrict_access; - if ( req.http.host != "<%= cluster_options.fetch('upload_domain', 'upload.wikimedia.org') %>") { + if ( req.http.host != "<%= @cluster_options.fetch('upload_domain', 'upload.wikimedia.org') %>") { error 403 "Requested target domain not allowed."; } diff --git a/templates/varnish/upload-frontend.inc.vcl.erb b/templates/varnish/upload-frontend.inc.vcl.erb index bbcf905..c19cfc0 100644 --- a/templates/varnish/upload-frontend.inc.vcl.erb +++ b/templates/varnish/upload-frontend.inc.vcl.erb @@ -23,7 +23,7 @@ set req.http.X-Content-Disposition = "attachment"; } - if ( req.http.host == "<%= cluster_options.fetch('upload_domain', 'upload.wikimedia.org') %>") { + if ( req.http.host == "<%= @cluster_options.fetch('upload_domain', 'upload.wikimedia.org') %>") { # Replace double slashes set req.url = regsuball(req.url, "/{2,}", "/"); return (lookup); @@ -71,7 +71,7 @@ } # Stream large objects, >= 1 or 32 MB -<% stream_threshold = vcl_config.fetch("cluster_tier", "1") == "1" ? 33554432 : 1048576 -%> +<% stream_threshold = @vcl_config.fetch("cluster_tier", "1") == "1" ? 33554432 : 1048576 -%> if (std.integer(beresp.http.Content-Length, 33554432) >= <%= stream_threshold %> || beresp.http.Content-Length ~ "^[0-9]{9}") { set beresp.do_stream = true; if (std.integer(beresp.http.Content-Length, 33554432) >= 33554432 || beresp.http.Content-Length ~ "^[0-9]{9}") { -- To view, visit https://gerrit.wikimedia.org/r/179468 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I349b5328d504d75f2c71a33fd16713f5d1e03875 Gerrit-PatchSet: 1 Gerrit-Project: operations/puppet Gerrit-Branch: production Gerrit-Owner: Giuseppe Lavagetto <[email protected]> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
