GWicke has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/274458

Change subject: WIP: Add a cluster_be_recv_pre_purge handler & normalize paths
......................................................................

WIP: Add a cluster_be_recv_pre_purge handler & normalize paths

To ensure reliable purging of titles with special characters, we would like to
apply the same path normalizations to PURGE and other requests. The previous
attempt to do so (274282) only applied to frontends, so was not a complete
solution.

This patch introduces an equivalent cluster_be_recv_pre_purge handler, and
calls / defines it for all Varnish clusters. For the text cluster, this
handler is then used to apply the same path normalizations as performed in the
frontend to PURGE requests.

Bug: T127387
Change-Id: I9a882013adb620ae5f5e36eb0ad4ef1a9ba1b0a0
---
M modules/varnish/templates/vcl/wikimedia-backend.vcl.erb
M templates/varnish/maps-backend.inc.vcl.erb
M templates/varnish/misc-backend.inc.vcl.erb
M templates/varnish/text-backend.inc.vcl.erb
M templates/varnish/text-common.inc.vcl.erb
M templates/varnish/text-frontend.inc.vcl.erb
M templates/varnish/upload-backend.inc.vcl.erb
7 files changed, 27 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/58/274458/1

diff --git a/modules/varnish/templates/vcl/wikimedia-backend.vcl.erb 
b/modules/varnish/templates/vcl/wikimedia-backend.vcl.erb
index 6329f5e..d429804 100644
--- a/modules/varnish/templates/vcl/wikimedia-backend.vcl.erb
+++ b/modules/varnish/templates/vcl/wikimedia-backend.vcl.erb
@@ -11,6 +11,7 @@
        }
 
        call wm_common_recv;
+       call cluster_be_recv_pre_purge;
        call wm_common_recv_purge;
        call cluster_be_recv;
 
diff --git a/templates/varnish/maps-backend.inc.vcl.erb 
b/templates/varnish/maps-backend.inc.vcl.erb
index b9b4df6..8b66812 100644
--- a/templates/varnish/maps-backend.inc.vcl.erb
+++ b/templates/varnish/maps-backend.inc.vcl.erb
@@ -1,4 +1,5 @@
 // Varnish VCL include file for maps backends
+sub cluster_be_recv_pre_purge { }
 sub cluster_be_recv { }
 sub cluster_be_hash { }
 sub cluster_be_hit { }
diff --git a/templates/varnish/misc-backend.inc.vcl.erb 
b/templates/varnish/misc-backend.inc.vcl.erb
index 24f76c0..ed9e315 100644
--- a/templates/varnish/misc-backend.inc.vcl.erb
+++ b/templates/varnish/misc-backend.inc.vcl.erb
@@ -1,5 +1,7 @@
 include "misc-common.inc.vcl";
 
+sub cluster_be_recv_pre_purge { }
+
 sub cluster_be_recv {
 <% if @site_tier == "one" -%>
     if (req.http.Host == "git.wikimedia.org") {
diff --git a/templates/varnish/text-backend.inc.vcl.erb 
b/templates/varnish/text-backend.inc.vcl.erb
index fccd248..629c103 100644
--- a/templates/varnish/text-backend.inc.vcl.erb
+++ b/templates/varnish/text-backend.inc.vcl.erb
@@ -1,6 +1,13 @@
 // Varnish VCL include file for text backends
 
 include "text-common.inc.vcl";
+include "normalize_path.inc.vcl";
+
+sub cluster_be_recv_pre_purge { 
+       if (req.request == "PURGE") {
+               call text_normalize_path;
+       }
+}
 
 sub cluster_be_recv {
 <% if @site_tier == "one" -%>
diff --git a/templates/varnish/text-common.inc.vcl.erb 
b/templates/varnish/text-common.inc.vcl.erb
index 53e3dcf..c825adf 100644
--- a/templates/varnish/text-common.inc.vcl.erb
+++ b/templates/varnish/text-common.inc.vcl.erb
@@ -1,5 +1,7 @@
 // Common functions for the Text/Mobile Varnish clusters
 
+include "normalize_path.inc.vcl";
+
 sub text_common_misspass_restore_cookie {
        // Restore the original Cookie header for upstream
        // Assumes client header X-Orig-Cookie has been filtered!
@@ -56,6 +58,15 @@
        }
 }
 
+sub text_normalize_path {
+       // Don't decode percent-encoded slashes in paths for REST APIs
+       if (req.url ~ "^/api/rest_v1/" || req.http.host ~ 
"cxserver|citoid|restbase|^rest\.") {
+               call normalize_rest_path;
+       } else {
+               call normalize_mediawiki_path;
+       }
+}
+
 // fe+be common recv code
 sub text_common_recv {
        if (req.request != "GET" && req.request != "HEAD") {
diff --git a/templates/varnish/text-frontend.inc.vcl.erb 
b/templates/varnish/text-frontend.inc.vcl.erb
index 7d7b7fc..b295ae3 100644
--- a/templates/varnish/text-frontend.inc.vcl.erb
+++ b/templates/varnish/text-frontend.inc.vcl.erb
@@ -3,7 +3,6 @@
 include "text-common.inc.vcl";
 include "zero.inc.vcl";
 include "geoip.inc.vcl";
-include "normalize_path.inc.vcl";
 
 // Note that analytics.inc.vcl will set an X-Analytics value of proxy=IORG
 // without inspecting whether there's an existing proxy=<proxy> key-
@@ -111,6 +110,9 @@
                        }
                }
        }
+
+       // Normalize paths before purging
+       call text_normalize_path;
 }
 
 sub cluster_fe_recv {
@@ -120,13 +122,6 @@
                        error 204;
                }
                return (lookup);
-       }
-
-       // Don't decode percent-encoded slashes in paths for REST APIs
-       if (req.url ~ "^/api/rest_v1/" || req.http.host ~ 
"cxserver|citoid|restbase|^rest\.") {
-               call normalize_rest_path;
-       } else {
-               call normalize_mediawiki_path;
        }
 
        call mobile_redirect;
diff --git a/templates/varnish/upload-backend.inc.vcl.erb 
b/templates/varnish/upload-backend.inc.vcl.erb
index 10ec594..49a3878 100644
--- a/templates/varnish/upload-backend.inc.vcl.erb
+++ b/templates/varnish/upload-backend.inc.vcl.erb
@@ -17,6 +17,8 @@
        }
 }
 
+sub cluster_be_recv_pre_purge { }
+
 sub cluster_be_recv {
        call upload_common_recv;
 

-- 
To view, visit https://gerrit.wikimedia.org/r/274458
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9a882013adb620ae5f5e36eb0ad4ef1a9ba1b0a0
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: GWicke <gwi...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to