Giuseppe Lavagetto has uploaded a new change for review.

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

Change subject: varnish: add fixed_weight to the directors options
......................................................................

varnish: add fixed_weight to the directors options

In some cases, we define additional directors based off of the same list
of backends we use for another director, but we may want to keep all the
weights even in this second case - this additional (optional) argument
of the directors data structure will allow this. This is a fixup of
I9f856c54493cc which made the "random backend" of the text caches use
uneven weights.

Change-Id: Ica50ecaa73362326e3da7e2b943346094c036f63
---
M modules/role/manifests/cache/text.pp
M modules/varnish/templates/vcl/directors.vcl.tpl.erb
M modules/varnish/templates/vcl/wikimedia.vcl.erb
3 files changed, 10 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/15/220815/1

diff --git a/modules/role/manifests/cache/text.pp 
b/modules/role/manifests/cache/text.pp
index 17e323e..c139899 100644
--- a/modules/role/manifests/cache/text.pp
+++ b/modules/role/manifests/cache/text.pp
@@ -59,9 +59,10 @@
                 'backends' => $text_nodes['eqiad'],
             },
             'backend_random'    => {
-                'dynamic'  => 'yes',
-                'type'     => 'random',
-                'backends' => $text_nodes['eqiad'],
+                'dynamic'      => 'yes',
+                'type'         => 'random',
+                'backends'     => $text_nodes['eqiad'],
+                'fixed_weight' => 10,
             },
         },
     }
@@ -131,9 +132,10 @@
                 'backends' => $site_text_nodes,
             },
             'backend_random' => {
-                'dynamic'  => 'yes',
-                'type'     => 'random',
-                'backends' => $site_text_nodes,
+                'dynamic'      => 'yes',
+                'type'         => 'random',
+                'backends'     => $site_text_nodes,
+                'fixed_weight' => 10,
             },
         },
         vcl_config      => {
diff --git a/modules/varnish/templates/vcl/directors.vcl.tpl.erb 
b/modules/varnish/templates/vcl/directors.vcl.tpl.erb
index 8b2c912..c0152c1 100644
--- a/modules/varnish/templates/vcl/directors.vcl.tpl.erb
+++ b/modules/varnish/templates/vcl/directors.vcl.tpl.erb
@@ -22,7 +22,7 @@
        {{range $node := ls "<%= @keyspace %>"}}{{ $key := printf "<%= 
@keyspace %>/%s" $node }}{{ $data := json (getv $key) }}{{ if eq $data.pooled 
"yes"}}
        {
                .backend = {{ $parts := split $node "." }}{{ index $parts 0 }};
-               .weight = {{ $data.weight }};
+               .weight = <% if director.include?'fixed_weight' %><%= 
director['fixed_weight'] %><% else %>{{ $data.weight }}<% end %>;
        }{{end}}{{end}}
 }
 <% end %>
diff --git a/modules/varnish/templates/vcl/wikimedia.vcl.erb 
b/modules/varnish/templates/vcl/wikimedia.vcl.erb
index 9a5c9da..14bb048 100644
--- a/modules/varnish/templates/vcl/wikimedia.vcl.erb
+++ b/modules/varnish/templates/vcl/wikimedia.vcl.erb
@@ -174,7 +174,7 @@
 -%>
        {
                .backend = <%= name %>;
-               .weight = <%= backend_option(backend, "weight", 10) %>;
+               .weight = <% if director.include?'fixed_weight' %><%= 
director['fixed_weight'] %><% else %><%= backend_option(backend, "weight", 10) 
%><% end %>;
        }
 <%     end -%>
 }

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

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

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

Reply via email to