Giuseppe Lavagetto has submitted this change and it was merged.

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/lvs/manifests/configuration.pp
M modules/varnish/templates/varnishncsa.init.erb
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
10 files changed, 34 insertions(+), 34 deletions(-)

Approvals:
  Giuseppe Lavagetto: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/modules/lvs/manifests/configuration.pp 
b/modules/lvs/manifests/configuration.pp
index f54a8e5..7f4840b 100644
--- a/modules/lvs/manifests/configuration.pp
+++ b/modules/lvs/manifests/configuration.pp
@@ -65,7 +65,7 @@
             },
         'bgp-nexthop-ipv4' => $::ipaddress_eth0,
         # FIXME: make a Puppet function, or fix facter
-        'bgp-nexthop-ipv6' => inline_template("<%= require 'ipaddr'; 
(IPAddr.new(v6_ip).mask(64) | IPAddr.new(\"::\" + 
scope.lookupvar(\"::ipaddress\").gsub('.', ':'))).to_s() %>")
+        'bgp-nexthop-ipv6' => inline_template("<%= require 'ipaddr'; 
(IPAddr.new(@v6_ip).mask(64) | IPAddr.new(\"::\" + 
scope.lookupvar(\"::ipaddress\").gsub('.', ':'))).to_s() %>")
     }
 
     $idleconnection_monitor_options = {
diff --git a/modules/varnish/templates/varnishncsa.init.erb 
b/modules/varnish/templates/varnishncsa.init.erb
index bf87f0b..6d00283 100755
--- a/modules/varnish/templates/varnishncsa.init.erb
+++ b/modules/varnish/templates/varnishncsa.init.erb
@@ -21,7 +21,7 @@
 LOGFILE=/var/log/varnish/varnishncsa.log
 USER=varnishlog
 
-DAEMON_OPTS="-n <%= @shm_name %> -w <%= listener_address %>:<%= port %> <%= 
cli_args %> -P $PIDFILE"
+DAEMON_OPTS="-n <%= @shm_name %> -w <%= @listener_address %>:<%= @port %> <%= 
@cli_args %> -P $PIDFILE"
 
 # Include defaults if available
 if [ -f /etc/default/varnishncsa ] ; then
@@ -42,13 +42,13 @@
 test -x $DAEMON || exit 0
 
 
-# I can't seem to make quoting work properly with 
+# I can't seem to make quoting work properly with
 # $LOG_FORMAT set from /etc/default/varnishncsa.
 # I have to manually quote the LOG_FORMAT string
 # in the start-stop-daemon line here.  NOT ideal
 # at all.  This means I have to ALWAYS pass the -F
 # option with a hardcoded default LOG_FORMAT.
-# The default is already hardcoded into 
+# The default is already hardcoded into
 # Wikimedia's package of varnishncsa, so yuck.
 # I don't like it.
 
@@ -63,7 +63,7 @@
     output=$(/bin/tempfile -s.varnish)
     log_daemon_msg "Starting $DESC" "$NAME"
     create_pid_directory
-    
+
     if start-stop-daemon --start --quiet --pidfile ${PIDFILE} \
         --chuid $USER --exec ${DAEMON} -- ${DAEMON_OPTS} -F "${LOG_FORMAT}" \
         > ${output} 2>&1; then
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: merged
Gerrit-Change-Id: I349b5328d504d75f2c71a33fd16713f5d1e03875
Gerrit-PatchSet: 3
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Giuseppe Lavagetto <[email protected]>
Gerrit-Reviewer: Giuseppe Lavagetto <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to