BBlack has submitted this change and it was merged. Change subject: Revert "cache_app_route(): parser func for cache->app routing" ......................................................................
Revert "cache_app_route(): parser func for cache->app routing" In real-world testing, this still causes a puppet compile failure when a services is set to "split". In any case this is a stretch now, and there may be better ways to handle this behavior in the bigger picture. Reverting for now. This reverts commit 95a4df090aa521d865462d010738c592280f2929. Change-Id: I3635d6b5ff5b8af9711b79bf0aee0e0154c88cbf --- D modules/role/lib/puppet/parser/functions/cache_app_route.rb M modules/role/manifests/cache/maps.pp M modules/role/manifests/cache/text.pp M modules/role/manifests/cache/upload.pp 4 files changed, 16 insertions(+), 82 deletions(-) Approvals: BBlack: Verified; Looks good to me, approved diff --git a/modules/role/lib/puppet/parser/functions/cache_app_route.rb b/modules/role/lib/puppet/parser/functions/cache_app_route.rb deleted file mode 100644 index 9e2eaef..0000000 --- a/modules/role/lib/puppet/parser/functions/cache_app_route.rb +++ /dev/null @@ -1,69 +0,0 @@ -# == Function: cache_app_route ($app) -# -# Given an app name from the list in hiera('cache::foo::apps'), this function -# will make the applayer routing choice and return the correct backend host(s) -# to use in VCL configuration. -# -# This code supports an app's 'route' hierdata being either an explicit dcname -# for which the app defines backend(s), or the magic value 'split'. -# -# For 'split', the code walks the cache::route_table from the current site -# downwards until it finds a site that's 'direct', and then uses that site as -# the applayer route. This implies the constraint that if an app route is set -# to 'split', it must have backends defined for every dcname which maps to -# 'direct' in cache::route_table. -# -# Internally, this function references: -# $::site -# hiera('cluster') -# hiera('cache::foo::apps') # where foo is derived from cluster above -# hiera('cache::route_table') -# - -# I wouldn't normally be so verbose with 'raise X unless Y', but it's hard to -# decipher what's going on when puppet fails in here otherwise - -module Puppet::Parser::Functions - newfunction(:cache_app_route, :type => :rvalue, :arity => 1) do |args| - appname = args.first - raise 'cache_app_route(): arg must be a String' unless appname.is_a? String - - err_pfx = "cache_app_route(#{appname}): " - - site = compiler.topscope.lookupvar('site') - raise "#{err_pfx}missing $::site" unless site - - cache_rt = function_hiera(['cache::route_table']) - raise "#{err_pfx}missing cache::route_table" unless cache_rt - - full_cluster = function_hiera(['cluster']) - raise "#{err_pfx}missing cache cluster name" unless full_cluster - - cluster = full_cluster.gsub(/^cache_/, '') - apps = function_hiera(["cache::#{cluster}::apps"]) - raise "#{err_pfx}missing cache::#{cluster}::apps" unless apps - - app = apps[appname] - raise "#{err_pfx}missing cache::#{cluster}::apps::#{appname}" unless app - - route = app['route'] - raise "#{err_pfx}missing route attribute" unless route - - backends = app['backends'] - raise "#{err_pfx}missing backends attribute" unless backends - - if route == 'split' - cache_rt.size.times do - if cache_rt[site] == 'direct' - raise "#{err_pfx}split: no backend for #{site}" unless backends[site] - return backends[site] - end - site = cache_rt[site] - end - raise "#{err_pfx}infinite loop in cache::route_table" - else - raise "#{err_pfx}split: no backend for #{route}" unless backends[route] - return backends[route] - end - end -end diff --git a/modules/role/manifests/cache/maps.pp b/modules/role/manifests/cache/maps.pp index 8192424..81f2752 100644 --- a/modules/role/manifests/cache/maps.pp +++ b/modules/role/manifests/cache/maps.pp @@ -35,12 +35,13 @@ 'probe' => 'varnish', } + $apps = hiera('cache::maps::apps') $app_directors = { - 'kartotherian' => { + 'kartotherian' => { 'dynamic' => 'no', 'type' => 'random', - 'backends' => cache_app_route('kartotherian'), - 'be_opts' => { + 'backends' => $apps['kartotherian']['backends'][$apps['kartotherian']['route']], + 'be_opts' => { 'port' => 6533, 'connect_timeout' => '5s', 'first_byte_timeout' => '35s', diff --git a/modules/role/manifests/cache/text.pp b/modules/role/manifests/cache/text.pp index d0b91c1..46f4e45 100644 --- a/modules/role/manifests/cache/text.pp +++ b/modules/role/manifests/cache/text.pp @@ -45,53 +45,54 @@ 'max_connections' => 1000, } + $apps = hiera('cache::text::apps') $app_directors = { 'appservers' => { 'dynamic' => 'no', 'type' => 'random', - 'backends' => cache_app_route('appservers'), + 'backends' => $apps['appservers']['backends'][$apps['appservers']['route']], 'be_opts' => $app_def_be_opts, }, 'api' => { 'dynamic' => 'no', 'type' => 'random', - 'backends' => cache_app_route('api'), + 'backends' => $apps['api']['backends'][$apps['api']['route']], 'be_opts' => $app_def_be_opts, }, 'rendering' => { 'dynamic' => 'no', 'type' => 'random', - 'backends' => cache_app_route('rendering'), + 'backends' => $apps['rendering']['backends'][$apps['rendering']['route']], 'be_opts' => $app_def_be_opts, }, 'security_audit' => { 'dynamic' => 'no', 'type' => 'random', - 'backends' => cache_app_route('security_audit'), + 'backends' => $apps['security_audit']['backends'][$apps['security_audit']['route']], 'be_opts' => $app_def_be_opts, }, 'appservers_debug' => { 'dynamic' => 'no', 'type' => 'random', - 'backends' => cache_app_route('appservers_debug'), + 'backends' => $apps['appservers_debug']['backends'][$apps['appservers_debug']['route']], 'be_opts' => merge($app_def_be_opts, { 'max_connections' => 20 }), }, 'restbase_backend' => { 'dynamic' => 'no', 'type' => 'random', - 'backends' => cache_app_route('restbase'), + 'backends' => $apps['restbase']['backends'][$apps['restbase']['route']], 'be_opts' => merge($app_def_be_opts, { 'port' => 7231, 'max_connections' => 5000 }), }, 'cxserver_backend' => { # LEGACY: should be removed eventually 'dynamic' => 'no', 'type' => 'random', - 'backends' => cache_app_route('cxserver'), + 'backends' => $apps['cxserver']['backends'][$apps['cxserver']['route']], 'be_opts' => merge($app_def_be_opts, { 'port' => 8080 }), }, 'citoid_backend' => { # LEGACY: should be removed eventually 'dynamic' => 'no', 'type' => 'random', - 'backends' => cache_app_route('citoid'), + 'backends' => $apps['citoid']['backends'][$apps['citoid']['route']], 'be_opts' => merge($app_def_be_opts, { 'port' => 1970 }), }, } diff --git a/modules/role/manifests/cache/upload.pp b/modules/role/manifests/cache/upload.pp index cca8419..4457a8c 100644 --- a/modules/role/manifests/cache/upload.pp +++ b/modules/role/manifests/cache/upload.pp @@ -35,11 +35,12 @@ 'probe' => 'varnish', } + $apps = hiera('cache::upload::apps') $app_directors = { 'swift' => { 'dynamic' => 'no', 'type' => 'random', - 'backends' => cache_app_route('swift'), + 'backends' => $apps['swift']['backends'][$apps['swift']['route']], 'be_opts' => { 'port' => 80, 'connect_timeout' => '5s', @@ -51,7 +52,7 @@ 'swift_thumbs' => { 'dynamic' => 'no', 'type' => 'random', - 'backends' => cache_app_route('swift_thumbs'), + 'backends' => $apps['swift_thumbs']['backends'][$apps['swift_thumbs']['route']], 'be_opts' => { 'port' => 80, 'connect_timeout' => '5s', -- To view, visit https://gerrit.wikimedia.org/r/276380 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I3635d6b5ff5b8af9711b79bf0aee0e0154c88cbf Gerrit-PatchSet: 2 Gerrit-Project: operations/puppet Gerrit-Branch: production Gerrit-Owner: BBlack <bbl...@wikimedia.org> Gerrit-Reviewer: BBlack <bbl...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits