BBlack has uploaded a new change for review.

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

Change subject: Move all X-Analytics code to analytics.inc, include in common 
VCL
......................................................................

Move all X-Analytics code to analytics.inc, include in common VCL

(Note, this was originally these 2 commits
d200332d2a8df72f5895aa7bdb8e4ea7f73e6412
a47a985fbafcce708c9d0c896dad05e4106d9d2f
Then was reverted along with earlier stuff in:
e37e79857a6457578348451216d8efdfa465a814
, now re-applied)

All clusters should now emit the same X-Analytics data (all of the
fields currently defined, previously only for text and/or mobile),
which is lumped together in analytics.inc.vcl.erb and included
from the primary common VCL file.

Bug: T89177
Bug: T96847
Bug: T109286
Change-Id: Ic94d9f3cfe18f024260e0d6fa65446c2b15036cb
---
M modules/varnish/manifests/common/vcl.pp
M modules/varnish/templates/vcl/wikimedia.vcl.erb
A templates/varnish/analytics.inc.vcl.erb
D templates/varnish/last-access.inc.vcl.erb
M templates/varnish/mobile-frontend.inc.vcl.erb
D templates/varnish/provenance.inc.vcl.erb
M templates/varnish/text-frontend.inc.vcl.erb
D templates/varnish/via.inc.vcl.erb
M templates/varnish/zero.inc.vcl.erb
9 files changed, 211 insertions(+), 243 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/77/243977/1

diff --git a/modules/varnish/manifests/common/vcl.pp 
b/modules/varnish/manifests/common/vcl.pp
index 41f63bd..2ace903 100644
--- a/modules/varnish/manifests/common/vcl.pp
+++ b/modules/varnish/manifests/common/vcl.pp
@@ -9,17 +9,11 @@
     }
 
     file { '/etc/varnish/last-access.inc.vcl':
-        owner   => 'root',
-        group   => 'root',
-        mode    => '0444',
-        content => template('varnish/last-access.inc.vcl.erb'),
+        ensure => absent,
     }
 
     file { '/etc/varnish/provenance.inc.vcl':
-        owner   => 'root',
-        group   => 'root',
-        mode    => '0444',
-        content => template('varnish/provenance.inc.vcl.erb'),
+        ensure => absent,
     }
 
     file { '/etc/varnish/device-detection.inc.vcl':
@@ -33,12 +27,8 @@
         content => template('varnish/errorpage.inc.vcl.erb'),
     }
 
-
     file { '/etc/varnish/via.inc.vcl':
-        owner   => 'root',
-        group   => 'root',
-        mode    => '0444',
-        content => template('varnish/via.inc.vcl.erb'),
+        ensure => absent,
     }
 
     file { '/etc/varnish/hhvm.inc.vcl':
@@ -48,6 +38,13 @@
         mode   => '0444',
     }
 
+    file { '/etc/varnish/analytics.inc.vcl':
+        owner   => 'root',
+        group   => 'root',
+        mode    => '0444',
+        content => template('varnish/analytics.inc.vcl.erb'),
+    }
+
     # VCL unit tests
     file { '/usr/local/sbin/varnish-test-geoip':
         owner  => 'root',
diff --git a/modules/varnish/templates/vcl/wikimedia.vcl.erb 
b/modules/varnish/templates/vcl/wikimedia.vcl.erb
index 7427e34..c52f4c2 100644
--- a/modules/varnish/templates/vcl/wikimedia.vcl.erb
+++ b/modules/varnish/templates/vcl/wikimedia.vcl.erb
@@ -49,6 +49,11 @@
 include "geoip.inc.vcl";
 <% end -%>
 
+<% if @vcl_config.fetch("layer", "") == "frontend" -%>
+// defines analytics_(recv|deliver) subs
+include "analytics.inc.vcl";
+<% end -%>
+
 # ACLs
 
 acl purge { 
@@ -560,6 +565,11 @@
        }
 <% end -%>
 
+<% if @vcl_config.fetch("layer", "") == "frontend" -%>
+       if(req.restarts == 0) {
+               call analytics_recv;
+       }
+<% end -%>
        /* Function vcl_recv in <%= @vcl %>.inc.vcl will be appended here */
 }
 
@@ -645,6 +655,10 @@
        call https_deliver_hsts;
 <% end -%>
 
+<% if @vcl_config.fetch("layer", "") == "frontend" -%>
+       call analytics_deliver;
+<% end -%>
+
        /* Function vcl_deliver in <%= @vcl %>.inc.vcl will be appended here */
 }
 
diff --git a/templates/varnish/analytics.inc.vcl.erb 
b/templates/varnish/analytics.inc.vcl.erb
new file mode 100644
index 0000000..a280e7c
--- /dev/null
+++ b/templates/varnish/analytics.inc.vcl.erb
@@ -0,0 +1,181 @@
+/*****************************************************************************
+ * Varnish VCL for WMF-Last-Access Cookie
+ * Please see what this cookie is trying to acomplish:
+ * 
https://wikitech.wikimedia.org/wiki/Analytics/Unique_clients/Last_visit_solution
+ *
+ * General notes on timestamp format strings used here:
+ * "now" stringifies as "Wed, 01 Jan 2000 01:01:01 GMT", which is the same
+ * format used by Set-Cookie "Expires" data.  The format for the last access
+ * value, and thus X-NowDay and X-WMF-LastStamp as well, is "01-Jan-2000"
+ * (because the other info is redundant or too-specific, and cookie values
+ * shouldn't have whitespace or commas).
+ ****************************************************************************/
+
+/*****************************************************************************
+ * This must be called *before* any vcl_recv cookie munging.  It more-properly
+ * belongs in _deliver, but putting it here avoids all of the issues
+ * surrounding consistent access to Cookie vs X-Orig-Cookie at vcl_deliver
+ * time in the text/mobile cases.
+ * It does so at the cost of sending a pointless and unintended
+ * "X-WMF-LastStamp: 01-Jan-2000" header to the application layer as well on
+ * cache miss/bypass.
+ * Note we don't validate that the cookie's 3-letter month abbreviation is
+ * legal, or that the numeric values for the date/year are legal, just that
+ * they have the right count of the right kinds of characters.
+ ****************************************************************************/
+sub analytics_last_access_recv {
+    unset req.http.X-WMF-LastStamp; // clear any sent by the user
+    if (req.http.Cookie ~ 
"(^|;\s*)WMF-Last-Access=[0-9]{2}-[A-Za-z]{3}-[0-9]{4}(;|$)") {
+        // Save the value for use later in _deliver
+        set req.http.X-WMF-LastStamp = regsub(
+            req.http.Cookie,
+            "^(?:.*;\s*)?WMF-Last-Access=([^;]+).*$",
+            "\1"
+        );
+    }
+}
+
+/*****************************************************************************
+ * !!! private to analytics_last_access_deliver !!!!
+ * This should be:
+ *     header.append(resp.http.Set-Cookie,
+ *         "WMF-Last-Access="
+ *         + req.http.X-NowDay
+ *         + ";Path=/;HttpOnly;Expires="
+ *         + (now + 32d)
+ *     );
+ * However, varnish3 is buggy wrt str + (time + duration), so we're forced to
+ * drop to inline C a bit here and do what the VCL compiler should have done
+ * for us above.  On top of all that, the C code now floors the expiry to the
+ * next-lower 12 hour mark, which would've been a bit trickier in VCL...
+ ****************************************************************************/
+C{#include <time.h>}C
+sub set_last_access_cookie__ { C{
+    Vmod_Func_header.append(sp, HDR_RESP, "\013Set-Cookie:",
+        "WMF-Last-Access=",
+        VRT_GetHdr(sp, HDR_REQ, "\011X-NowDay:"),
+        ";Path=/;HttpOnly;Expires=",
+        VRT_time_string(sp, (double)(
+            ((time_t)VRT_r_now(sp) + 2764800) / 43200 * 43200
+        )),
+        vrt_magic_string_end
+    );
+}C }
+
+// Call from vcl_deliver near other X-Analytics code
+sub analytics_last_access_deliver {
+    // Create X-NowDay in "01-Jan-2000" form, from "now"
+    set req.http.X-NowDay = regsub(
+        now, "^..., (..) (...) (....) .*$", "\1-\2-\3"
+    );
+
+    if(req.http.X-WMF-LastStamp) {
+        set resp.http.X-Analytics = resp.http.X-Analytics
+            + ";WMF-Last-Access="
+            + req.http.X-WMF-LastStamp;
+
+        // re-set the cookie if it's not from today
+        if (req.http.X-NowDay != req.http.X-WMF-LastStamp) {
+            call set_last_access_cookie__;
+        }
+
+    }
+    else {
+        // sets the initial cookie if no valid one existed
+        call set_last_access_cookie__;
+    }
+
+    // we could clean up req.http.X-WMF-LastStamp + req.http.X-NowDay
+    // here, but they're not being sent anywhere (else) at this point
+    // anyways, so why bother?
+}
+
+// Analytics for analytics "wprov" Provenance data
+// See https://www.mediawiki.org/wiki/Provenance for reserved values.
+
+sub analytics_provenance_recv {
+    // Avoid cache fragmentation for well-formed provenance parameters
+    // Refer to discussion starting from
+    // 
https://lists.wikimedia.org/pipermail/analytics/2015-February/003426.html
+    // Look for wprov parameter with a value
+    if (req.url ~ "(?i)[?&]wprov=[^&]+") {
+        // Ready a variable for later X-Analytics tagging in vcl_deliver.
+
+        // Grab just the value of the wprov parameter, excluding the rest of 
the URL
+        set req.http.X-WMF-WPROV = regsub(req.url, 
"(?i).+[?&]wprov=([^&]+).*", "\1");
+
+        // Remove the wprov=X parameter from req.url to avoid cache
+        // fragmentation using two regexes to cover distinct cases:
+
+        // (1) Simple strip if final query arg:
+        set req.url = regsub(req.url, "(?i)[?&]wprov=[^&]+$", "");
+
+        // (2) When not the final arg, we need to capture the leading
+        //     [?&] to reuse with the parameter that follows:
+        set req.url = regsub(req.url, "(?i)([?&])wprov=[^&]+&", "\1");
+    }
+}
+
+sub analytics_provenance_deliver {
+    // In case there was a provenance parameter with a value, add it to 
X-Analytics
+    if (req.http.X-WMF-WPROV) {
+        set resp.http.X-Analytics = resp.http.X-Analytics + ";wprov=" + 
req.http.X-WMF-WPROV;
+    }
+}
+
+// Combined analytics recv and deliver hooks, to be included directly in 
vcl_recv and vcl_deliver
+sub analytics_recv {
+    call analytics_last_access_recv;
+    call analytics_provenance_recv;
+}
+
+sub analytics_deliver {
+    // Create empty header if none, to avoid tons of if/else clauses; will
+    // clean up at the end.  Note that if we defined one of the k=v pairs as
+    // required (having a real value for the false/negative case), we could
+    // set that one first and this would get a bit cleaner...
+    if (!resp.http.X-Analytics) {
+        set resp.http.X-Analytics = "";
+    }
+
+    call analytics_last_access_deliver;
+    call analytics_provenance_deliver;
+
+    if (req.http.X-Carrier) {
+        set resp.http.X-Analytics = resp.http.X-Analytics + ";zero=" + 
req.http.X-Carrier;
+        if (req.http.X-Carrier-Meta) {
+            set resp.http.X-Analytics = resp.http.X-Analytics + ";zeronet=" + 
req.http.X-Carrier-Meta;
+        }
+    }
+
+    if (req.http.X-Trusted-Proxy) {
+        set resp.http.X-Analytics = resp.http.X-Analytics + ";proxy=" + 
req.http.X-Trusted-Proxy;
+    }
+
+    if (req.http.X-Forwarded-Proto) {
+        set resp.http.X-Analytics = resp.http.X-Analytics + ";https=1";
+    }
+
+    if (req.http.X-WMF-UUID) {
+        set resp.http.X-Analytics = resp.http.X-Analytics + ";wmfuuid=" + 
req.http.X-WMF-UUID;
+    }
+
+    // Add proxy=IORG X-Analytics tag if appropriate.
+    // Although Via: Internet.org usually comes via proxying, it isn't 
guaranteed to come that way.
+    // Nonetheless, as it is tagged with Via and the equipment is under 
Internet.org, we proxy tag.
+    // Note, Internet.org is believed to apply to all Wikimedia sites, so this 
code should run not
+    // just for (m|zero).wikipedia.org and subdomains. Hence the inclusion of 
this file by both
+    // mobile-frontend.inc.vcl.erb and text-frontend.inc.vcl.erb, as opposed 
to a one-off in
+    // zero.inc.vcl.erb alone. See the notes at the top of 
mobile-frontend.inc.vcl.erb and
+    // text-frontend.inc.vcl.erb for more context.
+    if (req.http.Via ~ "(?i)Internet\.org") {
+        set resp.http.X-Analytics = resp.http.X-Analytics + ";proxy=IORG";
+    }
+
+    // Clean up header from setting to empty at the start...
+    if (resp.http.X-Analytics == "") {
+        unset resp.http.X-Analytics;
+    } else {
+        set resp.http.X-Analytics = regsub(resp.http.X-Analytics, "^;", "");
+    }
+}
diff --git a/templates/varnish/last-access.inc.vcl.erb 
b/templates/varnish/last-access.inc.vcl.erb
deleted file mode 100644
index bdf4a76..0000000
--- a/templates/varnish/last-access.inc.vcl.erb
+++ /dev/null
@@ -1,98 +0,0 @@
-/*****************************************************************************
- * Varnish VCL include file for WMF-Last-Access Cookie
- * Please see what this cookie is trying to acomplish:
- * 
https://wikitech.wikimedia.org/wiki/Analytics/Unique_clients/Last_visit_solution
- *
- * General notes on timestamp format strings used here:
- * "now" stringifies as "Wed, 01 Jan 2000 01:01:01 GMT", which is the same
- * format used by Set-Cookie "Expires" data.  The format for the last access
- * value, and thus X-NowDay and X-WMF-LastStamp as well, is "01-Jan-2000"
- * (because the other info is redundant or too-specific, and cookie values
- * shouldn't have whitespace or commas).
- ****************************************************************************/
-
-/*****************************************************************************
- * This must be called *before* any vcl_recv cookie munging.  It more-properly
- * belongs in _deliver, but putting it here avoids all of the issues
- * surrounding consistent access to Cookie vs X-Orig-Cookie at vcl_deliver
- * time in the text/mobile cases.
- * It does so at the cost of sending a pointless and unintended
- * "X-WMF-LastStamp: 01-Jan-2000" header to the application layer as well on
- * cache miss/bypass.
- * Note we don't validate that the cookie's 3-letter month abbreviation is
- * legal, or that the numeric values for the date/year are legal, just that
- * they have the right count of the right kinds of characters.
- ****************************************************************************/
-sub analytics_last_access_recv {
-       if (req.restarts == 0) {
-               unset req.http.X-WMF-LastStamp; // clear any sent by the user
-               if (req.http.Cookie ~ 
"(^|;\s*)WMF-Last-Access=[0-9]{2}-[A-Za-z]{3}-[0-9]{4}(;|$)") {
-                       // Save the value for use later in _deliver
-                       set req.http.X-WMF-LastStamp = regsub(
-                               req.http.Cookie,
-                               "^(?:.*;\s*)?WMF-Last-Access=([^;]+).*$",
-                               "\1"
-                       );
-               }
-       }
-}
-
-/*****************************************************************************
- * !!! private to analytics_last_access_deliver !!!!
- * This should be:
- *     header.append(resp.http.Set-Cookie,
- *             "WMF-Last-Access="
- *             + req.http.X-NowDay
- *             + ";Path=/;HttpOnly;Expires="
- *             + (now + 32d)
- *     );
- * However, varnish3 is buggy wrt str + (time + duration), so we're forced to
- * drop to inline C a bit here and do what the VCL compiler should have done
- * for us above.  On top of all that, the C code now floors the expiry to the
- * next-lower 12 hour mark, which would've been a bit trickier in VCL...
- ****************************************************************************/
-C{#include <time.h>}C
-sub set_last_access_cookie__ { C{
-       Vmod_Func_header.append(sp, HDR_RESP, "\013Set-Cookie:",
-               "WMF-Last-Access=",
-               VRT_GetHdr(sp, HDR_REQ, "\011X-NowDay:"),
-               ";Path=/;HttpOnly;Expires=",
-               VRT_time_string(sp, (double)(
-                       ((time_t)VRT_r_now(sp) + 2764800) / 43200 * 43200
-               )),
-               vrt_magic_string_end
-       );
-}C }
-
-// Call from vcl_deliver near other X-Analytics code
-sub analytics_last_access_deliver {
-       // Create X-NowDay in "01-Jan-2000" form, from "now"
-       set req.http.X-NowDay = regsub(
-               now, "^..., (..) (...) (....) .*$", "\1-\2-\3"
-       );
-
-       if(req.http.X-WMF-LastStamp) {
-               if (resp.http.X-Analytics) {
-                       set resp.http.X-Analytics = resp.http.X-Analytics
-                               + ";WMF-Last-Access="
-                               + req.http.X-WMF-LastStamp;
-               } else {
-                       set resp.http.X-Analytics = "WMF-Last-Access="
-                               + req.http.X-WMF-LastStamp;
-               }
-
-               // re-set the cookie if it's not from today
-               if (req.http.X-NowDay != req.http.X-WMF-LastStamp) {
-                       call set_last_access_cookie__;
-               }
-
-       }
-       else {
-               // sets the initial cookie if no valid one existed
-               call set_last_access_cookie__;
-       }
-
-       // we could clean up req.http.X-WMF-LastStamp + req.http.X-NowDay
-       // here, but they're not being sent anywhere (else) at this point
-       // anyways, so why bother?
-}
diff --git a/templates/varnish/mobile-frontend.inc.vcl.erb 
b/templates/varnish/mobile-frontend.inc.vcl.erb
index 88a0822..0944840 100644
--- a/templates/varnish/mobile-frontend.inc.vcl.erb
+++ b/templates/varnish/mobile-frontend.inc.vcl.erb
@@ -3,11 +3,8 @@
 include "errorpage.inc.vcl";
 include "text-common.inc.vcl";
 include "zero.inc.vcl";
-include "provenance.inc.vcl";
-include "via.inc.vcl";
-include "last-access.inc.vcl";
 
-// Note that via.inc.vcl will set an X-Analytics value of proxy=IORG
+// Note that analytics.inc.vcl will set an X-Analytics value of proxy=IORG
 // without inspecting whether there's an existing proxy=<proxy> key-
 // value pair inside X-Analytics. We do this because if the traffic
 // had come from a known proxy (e.g., Opera or Nokia), that would
@@ -93,7 +90,6 @@
                unset req.http.If-Modified-Since;
        }
 
-       call analytics_last_access_recv;
        call evaluate_cookie_mobile;
        call pass_authorization;
        return (lookup);
@@ -148,25 +144,4 @@
                call geoip_cookie;
        }
 <% end -%>
-
-       // Assemble X-Analytics header
-       // Some of the headers used for X-Analytics are not varied on, so add 
them after the backend processing
-       // Note that vcl_deliver in other files may also modify X-Analytics.
-       if (req.http.X-Forwarded-Proto) {
-               if (resp.http.X-Analytics) {
-                       set resp.http.X-Analytics = resp.http.X-Analytics + 
";https=1";
-               } else {
-                       set resp.http.X-Analytics = "https=1";
-               }
-       }
-
-       if (req.http.X-WMF-UUID) {
-               if (resp.http.X-Analytics) {
-                       set resp.http.X-Analytics = resp.http.X-Analytics + 
";wmfuuid=" + req.http.X-WMF-UUID;
-               } else {
-                       set resp.http.X-Analytics = "wmfuuid=" + 
req.http.X-WMF-UUID;
-               }
-       }
-
-       call analytics_last_access_deliver;
 }
diff --git a/templates/varnish/provenance.inc.vcl.erb 
b/templates/varnish/provenance.inc.vcl.erb
deleted file mode 100644
index 852924b..0000000
--- a/templates/varnish/provenance.inc.vcl.erb
+++ /dev/null
@@ -1,34 +0,0 @@
-sub vcl_recv {
-       // Avoid cache fragmentation for well-formed provenance parameters
-       // Refer to discussion starting from
-       // 
https://lists.wikimedia.org/pipermail/analytics/2015-February/003426.html
-       // Look for wprov parameter with a value
-       if (req.url ~ "(?i)[?&]wprov=[^&]+") {
-               // Ready a variable for later X-Analytics tagging in 
vcl_deliver.
-               // See https://www.mediawiki.org/wiki/Provenance for reserved 
values.
-
-               // Grab just the value of the wprov parameter, excluding the 
rest of the URL
-               set req.http.X-WMF-WPROV = regsub(req.url, 
"(?i).+[?&]wprov=([^&]+).*", "\1");
-
-               // Remove the wprov=X parameter from req.url to avoid cache
-               // fragmentation using two regexes to cover distinct cases:
-
-               // (1) Simple strip if final query arg:
-               set req.url = regsub(req.url, "(?i)[?&]wprov=[^&]+$", "");
-
-               // (2) When not the final arg, we need to capture the leading
-               //     [?&] to reuse with the parameter that follows:
-               set req.url = regsub(req.url, "(?i)([?&])wprov=[^&]+&", "\1");
-       }
-}
-
-sub vcl_deliver {
-       // In case there was a provenance parameter with a value, add it to 
X-Analytics
-       if (req.http.X-WMF-WPROV) {
-               if (resp.http.X-Analytics) {
-                       set resp.http.X-Analytics = resp.http.X-Analytics + 
";wprov=" + req.http.X-WMF-WPROV;
-               } else {
-                       set resp.http.X-Analytics = "wprov=" + 
req.http.X-WMF-WPROV;
-               }
-       }
-}
diff --git a/templates/varnish/text-frontend.inc.vcl.erb 
b/templates/varnish/text-frontend.inc.vcl.erb
index 161cc54..955f272 100644
--- a/templates/varnish/text-frontend.inc.vcl.erb
+++ b/templates/varnish/text-frontend.inc.vcl.erb
@@ -2,11 +2,8 @@
 
 include "errorpage.inc.vcl";
 include "text-common.inc.vcl";
-include "provenance.inc.vcl";
-include "via.inc.vcl";
-include "last-access.inc.vcl";
 
-// Note that via.inc.vcl will set an X-Analytics value of proxy=IORG
+// Note that analytics.inc.vcl will set an X-Analytics value of proxy=IORG
 // without inspecting whether there's an existing proxy=<proxy> key-
 // value pair inside X-Analytics. We do this because if the traffic
 // had come from a known proxy (e.g., Opera or Nokia), that would
@@ -103,7 +100,6 @@
                unset req.http.If-Modified-Since;
        }
 
-       call analytics_last_access_recv;
        call evaluate_cookie;
        call pass_authorization;
        return (lookup);
@@ -168,25 +164,4 @@
                call geoip_cookie;
        }
 <% end -%>
-
-       // Assemble X-Analytics header
-       // Some of the headers used for X-Analytics are not varied on, so add 
them after the backend processing
-       // Note that vcl_deliver in other files may also modify X-Analytics.
-       if (req.http.X-Forwarded-Proto) {
-               if (resp.http.X-Analytics) {
-                       set resp.http.X-Analytics = resp.http.X-Analytics + 
";https=1";
-               } else {
-                       set resp.http.X-Analytics = "https=1";
-               }
-       }
-
-       if (req.http.X-WMF-UUID) {
-               if (resp.http.X-Analytics) {
-                       set resp.http.X-Analytics = resp.http.X-Analytics + 
";wmfuuid=" + req.http.X-WMF-UUID;
-               } else {
-                       set resp.http.X-Analytics = "wmfuuid=" + 
req.http.X-WMF-UUID;
-               }
-       }
-
-       call analytics_last_access_deliver;
 }
diff --git a/templates/varnish/via.inc.vcl.erb 
b/templates/varnish/via.inc.vcl.erb
deleted file mode 100644
index 1736d7e..0000000
--- a/templates/varnish/via.inc.vcl.erb
+++ /dev/null
@@ -1,18 +0,0 @@
-sub vcl_deliver {
-       // Add proxy=IORG X-Analytics tag if appropriate.
-       // Although Via: Internet.org usually comes via proxying, it isn't 
guaranteed to come that way.
-       // Nonetheless, as it is tagged with Via and the equipment is under 
Internet.org, we proxy tag.
-       // Note, Internet.org is believed to apply to all Wikimedia sites, so 
this code should run not
-       // just for (m|zero).wikipedia.org and subdomains. Hence the inclusion 
of this file by both
-       // mobile-frontend.inc.vcl.erb and text-frontend.inc.vcl.erb, as 
opposed to a one-off in
-       // zero.inc.vcl.erb alone. See the notes at the top of 
mobile-frontend.inc.vcl.erb and
-       // text-frontend.inc.vcl.erb for more context.
-       if (req.http.Via ~ "(?i)Internet\.org") {
-               if (resp.http.X-Analytics) {
-                       set resp.http.X-Analytics = resp.http.X-Analytics + 
";proxy=IORG";
-               } else {
-                       set resp.http.X-Analytics = "proxy=IORG";
-               }
-       }
-}
-
diff --git a/templates/varnish/zero.inc.vcl.erb 
b/templates/varnish/zero.inc.vcl.erb
index 58968e9..8d26ed7f 100644
--- a/templates/varnish/zero.inc.vcl.erb
+++ b/templates/varnish/zero.inc.vcl.erb
@@ -35,10 +35,7 @@
 
     if (req.http.X-Forwarded-By) {
         // Current backend & cache vary on X-Forwarded-By, so in order not to 
fragment cache,
-        // unset X-Forwarded-By. We still need that value in the resulting 
X-Analytics header,
-        // so create a copy to be used in the vcl_deliver.
-        set req.http.X-Forwarded-By2 = req.http.X-Forwarded-By;
-
+        // unset X-Forwarded-By.
         // the backend now checks this value. Soon we will stop varying on it
         if (!req.http.X-CS) {
             unset req.http.X-Forwarded-By;
@@ -60,31 +57,10 @@
         header.append(resp.http.Set-Cookie,"ZeroOpts=tls");
     }
 
-    // Prepare for outbound X-CS and X-Analytics header assembly.
+    // Regardless of X-CS transform to "ON" for Vary and/or server-side
+    // purposes, if a carrier was detected at all, set X-CS as an outbound
+    // response header for the application to consume.
     if (req.http.X-CS2) {
-       // Regardless of X-CS transform to "ON" for Vary and/or server-side
-       // purposes, if a carrier was detected at all, set X-CS as an outbound
-       // response header for the application to consume.
        set resp.http.X-CS = req.http.X-CS2;
-
-       // X-C and X-C-M are set/split in the common recv code in
-       // wikimedia.vcl; X-CS2 is aggregated from them in recv
-       if (req.http.X-Carrier) {
-               if (resp.http.X-Analytics) {
-                       set resp.http.X-Analytics = resp.http.X-Analytics + 
";zero=" + req.http.X-Carrier;
-               } else {
-                       set resp.http.X-Analytics = "zero=" + 
req.http.X-Carrier;
-               }
-               if (req.http.X-Carrier-Meta) {
-                       set resp.http.X-Analytics = resp.http.X-Analytics + 
";zeronet=" + req.http.X-Carrier-Meta;
-               }
-       }
-    }
-    if (req.http.X-Forwarded-By2) {
-        if (resp.http.X-Analytics) {
-            set resp.http.X-Analytics = resp.http.X-Analytics + ";proxy=" + 
req.http.X-Forwarded-By2;
-        } else {
-            set resp.http.X-Analytics = "proxy=" + req.http.X-Forwarded-By2;
-        }
     }
 }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic94d9f3cfe18f024260e0d6fa65446c2b15036cb
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: BBlack <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to