Alexandros Kosiaris has uploaded a new change for review.

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

Change subject: ores: Collapse the redis configs into one stanza
......................................................................

ores: Collapse the redis configs into one stanza

Since redis::instance allows us to use map to override configs per redis
instance, take advantage of that to collapse the config in order to add
support for replication in an easier fashion. While at it add all the
usual settings we have for a jobqueue redis and for now apply them as is
on the cache as well. That is:

* Use the standard /srv/redis directory
* Name the db filename per instance
* Enable AOF
* Effectively stop RDB by specifying an empty save
* Increase defaults limits for replication
* Apply latency improvents on fsync
* Have slave be able to be used read-write
* Don't stop writes on bgsave error

Bug: T124200
Change-Id: I49f5995363fbc669625af1c8a512c0f43ad9fe9b
---
M modules/ores/manifests/redis.pp
1 file changed, 46 insertions(+), 27 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/36/278836/1

diff --git a/modules/ores/manifests/redis.pp b/modules/ores/manifests/redis.pp
index 713ef35..51bf688 100644
--- a/modules/ores/manifests/redis.pp
+++ b/modules/ores/manifests/redis.pp
@@ -1,37 +1,56 @@
 class ores::redis(
     $queue_maxmemory,
     $cache_maxmemory,
+    $password=undef,
+    $slaveof=undef,
 ) {
-    file { [
-        '/srv/redis/queue',
-        '/srv/redis/cache'
-        ]:
-        ensure => directory,
-        owner  => 'redis',
-        group  => 'redis',
-        mode   => '0774'
+    $common_settings = {
+            bind                        => '0.0.0.0',
+            appendonly                  => true,
+            auto_aof_rewrite_min_size   => '512mb',
+            client_output_buffer_limit  => 'slave 512mb 200mb 60',
+            dir                         => '/srv/redis',
+            no_appendfsync_on_rewrite   => true,
+            save                        => '""',
+            stop_writes_on_bgsave_error => false,
+            slave_read_only             => false,
+            tcp_keepalive               => 60,
+    }
+    $instance_settings = {
+        '6379' => {
+            maxmemory      => $queue_maxmemory,
+            appendfilename => "${::hostname}-6379.aof",
+            dbfilename     => "${::hostname}-6379.rdb",
+        },
+        '6380' => {
+            maxmemory      => $cache_maxmemory,
+            appendfilename => "${::hostname}-6380.aof",
+            dbfilename     => "${::hostname}-6380.rdb",
+        }
     }
 
-    # FIXME: Tune the individual redises better for their use case
-    # For the queue
-    redis::instance { '6379':
-        settings => {
-            bind          => '0.0.0.0',
-            dir           => '/srv/redis/queue',
-            maxmemory     => $queue_maxmemory,
-            tcp_keepalive => 60,
-        },
-        require  => File['/srv/redis/queue']
+    # If we specified a password use it
+    if $password {
+        $password_settings = {
+            masterauth  => $password,
+            requirepass => $password,
+        }
+    } else {
+        $password_settings = {}
     }
+    $common_settings_real = deep_merge($common_settings, $password_settings)
+    # if we specified a slave, use it
+    if $slave {
+        $slave_settings = {
+            slaveof => $slaveof,
+        }
+    } else {
+        $slave_settings = {}
+    }
+    $instance_settings_real = deep_merge($instance_settings, $slave_settings)
 
-    # For the cache
-    redis::instance { '6380':
-        settings => {
-            bind          => '0.0.0.0',
-            dir           => '/srv/redis/cache',
-            maxmemory     => $cache_maxmemory,
-            tcp_keepalive => 60,
-        },
-        require  => File['/srv/redis/cache']
+    redis::instance { ['6379', '6389']:
+        settings => $common_settings_real,
+        map      => $instance_settings_real,
     }
 }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I49f5995363fbc669625af1c8a512c0f43ad9fe9b
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Alexandros Kosiaris <[email protected]>

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

Reply via email to