BBlack has uploaded a new change for review. https://gerrit.wikimedia.org/r/315091
Change subject: VCL: remove remaining v3 compat from misc+upload ...................................................................... VCL: remove remaining v3 compat from misc+upload Change-Id: I6f95b1498d2438d7742417b8388850ecd0d52c4a --- M modules/varnish/templates/misc-backend.inc.vcl.erb M modules/varnish/templates/upload-backend.inc.vcl.erb M modules/varnish/templates/upload-common.inc.vcl.erb M modules/varnish/templates/upload-frontend.inc.vcl.erb 4 files changed, 23 insertions(+), 26 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/operations/puppet refs/changes/91/315091/1 diff --git a/modules/varnish/templates/misc-backend.inc.vcl.erb b/modules/varnish/templates/misc-backend.inc.vcl.erb index e9d2fec..5d07187 100644 --- a/modules/varnish/templates/misc-backend.inc.vcl.erb +++ b/modules/varnish/templates/misc-backend.inc.vcl.erb @@ -13,22 +13,19 @@ hostcmp = %Q[req.http.Host ~ "#{dir['req_host_re']}"] end if dir.key?('maintenance') - action = error_synth(503, dir['maintenance']) - elsif @varnish_version4 + action = %Q[return (synth(503, "#{dir['maintenance']}"));] if dir['type'] == 'hash' action = "set req.backend_hint = #{dirname}.backend(req.http.X-Client-IP);\n" else action = "set req.backend_hint = #{dirname}.backend();\n" end - else - action = "set req.backend = #{dirname};\n" end if_stmts.push("if (#{hostcmp}) {\n #{action} }") end all_ifs = if_stmts.join(' els') %> <%= all_ifs -%> else { - <%= error_synth(404, "Domain not served here") -%> + return (synth(404, "Domain not served here")); } } diff --git a/modules/varnish/templates/upload-backend.inc.vcl.erb b/modules/varnish/templates/upload-backend.inc.vcl.erb index b92d381..a955ef1 100644 --- a/modules/varnish/templates/upload-backend.inc.vcl.erb +++ b/modules/varnish/templates/upload-backend.inc.vcl.erb @@ -51,7 +51,7 @@ call upload_common_miss; if (req.http.If-Cached) { - <%= error_synth(412, "Entity not in cache") -%> + return (synth(412, "Entity not in cache")); } } @@ -71,8 +71,8 @@ } // Derive the corresponding original URL and store it with the object - if (!beresp.http.X-MediaWiki-Original && <%= @bereq_req %>.url ~ "^/+[^/]+/[^/]+/thumb/[^/]+/[^/]+/[^/]+/[0-9]+px-") { - set beresp.http.X-MediaWiki-Original = regsub(<%= @bereq_req %>.url, "^(/+[^/]+/[^/]+/)thumb/([^/]+/[^/]+/[^/]+).*$", "\1\2"); + if (!beresp.http.X-MediaWiki-Original && bereq.url ~ "^/+[^/]+/[^/]+/thumb/[^/]+/[^/]+/[^/]+/[0-9]+px-") { + set beresp.http.X-MediaWiki-Original = regsub(bereq.url, "^(/+[^/]+/[^/]+/)thumb/([^/]+/[^/]+/[^/]+).*$", "\1\2"); } call upload_common_backend_response; diff --git a/modules/varnish/templates/upload-common.inc.vcl.erb b/modules/varnish/templates/upload-common.inc.vcl.erb index 7543350..2043693 100644 --- a/modules/varnish/templates/upload-common.inc.vcl.erb +++ b/modules/varnish/templates/upload-common.inc.vcl.erb @@ -3,7 +3,7 @@ sub upload_common_recv { unset req.http.X-Range; if (req.http.host != "<%= @vcl_config.fetch('upload_domain') %>") { - <%= error_synth(404, "Requested domainname does not exist on this server") -%> + return (synth(404, "Requested domainname does not exist on this server")); } if (req.http.Range) { @@ -13,7 +13,7 @@ sub upload_common_hit { if (req.http.If-Cached && req.http.If-Cached != obj.http.Etag) { - <%= error_synth(412, "Etag mismatch") -%> + return (synth(412, "Etag mismatch")); } } diff --git a/modules/varnish/templates/upload-frontend.inc.vcl.erb b/modules/varnish/templates/upload-frontend.inc.vcl.erb index a63d51d..e322aa1 100644 --- a/modules/varnish/templates/upload-frontend.inc.vcl.erb +++ b/modules/varnish/templates/upload-frontend.inc.vcl.erb @@ -5,13 +5,13 @@ sub cluster_fe_recv { // CORS preflight requests - if (<%= @req_method %> == "OPTIONS" && req.http.Origin) { - <%= error_synth(667, "OK") -%> + if (req.method == "OPTIONS" && req.http.Origin) { + return (synth(667, "OK")); } // Homepage redirect to commons if (req.url == "/") { - <%= error_synth(666, "Moved Permanently") -%> + return (synth(666, "Moved Permanently")); } call upload_common_recv; @@ -129,26 +129,26 @@ sub cluster_fe_err_synth { // Handle CORS preflight requests - if (<%= @resp_obj %>.status == 667) { - set <%= @resp_obj %>.status = 200; - set <%= @resp_obj %>.http.Connection = "keep-alive"; - set <%= @resp_obj %>.http.Content-Length = "0"; + if (resp.status == 667) { + set resp.status = 200; + set resp.http.Connection = "keep-alive"; + set resp.http.Content-Length = "0"; // allow Range requests, used by ogv.js - set <%= @resp_obj %>.http.Access-Control-Allow-Origin = "*"; - set <%= @resp_obj %>.http.Access-Control-Allow-Headers = "Range"; - set <%= @resp_obj %>.http.Access-Control-Allow-Methods = "GET, HEAD, OPTIONS"; - set <%= @resp_obj %>.http.Access-Control-Max-Age = "86400"; + set resp.http.Access-Control-Allow-Origin = "*"; + set resp.http.Access-Control-Allow-Headers = "Range"; + set resp.http.Access-Control-Allow-Methods = "GET, HEAD, OPTIONS"; + set resp.http.Access-Control-Max-Age = "86400"; return (deliver); } // Homepage redirect to commons - if (<%= @resp_obj %>.status == 666) { - set <%= @resp_obj %>.status = 301; - set <%= @resp_obj %>.http.Location = "https://commons.wikimedia.org/"; - set <%= @resp_obj %>.http.Connection = "keep-alive"; - set <%= @resp_obj %>.http.Content-Length = "0"; + if (resp.status == 666) { + set resp.status = 301; + set resp.http.Location = "https://commons.wikimedia.org/"; + set resp.http.Connection = "keep-alive"; + set resp.http.Content-Length = "0"; return (deliver); } } -- To view, visit https://gerrit.wikimedia.org/r/315091 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I6f95b1498d2438d7742417b8388850ecd0d52c4a Gerrit-PatchSet: 1 Gerrit-Project: operations/puppet Gerrit-Branch: production Gerrit-Owner: BBlack <bbl...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits