Ema has submitted this change and it was merged. Change subject: upload VCL: X-Range hack for V4 ......................................................................
upload VCL: X-Range hack for V4 Varnish strips the Range header before copying req (client request) into bereq (varnish request). With Varnish 3 it is enough to assign req.http.Range to bereq.http.Range in vcl_miss to send the Range header to the backend. Because of Varnish 4 architectural changes, though, this hack is required. We are saving the Range header into X-Range in vcl_miss and copying it into bereq in vcl_backend_fetch. Bug: T131502 Change-Id: Ieb84e167dd0a630f6c9b50e0c553407f7e3b00d1 --- M templates/varnish/upload-backend.inc.vcl.erb M templates/varnish/upload-common.inc.vcl.erb M templates/varnish/upload-frontend.inc.vcl.erb 3 files changed, 30 insertions(+), 2 deletions(-) Approvals: Ema: Verified; Looks good to me, approved BBlack: Looks good to me, but someone else must approve diff --git a/templates/varnish/upload-backend.inc.vcl.erb b/templates/varnish/upload-backend.inc.vcl.erb index ead23fb..ef04e23 100644 --- a/templates/varnish/upload-backend.inc.vcl.erb +++ b/templates/varnish/upload-backend.inc.vcl.erb @@ -57,7 +57,11 @@ if (req.http.Range && (std.integer(regsub(req.http.Range, "^bytes=([0-9]*)-", "\1"), 0) > 33554432 || req.http.Range ~ "^bytes=([0-9]{9,})-")) { + <%- if @varnish_version4 -%> + call upload_common_set_xrange; + <%- else -%> set bereq.http.Range = req.http.Range; + <%- end -%> std.log("Passing high range request: " + req.http.Range); return (pass); } @@ -70,7 +74,9 @@ sub cluster_be_pass { } <% if @varnish_version4 -%> -sub cluster_be_backend_fetch { } +sub cluster_be_backend_fetch { + call upload_common_set_range; +} <% end -%> sub cluster_be_backend_response { diff --git a/templates/varnish/upload-common.inc.vcl.erb b/templates/varnish/upload-common.inc.vcl.erb index 11b2ad2..2e38d41 100644 --- a/templates/varnish/upload-common.inc.vcl.erb +++ b/templates/varnish/upload-common.inc.vcl.erb @@ -1,6 +1,7 @@ // common to upload front+backend VCL 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") -%> } @@ -18,3 +19,18 @@ unset resp.http.X-Content-Range; } } + +// Varnish strips the Range header before copying req into bereq. Save it into +// a header and restore it in upload_common_set_range +sub upload_common_set_xrange { + if (req.http.Range) { + set req.http.X-Range = req.http.Range; + } +} + +sub upload_common_set_range { + if (bereq.http.X-Range) { + set bereq.http.Range = bereq.http.X-Range; + unset bereq.http.X-Range; + } +} diff --git a/templates/varnish/upload-frontend.inc.vcl.erb b/templates/varnish/upload-frontend.inc.vcl.erb index b992fcf..edf168b 100644 --- a/templates/varnish/upload-frontend.inc.vcl.erb +++ b/templates/varnish/upload-frontend.inc.vcl.erb @@ -37,7 +37,11 @@ sub cluster_fe_miss { // Convert range requests into pass if (req.http.Range) { + <%- if @varnish_version4 -%> + call upload_common_set_xrange; + <%- else -%> set bereq.http.Range = req.http.Range; + <%- end -%> return (pass); } @@ -50,7 +54,9 @@ sub cluster_fe_pass { } <% if @varnish_version4 -%> -sub cluster_fe_backend_fetch { } +sub cluster_fe_backend_fetch { + call upload_common_set_range; +} <% end -%> sub cluster_fe_backend_response { -- To view, visit https://gerrit.wikimedia.org/r/299130 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ieb84e167dd0a630f6c9b50e0c553407f7e3b00d1 Gerrit-PatchSet: 5 Gerrit-Project: operations/puppet Gerrit-Branch: production Gerrit-Owner: BBlack <bbl...@wikimedia.org> Gerrit-Reviewer: BBlack <bbl...@wikimedia.org> Gerrit-Reviewer: Ema <e...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits