Browse Source

fix name for master of redis cluster

value of master name should be the same as in
ceilometer redis backend url

Co-Authored-By: alexey-mr <Alexey.Morlang@gmail.com>

Change-Id: Ic9f6399950597db399718b4e607c6586db5647e3
Closes-Bug: #1553229
Mykyta Karpin 3 years ago
parent
commit
39bd25c060

+ 5
- 0
deployment_scripts/puppet/manifests/controller.pp View File

@@ -26,9 +26,14 @@ $redis_primary_nodes       = get_nodes_hash_by_roles(hiera('network_metadata'),
26 26
 $redis_primary_address_map = get_node_to_ipaddr_map_by_network_role($redis_primary_nodes, 'ceilometer/api')
27 27
 $primary_redis_node        = values($redis_primary_address_map)
28 28
 
29
+# TODO: get value from hiera
30
+$master_name               = 'ceilometer_redis_master'
31
+
32
+
29 33
 class {'::redis::main':
30 34
   primary_redis_node => $primary_redis_node[0],
31 35
   redis_hosts        => $redis_hosts,
32 36
   redis_bind_address => $redis_bind_address,
33 37
   primary_controller => hiera('primary_controller'),
38
+  master_name        => $master_name,
34 39
 }

+ 3
- 2
deployment_scripts/puppet/modules/redis/lib/puppet/parser/functions/redis_backend_url.rb View File

@@ -1,13 +1,14 @@
1 1
 module Puppet::Parser::Functions
2 2
   newfunction(:redis_backend_url, :type => :rvalue) do |args|
3
-    if args.length != 3
3
+    if args.length != 4
4 4
       raise "Wrong number of arguments"
5 5
     end
6 6
     nodes = args[0]
7 7
     port = args[1]
8 8
     timeout = args[2]
9
+    master_name = args[3]
9 10
 
10
-    backend_url="redis://" + nodes[0] + ":" + port + "?sentinel=" + nodes[0]
11
+    backend_url="redis://" + nodes[0] + ":" + port + "?sentinel=" + master_name
11 12
 
12 13
     nodes.each do |value|
13 14
       if value != nodes[0]

+ 7
- 4
deployment_scripts/puppet/modules/redis/lib/puppet/parser/functions/sentinel_confs.rb View File

@@ -12,10 +12,13 @@ module Puppet::Parser::Functions
12 12
     hash = {}
13 13
 
14 14
     nodes.each do |value|
15
-      hash[value] = { 'monitor' => value + ' ' + port + ' ' + quorum,
16
-                      'down-after-milliseconds' => down_after_milliseconds,
17
-                      'failover-timeout' => failover_timeout,
18
-                      'parallel-syncs' => parallel_syncs }
15
+      name = value['name']
16
+      addr = value['addr']
17
+      hash[name] = {
18
+                     'monitor' => addr + ' ' + port + ' ' + quorum,
19
+                     'down-after-milliseconds' => down_after_milliseconds,
20
+                     'failover-timeout' => failover_timeout,
21
+                     'parallel-syncs' => parallel_syncs }
19 22
     end
20 23
 
21 24
     hash

+ 11
- 4
deployment_scripts/puppet/modules/redis/manifests/main.pp View File

@@ -54,6 +54,7 @@ class redis::main (
54 54
   $redis_bind_address      = '0.0.0.0',
55 55
   $redis_port              = '6379',
56 56
   $redis_sentinel_port     = '26379',
57
+  $master_name             = 'mymaster',
57 58
 ) {
58 59
 
59 60
   include ceilometer::params
@@ -107,9 +108,14 @@ class redis::main (
107 108
   }
108 109
 
109 110
   # Use custom function to generate sentinel configuration
110
-  $sentinel_confs = sentinel_confs($redis_hosts, $redis_port, $quorum,
111
-                                    $parallel_syncs, $down_after_milliseconds,
112
-                                    $failover_timeout)
111
+  $masters_to_monitor = [
112
+    { name => $master_name,
113
+      addr => $primary_redis_node
114
+    },
115
+  ]
116
+  $sentinel_confs = sentinel_confs($masters_to_monitor, $redis_port, $quorum,
117
+                                   $parallel_syncs, $down_after_milliseconds,
118
+                                   $failover_timeout)
113 119
 
114 120
   package {'python-redis':
115 121
     ensure => 'present',
@@ -127,10 +133,11 @@ class redis::main (
127 133
     conf_port              => $redis_sentinel_port,
128 134
     sentinel_confs         => $sentinel_confs,
129 135
     manage_upstart_scripts => $manage_upstart_scripts,
136
+    master_name            => $master_name
130 137
   }
131 138
 
132 139
   ceilometer_config {
133
-    'coordination/backend_url'    : value => redis_backend_url($redis_hosts, $redis_sentinel_port, $timeout);
140
+    'coordination/backend_url'    : value => redis_backend_url($redis_hosts, $redis_sentinel_port, $timeout, $master_name);
134 141
     'coordination/heartbeat'      : value => '1.0';
135 142
     'coordination/check_watchers' : value => $timeout;
136 143
     'notification/workload_partitioning': value => true

+ 1
- 0
deployment_scripts/puppet/modules/redis/manifests/sentinel.pp View File

@@ -47,6 +47,7 @@ class redis::sentinel (
47 47
   $service_restart          = true,
48 48
   $manage_upstart_scripts   = true,
49 49
   $package_name             = undef,
50
+  $master_name              = 'mymaster'
50 51
 ) {
51 52
 
52 53
   include redis::sentinel_params

Loading…
Cancel
Save