Skip to content

Add parameters latency_tracking & repl_diskless_sync #540

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
36 changes: 36 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ The following parameters are available in the `redis` class:
* [`hll_sparse_max_bytes`](#-redis--hll_sparse_max_bytes)
* [`hz`](#-redis--hz)
* [`latency_monitor_threshold`](#-redis--latency_monitor_threshold)
* [`latency_tracking`](#-redis--latency_tracking)
* [`list_max_ziplist_entries`](#-redis--list_max_ziplist_entries)
* [`list_max_ziplist_value`](#-redis--list_max_ziplist_value)
* [`log_dir`](#-redis--log_dir)
Expand Down Expand Up @@ -153,6 +154,7 @@ The following parameters are available in the `redis` class:
* [`repl_announce_port`](#-redis--repl_announce_port)
* [`repl_backlog_size`](#-redis--repl_backlog_size)
* [`repl_backlog_ttl`](#-redis--repl_backlog_ttl)
* [`repl_diskless_sync`](#-redis--repl_diskless_sync)
* [`repl_disable_tcp_nodelay`](#-redis--repl_disable_tcp_nodelay)
* [`repl_ping_slave_period`](#-redis--repl_ping_slave_period)
* [`repl_timeout`](#-redis--repl_timeout)
Expand Down Expand Up @@ -455,6 +457,14 @@ Latency monitoring threshold in milliseconds

Default value: `0`

##### <a name="-redis--latency_tracking"></a>`latency_tracking`

Data type: `Boolean`

Latency monitoring enabled

Default value: `true`

##### <a name="-redis--list_max_ziplist_entries"></a>`list_max_ziplist_entries`

Data type: `Integer[0]`
Expand Down Expand Up @@ -784,6 +794,14 @@ The number of seconds to elapse before freeing backlog buffer

Default value: `3600`

##### <a name="-redis--repl_diskless_sync"></a>`repl_diskless_sync`

Data type: `Boolean`

Enable/disable diskless replication

Default value: `true`

##### <a name="-redis--repl_disable_tcp_nodelay"></a>`repl_disable_tcp_nodelay`

Data type: `Boolean`
Expand Down Expand Up @@ -1944,6 +1962,7 @@ The following parameters are available in the `redis::instance` defined type:
* [`hll_sparse_max_bytes`](#-redis--instance--hll_sparse_max_bytes)
* [`hz`](#-redis--instance--hz)
* [`latency_monitor_threshold`](#-redis--instance--latency_monitor_threshold)
* [`latency_tracking`](#-redis--instance--latency_tracking)
* [`list_max_ziplist_entries`](#-redis--instance--list_max_ziplist_entries)
* [`list_max_ziplist_value`](#-redis--instance--list_max_ziplist_value)
* [`log_dir`](#-redis--instance--log_dir)
Expand Down Expand Up @@ -1972,6 +1991,7 @@ The following parameters are available in the `redis::instance` defined type:
* [`repl_announce_port`](#-redis--instance--repl_announce_port)
* [`repl_backlog_size`](#-redis--instance--repl_backlog_size)
* [`repl_backlog_ttl`](#-redis--instance--repl_backlog_ttl)
* [`repl_diskless_sync`](#-redis--instance--repl_diskless_sync)
* [`repl_disable_tcp_nodelay`](#-redis--instance--repl_disable_tcp_nodelay)
* [`repl_ping_slave_period`](#-redis--instance--repl_ping_slave_period)
* [`repl_timeout`](#-redis--instance--repl_timeout)
Expand Down Expand Up @@ -2236,6 +2256,14 @@ Latency monitoring threshold in milliseconds

Default value: `$redis::latency_monitor_threshold`

##### <a name="-redis--instance--latency_tracking"></a>`latency_tracking`

Data type: `Boolean`

Latency monitoring enabled

Default value: `$redis::latency_tracking`

##### <a name="-redis--instance--list_max_ziplist_entries"></a>`list_max_ziplist_entries`

Data type: `Integer[0]`
Expand Down Expand Up @@ -2461,6 +2489,14 @@ The number of seconds to elapse before freeing backlog buffer

Default value: `$redis::repl_backlog_ttl`

##### <a name="-redis--instance--repl_diskless_sync"></a>`repl_diskless_sync`

Data type: `Boolean`

Enable/disable diskless replication

Default value: `$redis::repl_diskless_sync`

##### <a name="-redis--instance--repl_disable_tcp_nodelay"></a>`repl_disable_tcp_nodelay`

Data type: `Boolean`
Expand Down
6 changes: 6 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@
# Set redis background tasks frequency
# @param latency_monitor_threshold
# Latency monitoring threshold in milliseconds
# @param latency_tracking
# Latency monitoring enabled
# @param list_max_ziplist_entries
# Set max ziplist entries for lists.
# @param list_max_ziplist_value
Expand Down Expand Up @@ -158,6 +160,8 @@
# The replication backlog size
# @param repl_backlog_ttl
# The number of seconds to elapse before freeing backlog buffer
# @param repl_diskless_sync
# Enable/disable diskless replication
# @param repl_disable_tcp_nodelay
# Enable/disable TCP_NODELAY on the slave socket after SYNC
# @param repl_ping_slave_period
Expand Down Expand Up @@ -382,6 +386,7 @@
Integer[0] $hll_sparse_max_bytes = 3000,
Integer[1, 500] $hz = 10,
Integer[0] $latency_monitor_threshold = 0,
Boolean $latency_tracking = true,
Integer[0] $list_max_ziplist_entries = 512,
Integer[0] $list_max_ziplist_value = 64,
Stdlib::Absolutepath $log_dir = $redis::params::log_dir,
Expand Down Expand Up @@ -422,6 +427,7 @@
Optional[Stdlib::Port] $repl_announce_port = undef,
String[1] $repl_backlog_size = '1mb',
Integer[0] $repl_backlog_ttl = 3600,
Boolean $repl_diskless_sync = true,
Boolean $repl_disable_tcp_nodelay = false,
Integer[1] $repl_ping_slave_period = 10,
Integer[1] $repl_timeout = 60,
Expand Down
12 changes: 12 additions & 0 deletions manifests/instance.pp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
# Set redis background tasks frequency
# @param latency_monitor_threshold
# Latency monitoring threshold in milliseconds
# @param latency_tracking
# Latency monitoring enabled
# @param list_max_ziplist_entries
# Set max ziplist entries for lists.
# @param list_max_ziplist_value
Expand Down Expand Up @@ -113,6 +115,8 @@
# The replication backlog size
# @param repl_backlog_ttl
# The number of seconds to elapse before freeing backlog buffer
# @param repl_diskless_sync
# Enable/disable diskless replication
# @param repl_disable_tcp_nodelay
# Enable/disable TCP_NODELAY on the slave socket after SYNC
# @param repl_ping_slave_period
Expand Down Expand Up @@ -319,6 +323,7 @@
Integer[0] $hll_sparse_max_bytes = $redis::hll_sparse_max_bytes,
Integer[1, 500] $hz = $redis::hz,
Integer[0] $latency_monitor_threshold = $redis::latency_monitor_threshold,
Boolean $latency_tracking = $redis::latency_tracking,
Integer[0] $list_max_ziplist_entries = $redis::list_max_ziplist_entries,
Integer[0] $list_max_ziplist_value = $redis::list_max_ziplist_value,
Stdlib::Absolutepath $log_dir = $redis::log_dir,
Expand All @@ -344,6 +349,7 @@
Optional[Stdlib::Port] $repl_announce_port = $redis::repl_announce_port,
String[1] $repl_backlog_size = $redis::repl_backlog_size,
Integer[0] $repl_backlog_ttl = $redis::repl_backlog_ttl,
Boolean $repl_diskless_sync = $redis::repl_diskless_sync,
Boolean $repl_disable_tcp_nodelay = $redis::repl_disable_tcp_nodelay,
Integer[1] $repl_ping_slave_period = $redis::repl_ping_slave_period,
Integer[1] $repl_timeout = $redis::repl_timeout,
Expand Down Expand Up @@ -501,6 +507,9 @@

$bind_arr = [$bind].flatten

$default_redis_version = '8.0.0'
$redis_version = $facts.get('redis_server_version', $instance::default_version_var)

$_template_params = {
daemonize => $daemonize,
pid_file => $pid_file,
Expand Down Expand Up @@ -535,6 +544,7 @@
repl_disable_tcp_nodelay => $repl_disable_tcp_nodelay,
repl_backlog_size => $repl_backlog_size,
repl_backlog_ttl => $repl_backlog_ttl,
repl_diskless_sync => $repl_diskless_sync,
slave_priority => $slave_priority,
min_slaves_to_write => $min_slaves_to_write,
min_slaves_max_lag => $min_slaves_max_lag,
Expand All @@ -554,6 +564,7 @@
slowlog_log_slower_than => $slowlog_log_slower_than,
slowlog_max_len => $slowlog_max_len,
latency_monitor_threshold => $latency_monitor_threshold,
latency_tracking => $latency_tracking,
notify_keyspace_events => $notify_keyspace_events,
hash_max_ziplist_entries => $hash_max_ziplist_entries,
hash_max_ziplist_value => $hash_max_ziplist_value,
Expand Down Expand Up @@ -604,6 +615,7 @@
rdb_save_incremental_fsync => $rdb_save_incremental_fsync,
acls => $acls,
custom_options => $custom_options,
redis_version => $redis_version,
}

# TODO: Rely on https://github.com/puppetlabs/puppetlabs-stdlib/pull/1425
Expand Down
28 changes: 28 additions & 0 deletions spec/classes/redis_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
let(:facts) { facts }

describe 'without parameters' do
it { is_expected.to compile.with_all_deps }

Check failure on line 30 in spec/classes/redis_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

redis on debian-11-x86_64 without parameters is expected to compile into a catalogue without dependency cycles Failure/Error: it { is_expected.to compile.with_all_deps } error during compilation: Evaluation Error: Error while evaluating a Resource Statement, Evaluation Error: Unknown variable: 'instance::default_version_var'. (file: /home/runner/work/puppet-redis/puppet-redis/spec/fixtures/modules/redis/manifests/instance.pp, line: 511, column: 55) (file: /home/runner/work/puppet-redis/puppet-redis/spec/fixtures/modules/redis/manifests/config.pp, line: 30) on node fv-az1971-117.uviqhynusljuvnxuh24jnoaoob.cx.internal.cloudapp.net

Check failure on line 30 in spec/classes/redis_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

redis on debian-11-x86_64 without parameters is expected to compile into a catalogue without dependency cycles Failure/Error: it { is_expected.to compile.with_all_deps } error during compilation: Evaluation Error: Error while evaluating a Resource Statement, Evaluation Error: Unknown variable: 'instance::default_version_var'. (file: /home/runner/work/puppet-redis/puppet-redis/spec/fixtures/modules/redis/manifests/instance.pp, line: 511, column: 55) (file: /home/runner/work/puppet-redis/puppet-redis/spec/fixtures/modules/redis/manifests/config.pp, line: 30) on node fv-az1690-65.qpzrwuosrkvuxczmeamxp1lsch.ex.internal.cloudapp.net
it { is_expected.to create_class('redis') }
it { is_expected.to contain_class('redis::preinstall') }
it { is_expected.to contain_class('redis::install') }
Expand Down Expand Up @@ -741,6 +741,20 @@
}
end

describe 'with parameter latency_tracking' do
let(:params) do
{
latency_tracking: true
}
end

it {
is_expected.to contain_file(config_file_orig).with(
'content' => %r{^latency-tracking yes$}
)
}
end

describe 'with parameter rdbcompression' do
let(:params) do
{
Expand Down Expand Up @@ -826,6 +840,20 @@
}
end

describe 'with parameter repl_diskless_sync' do
let(:params) do
{
repl_diskless_sync: true
}
end

it {
is_expected.to contain_file(config_file_orig).with(
'content' => %r{^repl-diskless-sync yes$}
)
}
end

describe 'with parameter repl_disable_tcp_nodelay' do
let(:params) do
{
Expand Down
46 changes: 46 additions & 0 deletions templates/redis.conf.epp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
Boolean $repl_disable_tcp_nodelay,
String[1] $repl_backlog_size,
Integer[0] $repl_backlog_ttl,
Boolean $repl_diskless_sync,
Integer[0] $slave_priority,
Integer[0] $min_slaves_to_write,
Integer[0] $min_slaves_max_lag,
Expand All @@ -51,6 +52,7 @@
Integer[-1] $slowlog_log_slower_than,
Integer[0] $slowlog_max_len,
Integer[0] $latency_monitor_threshold,
Boolean $latency_tracking,
Optional[String[1]] $notify_keyspace_events,
Integer[0] $hash_max_ziplist_entries,
Integer[0] $hash_max_ziplist_value,
Expand Down Expand Up @@ -101,6 +103,7 @@
Optional[Boolean] $rdb_save_incremental_fsync,
Array[String[1]] $acls,
Hash[String[1],Variant[String[1], Integer]] $custom_options,
String[1] $redis_version
| -%>
# Redis configuration file example

Expand Down Expand Up @@ -562,6 +565,37 @@ slave-priority <%= $slave_priority %>
min-slaves-to-write <%= $min_slaves_to_write %>
min-slaves-max-lag <%= $min_slaves_max_lag %>

# Replication SYNC strategy: disk or socket.
#
# New replicas and reconnecting replicas that are not able to continue the
# replication process just receiving differences, need to do what is called a
# "full synchronization". An RDB file is transmitted from the master to the
# replicas.
#
# The transmission can happen in two different ways:
#
# 1) Disk-backed: The Redis master creates a new process that writes the RDB
# file on disk. Later the file is transferred by the parent
# process to the replicas incrementally.
# 2) Diskless: The Redis master creates a new process that directly writes the
# RDB file to replica sockets, without touching the disk at all.
#
# With disk-backed replication, while the RDB file is generated, more replicas
# can be queued and served with the RDB file as soon as the current child
# producing the RDB file finishes its work. With diskless replication instead
# once the transfer starts, new replicas arriving will be queued and a new
# transfer will start when the current one terminates.
#
# When diskless replication is used, the master waits a configurable amount of
# time (in seconds) before starting the transfer in the hope that multiple
# replicas will arrive and the transfer can be parallelized.
#
# With slow disks and fast (large bandwidth) networks, diskless replication
# works better.
<%- if versioncmp($redis_version, '7.0.0') >= 0 { -%>
repl-diskless-sync <%= bool2str($repl_diskless_sync, 'yes', 'no') -%>
<%- } -%>

################################## SECURITY ###################################

# Require clients to issue AUTH <PASSWORD> before processing any other
Expand Down Expand Up @@ -845,6 +879,18 @@ slowlog-max-len <%= $slowlog_max_len %>
# "CONFIG SET latency-monitor-threshold <milliseconds>" if needed.
latency-monitor-threshold <%= $latency_monitor_threshold %>

################################ LATENCY TRACKING ##############################

# The Redis extended latency monitoring tracks the per command latencies and enables
# exporting the percentile distribution via the INFO latencystats command,
# and cumulative latency distributions (histograms) via the LATENCY command.
#
# By default, the extended latency monitoring is enabled since the overhead
# of keeping track of the command latency is very small.
<% if versioncmp($redis_version, '7.0.0') >= 0 { %>
latency-tracking <%= bool2str($latency_tracking, 'yes', 'no') -%>
<% } %>

############################# Event notification ##############################

# Redis can notify Pub/Sub clients about events happening in the key space.
Expand Down
Loading