Puppet Class: profile::openstack::base::cloudweb_mcrouter

Defined in:
modules/profile/manifests/openstack/base/cloudweb_mcrouter.pp

Overview

Class profile::openstack::base::cloudweb_mcrouter

Configures a mcrouter cluster which pools all cloudweb hosts

Parameters:

  • cloudweb_hosts (Array[Stdlib::Fqdn]) (defaults to: lookup('profile::openstack::base::labweb_hosts'))
  • mcrouter_port (Stdlib::Port) (defaults to: lookup('profile::openstack::base::cloudweb::mcrouter_port'))
  • memcached_size (Integer) (defaults to: lookup('profile::openstack::base::cloudweb_memcached_size'))


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'modules/profile/manifests/openstack/base/cloudweb_mcrouter.pp', line 5

class profile::openstack::base::cloudweb_mcrouter(
    Array[Stdlib::Fqdn] $cloudweb_hosts = lookup('profile::openstack::base::labweb_hosts'),
    Stdlib::Port        $mcrouter_port  = lookup('profile::openstack::base::cloudweb::mcrouter_port'),
    Integer             $memcached_size = lookup('profile::openstack::base::cloudweb_memcached_size'),
) {
    # Replicated cache set including all cloudweb hosts.
    #
    # This is used for Horizon session and page caching.  Note
    #  that it's easy to start losing sessions if the cache size
    #  is too small (T145703)
    #
    # The route config here is copy/pasted from
    #  https://github.com/facebook/mcrouter/wiki/Replicated-pools-setup
    #
    # The cross-region bits don't actually matter but the parent class expects them.
    class { '::mcrouter':
        region                   => $::site,
        cluster                  => 'cloudweb',
        cross_region_timeout_ms  => 250,
        cross_cluster_timeout_ms => 1000,
        pools                    => {
            'cloudweb' => {
                servers => $cloudweb_hosts.map |$cloudwebhost| { sprintf('%s:11000:ascii:plain',ipresolve($cloudwebhost,4)) }
            },
        },
        routes                   => [
            aliases              => [ "/${::site}/cloudweb/" ],
            route                => {
                type               => 'OperationSelectorRoute',
                default_policy     => 'PoolRoute|cloudweb',
                operation_policies => {
                    add    => 'AllSyncRoute|Pool|cloudweb',
                    delete => 'AllSyncRoute|Pool|cloudweb',
                    get    => 'LatestRoute|Pool|cloudweb',
                    set    => 'AllSyncRoute|Pool|cloudweb'
                }
            }
        ]
    }

    class { '::memcached':
        size          => $memcached_size,
        # TODO: the following were implicit defaults from
        # MW settings, need to be reviewed.
        growth_factor => 1.05,
        min_slab_size => 5,
    }
    class { '::profile::prometheus::memcached_exporter': }

    ferm::rule { 'skip_mcrouter_cloudweb_conntrack_out':
        desc  => 'Skip outgoing connection tracking for mcrouter',
        table => 'raw',
        chain => 'OUTPUT',
        rule  => "proto tcp sport (${mcrouter_port}) NOTRACK;",
    }

    ferm::rule { 'skip_mcrouter_cloudweb_conntrack_in':
        desc  => 'Skip incoming connection tracking for mcrouter',
        table => 'raw',
        chain => 'PREROUTING',
        rule  => "proto tcp dport (${mcrouter_port}) NOTRACK;",
    }

    ferm::service { 'mcrouter':
        desc    => 'Allow connections to mcrouter',
        proto   => 'tcp',
        notrack => true,
        port    => $mcrouter_port,
        srange  => "(@resolve((${join($cloudweb_hosts,' ')}))
                    @resolve((${join($cloudweb_hosts,' ')}), AAAA))",
    }

    ferm::service { 'memcached_for_mcrouter':
        desc    => 'Allow connections to memcached',
        proto   => 'tcp',
        notrack => true,
        port    => 11000,
        srange  => "(@resolve((${join($cloudweb_hosts,' ')}))
                    @resolve((${join($cloudweb_hosts,' ')}), AAAA))",
    }
}