Add support for caching options
Trove supports caching using the oslo.cache library. This add support for customizing caching options. Change-Id: Ic4f8b9dc285efb4cd983cc6ba8a9eeaedd188456
This commit is contained in:
parent
0a832b7a06
commit
65214a004a
246
manifests/cache.pp
Normal file
246
manifests/cache.pp
Normal file
@ -0,0 +1,246 @@
|
||||
# Class trove::cache
|
||||
#
|
||||
# trove cache configuration
|
||||
#
|
||||
# == parameters
|
||||
#
|
||||
# [*config_prefix*]
|
||||
# (Optional) Prefix for building the configuration dictionary for
|
||||
# the cache region. This should not need to be changed unless there
|
||||
# is another dogpile.cache region with the same configuration name.
|
||||
# (string value)
|
||||
# Defaults to $facts['os_service_default']
|
||||
#
|
||||
# [*expiration_time*]
|
||||
# (Optional) Default TTL, in seconds, for any cached item in the
|
||||
# dogpile.cache region. This applies to any cached method that
|
||||
# doesn't have an explicit cache expiration time defined for it.
|
||||
# (integer value)
|
||||
# Defaults to $facts['os_service_default']
|
||||
#
|
||||
# [*backend*]
|
||||
# (Optional) Dogpile.cache backend module. It is recommended that
|
||||
# Memcache with pooling (oslo_cache.memcache_pool) or Redis
|
||||
# (dogpile.cache.redis) be used in production deployments. (string value)
|
||||
# Defaults to $facts['os_service_default']
|
||||
#
|
||||
# [*backend_argument*]
|
||||
# (Optional) Arguments supplied to the backend module. Specify this option
|
||||
# once per argument to be passed to the dogpile.cache backend.
|
||||
# Example format: "<argname>:<value>". (list value)
|
||||
# Defaults to $facts['os_service_default']
|
||||
#
|
||||
# [*proxies*]
|
||||
# (Optional) Proxy classes to import that will affect the way the
|
||||
# dogpile.cache backend functions. See the dogpile.cache documentation on
|
||||
# changing-backend-behavior. (list value)
|
||||
# Defaults to $facts['os_service_default']
|
||||
#
|
||||
# [*enabled*]
|
||||
# (Optional) Global toggle for caching. (boolean value)
|
||||
# Defaults to $facts['os_service_default']
|
||||
#
|
||||
# [*debug_cache_backend*]
|
||||
# (Optional) Extra debugging from the cache backend (cache keys,
|
||||
# get/set/delete/etc calls). This is only really useful if you need
|
||||
# to see the specific cache-backend get/set/delete calls with the keys/values.
|
||||
# Typically this should be left set to false. (boolean value)
|
||||
# Defaults to $facts['os_service_default']
|
||||
#
|
||||
# [*memcache_servers*]
|
||||
# (Optional) Memcache servers in the format of "host:port".
|
||||
# (dogpile.cache.memcache and oslo_cache.memcache_pool backends only).
|
||||
# (list value)
|
||||
# Defaults to $facts['os_service_default']
|
||||
#
|
||||
# [*memcache_dead_retry*]
|
||||
# (Optional) Number of seconds memcached server is considered dead before
|
||||
# it is tried again. (dogpile.cache.memcache and oslo_cache.memcache_pool
|
||||
# backends only). (integer value)
|
||||
# Defaults to $facts['os_service_default']
|
||||
#
|
||||
# [*memcache_socket_timeout*]
|
||||
# (Optional) Timeout in seconds for every call to a server.
|
||||
# (dogpile.cache.memcache and oslo_cache.memcache_pool backends only).
|
||||
# (floating point value)
|
||||
# Defaults to $facts['os_service_default']
|
||||
#
|
||||
# [*enable_socket_keepalive*]
|
||||
# (Optional) Global toggle for the socket keepalive of dogpile's
|
||||
# pymemcache backend
|
||||
# Defaults to $facts['os_service_default']
|
||||
#
|
||||
# [*socket_keepalive_idle*]
|
||||
# (Optional) The time (in seconds) the connection needs to remain idle
|
||||
# before TCP starts sending keepalive probes. Should be a positive integer
|
||||
# most greater than zero.
|
||||
# Defaults to $facts['os_service_default']
|
||||
#
|
||||
# [*socket_keepalive_interval*]
|
||||
# (Optional) The time (in seconds) between individual keepalive probes.
|
||||
# Should be a positive integer most greater than zero.
|
||||
# Defaults to $facts['os_service_default']
|
||||
#
|
||||
# [*socket_keepalive_count*]
|
||||
# (Optional) The maximum number of keepalive probes TCP should send before
|
||||
# dropping the connection. Should be a positive integer most greater than
|
||||
# zero.
|
||||
# Defaults to $facts['os_service_default']
|
||||
#
|
||||
# [*memcache_pool_maxsize*]
|
||||
# (Optional) Max total number of open connections to every memcached server.
|
||||
# (oslo_cache.memcache_pool backend only). (integer value)
|
||||
# Defaults to $facts['os_service_default']
|
||||
#
|
||||
# [*memcache_pool_unused_timeout*]
|
||||
# (Optional) Number of seconds a connection to memcached is held unused
|
||||
# in the pool before it is closed. (oslo_cache.memcache_pool backend only)
|
||||
# (integer value)
|
||||
# Defaults to $facts['os_service_default']
|
||||
#
|
||||
# [*memcache_pool_connection_get_timeout*]
|
||||
# (Optional) Number of seconds that an operation will wait to get a memcache
|
||||
# client connection. (integer value)
|
||||
# Defaults to $facts['os_service_default']
|
||||
#
|
||||
# [*memcache_pool_flush_on_reconnect*]
|
||||
# (Optional) Global toggle if memcache will be flushed on reconnect.
|
||||
# (oslo_cache.memcache_pool backend only)
|
||||
# Defaults to $facts['os_service_default']
|
||||
#
|
||||
# [*manage_backend_package*]
|
||||
# (Optional) Whether to install the backend package for the cache.
|
||||
# Defaults to true
|
||||
#
|
||||
# [*tls_enabled*]
|
||||
# (Optional) Global toggle for TLS usage when communicating with
|
||||
# the caching servers.
|
||||
# Default to $facts['os_service_default']
|
||||
#
|
||||
# [*tls_cafile*]
|
||||
# (Optional) Path to a file of concatenated CA certificates in PEM
|
||||
# format necessary to establish the caching server's authenticity.
|
||||
# If tls_enabled is False, this option is ignored.
|
||||
# Default to $facts['os_service_default']
|
||||
#
|
||||
# [*tls_certfile*]
|
||||
# (Optional) Path to a single file in PEM format containing the
|
||||
# client's certificate as well as any number of CA certificates
|
||||
# needed to establish the certificate's authenticity. This file
|
||||
# is only required when client side authentication is necessary.
|
||||
# If tls_enabled is False, this option is ignored.
|
||||
# Default to $facts['os_service_default']
|
||||
#
|
||||
# [*tls_keyfile*]
|
||||
# (Optional) Path to a single file containing the client's private
|
||||
# key in. Otherwise the private key will be taken from the file
|
||||
# specified in tls_certfile. If tls_enabled is False, this option
|
||||
# is ignored.
|
||||
# Default to $facts['os_service_default']
|
||||
#
|
||||
# [*tls_allowed_ciphers*]
|
||||
# (Optional) Set the available ciphers for sockets created with
|
||||
# the TLS context. It should be a string in the OpenSSL cipher
|
||||
# list format. If not specified, all OpenSSL enabled ciphers will
|
||||
# be available.
|
||||
# Default to $facts['os_service_default']
|
||||
#
|
||||
# [*enable_retry_client*]
|
||||
# (Optional) Enable retry client mechanisms to handle failure.
|
||||
# Those mechanisms can be used to wrap all kind of pymemcache
|
||||
# clients. The wrapper allows you to define how many attempts
|
||||
# to make and how long to wait between attempts.
|
||||
# Default to $facts['os_service_default']
|
||||
#
|
||||
# [*retry_attempts*]
|
||||
# (Optional) Number of times to attempt an action before failing.
|
||||
# Default to $facts['os_service_default']
|
||||
#
|
||||
# [*retry_delay*]
|
||||
# (Optional) Number of seconds to sleep between each attempt.
|
||||
# Default to $facts['os_service_default']
|
||||
#
|
||||
# [*hashclient_retry_attempts*]
|
||||
# (Optional) Amount of times a client should be tried
|
||||
# before it is marked dead and removed from the pool in
|
||||
# the HashClient's internal mechanisms.
|
||||
# Default to $facts['os_service_default']
|
||||
#
|
||||
# [*hashclient_retry_delay*]
|
||||
# (Optional) Time in seconds that should pass between
|
||||
# retry attempts in the HashClient's internal mechanisms.
|
||||
# Default to $facts['os_service_default']
|
||||
#
|
||||
# [*dead_timeout*]
|
||||
# (Optional) Time in seconds before attempting to add a node
|
||||
# back in the pool in the HashClient's internal mechanisms.
|
||||
# Default to $facts['os_service_default']
|
||||
#
|
||||
class trove::cache (
|
||||
$config_prefix = $facts['os_service_default'],
|
||||
$expiration_time = $facts['os_service_default'],
|
||||
$backend = $facts['os_service_default'],
|
||||
$backend_argument = $facts['os_service_default'],
|
||||
$proxies = $facts['os_service_default'],
|
||||
$enabled = $facts['os_service_default'],
|
||||
$debug_cache_backend = $facts['os_service_default'],
|
||||
$memcache_servers = $facts['os_service_default'],
|
||||
$memcache_dead_retry = $facts['os_service_default'],
|
||||
$memcache_socket_timeout = $facts['os_service_default'],
|
||||
$enable_socket_keepalive = $facts['os_service_default'],
|
||||
$socket_keepalive_idle = $facts['os_service_default'],
|
||||
$socket_keepalive_interval = $facts['os_service_default'],
|
||||
$socket_keepalive_count = $facts['os_service_default'],
|
||||
$memcache_pool_maxsize = $facts['os_service_default'],
|
||||
$memcache_pool_unused_timeout = $facts['os_service_default'],
|
||||
$memcache_pool_connection_get_timeout = $facts['os_service_default'],
|
||||
$memcache_pool_flush_on_reconnect = $facts['os_service_default'],
|
||||
$manage_backend_package = true,
|
||||
$tls_enabled = $facts['os_service_default'],
|
||||
$tls_cafile = $facts['os_service_default'],
|
||||
$tls_certfile = $facts['os_service_default'],
|
||||
$tls_keyfile = $facts['os_service_default'],
|
||||
$tls_allowed_ciphers = $facts['os_service_default'],
|
||||
$enable_retry_client = $facts['os_service_default'],
|
||||
$retry_attempts = $facts['os_service_default'],
|
||||
$retry_delay = $facts['os_service_default'],
|
||||
$hashclient_retry_attempts = $facts['os_service_default'],
|
||||
$hashclient_retry_delay = $facts['os_service_default'],
|
||||
$dead_timeout = $facts['os_service_default'],
|
||||
) {
|
||||
|
||||
include trove::deps
|
||||
|
||||
oslo::cache { 'trove_config':
|
||||
config_prefix => $config_prefix,
|
||||
expiration_time => $expiration_time,
|
||||
backend => $backend,
|
||||
backend_argument => $backend_argument,
|
||||
proxies => $proxies,
|
||||
enabled => $enabled,
|
||||
debug_cache_backend => $debug_cache_backend,
|
||||
memcache_servers => $memcache_servers,
|
||||
memcache_dead_retry => $memcache_dead_retry,
|
||||
memcache_socket_timeout => $memcache_socket_timeout,
|
||||
enable_socket_keepalive => $enable_socket_keepalive,
|
||||
socket_keepalive_idle => $socket_keepalive_idle,
|
||||
socket_keepalive_interval => $socket_keepalive_interval,
|
||||
socket_keepalive_count => $socket_keepalive_count,
|
||||
memcache_pool_maxsize => $memcache_pool_maxsize,
|
||||
memcache_pool_unused_timeout => $memcache_pool_unused_timeout,
|
||||
memcache_pool_connection_get_timeout => $memcache_pool_connection_get_timeout,
|
||||
memcache_pool_flush_on_reconnect => $memcache_pool_flush_on_reconnect,
|
||||
manage_backend_package => $manage_backend_package,
|
||||
tls_enabled => $tls_enabled,
|
||||
tls_cafile => $tls_cafile,
|
||||
tls_certfile => $tls_certfile,
|
||||
tls_keyfile => $tls_keyfile,
|
||||
tls_allowed_ciphers => $tls_allowed_ciphers,
|
||||
enable_retry_client => $enable_retry_client,
|
||||
retry_attempts => $retry_attempts,
|
||||
retry_delay => $retry_delay,
|
||||
hashclient_retry_attempts => $hashclient_retry_attempts,
|
||||
hashclient_retry_delay => $hashclient_retry_delay,
|
||||
dead_timeout => $dead_timeout,
|
||||
}
|
||||
}
|
28
manifests/cache/instance_ports.pp
vendored
Normal file
28
manifests/cache/instance_ports.pp
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
# == Class: trove::cache::instance_ports
|
||||
#
|
||||
# Configure instance_ports_cache options
|
||||
#
|
||||
# === Parameters
|
||||
#
|
||||
# [*expiration_time*]
|
||||
# (Optional) TTL, in seconds, for any cached item in the dogpile.cache region
|
||||
# used for caching of the instance ports.
|
||||
# Defaults to $facts['os_service_default']
|
||||
#
|
||||
# [*caching*]
|
||||
# (Optional) Toggle to enable/disable caching when getting trove instance
|
||||
# ports.
|
||||
# Defaults to $facts['os_service_default']
|
||||
#
|
||||
class trove::cache::instance_ports (
|
||||
$expiration_time = $facts['os_service_default'],
|
||||
$caching = $facts['os_service_default'],
|
||||
) {
|
||||
|
||||
include trove::deps
|
||||
|
||||
trove_config {
|
||||
'instance_ports_cache/expiration_time': value => $expiration_time;
|
||||
'instance_ports_cache/caching': value => $caching;
|
||||
}
|
||||
}
|
7
releasenotes/notes/cache-opts-d22f9a6692121131.yaml
Normal file
7
releasenotes/notes/cache-opts-d22f9a6692121131.yaml
Normal file
@ -0,0 +1,7 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
The following two classes have been added, to support caching options.
|
||||
|
||||
- ``trove::cache``
|
||||
- ``trove::cache::instance_ports``
|
39
spec/classes/trove_cache_instance_ports_spec.rb
Normal file
39
spec/classes/trove_cache_instance_ports_spec.rb
Normal file
@ -0,0 +1,39 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'trove::cache::instance_ports' do
|
||||
|
||||
shared_examples_for 'trove::cache::instance_ports' do
|
||||
context 'with default parameters' do
|
||||
it 'contains default values' do
|
||||
is_expected.to contain_trove_config('instance_ports_cache/expiration_time').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_trove_config('instance_ports_cache/caching').with_value('<SERVICE DEFAULT>')
|
||||
end
|
||||
end
|
||||
|
||||
context 'with overridden parameters' do
|
||||
let :params do
|
||||
{
|
||||
:expiration_time => 86400,
|
||||
:caching => true
|
||||
}
|
||||
end
|
||||
it 'contains overrided values' do
|
||||
is_expected.to contain_trove_config('instance_ports_cache/expiration_time').with_value(86400)
|
||||
is_expected.to contain_trove_config('instance_ports_cache/caching').with_value(true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
on_supported_os({
|
||||
:supported_os => OSDefaults.get_supported_os
|
||||
}).each do |os,facts|
|
||||
context "on #{os}" do
|
||||
let (:facts) do
|
||||
facts.merge!(OSDefaults.get_facts())
|
||||
end
|
||||
|
||||
it_configures 'trove::cache::instance_ports'
|
||||
end
|
||||
end
|
||||
|
||||
end
|
128
spec/classes/trove_cache_spec.rb
Normal file
128
spec/classes/trove_cache_spec.rb
Normal file
@ -0,0 +1,128 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'trove::cache' do
|
||||
|
||||
let :params do
|
||||
{}
|
||||
end
|
||||
|
||||
shared_examples_for 'trove::cache' do
|
||||
|
||||
context 'with default parameters' do
|
||||
it 'configures cache' do
|
||||
is_expected.to contain_oslo__cache('trove_config').with(
|
||||
:config_prefix => '<SERVICE DEFAULT>',
|
||||
:expiration_time => '<SERVICE DEFAULT>',
|
||||
:backend => '<SERVICE DEFAULT>',
|
||||
:backend_argument => '<SERVICE DEFAULT>',
|
||||
:proxies => '<SERVICE DEFAULT>',
|
||||
:enabled => '<SERVICE DEFAULT>',
|
||||
:debug_cache_backend => '<SERVICE DEFAULT>',
|
||||
:memcache_servers => '<SERVICE DEFAULT>',
|
||||
:memcache_dead_retry => '<SERVICE DEFAULT>',
|
||||
:memcache_socket_timeout => '<SERVICE DEFAULT>',
|
||||
:enable_socket_keepalive => '<SERVICE DEFAULT>',
|
||||
:socket_keepalive_idle => '<SERVICE DEFAULT>',
|
||||
:socket_keepalive_interval => '<SERVICE DEFAULT>',
|
||||
:socket_keepalive_count => '<SERVICE DEFAULT>',
|
||||
:memcache_pool_maxsize => '<SERVICE DEFAULT>',
|
||||
:memcache_pool_unused_timeout => '<SERVICE DEFAULT>',
|
||||
:memcache_pool_connection_get_timeout => '<SERVICE DEFAULT>',
|
||||
:memcache_pool_flush_on_reconnect => '<SERVICE DEFAULT>',
|
||||
:tls_enabled => '<SERVICE DEFAULT>',
|
||||
:tls_cafile => '<SERVICE DEFAULT>',
|
||||
:tls_certfile => '<SERVICE DEFAULT>',
|
||||
:tls_keyfile => '<SERVICE DEFAULT>',
|
||||
:tls_allowed_ciphers => '<SERVICE DEFAULT>',
|
||||
:enable_retry_client => '<SERVICE DEFAULT>',
|
||||
:retry_attempts => '<SERVICE DEFAULT>',
|
||||
:retry_delay => '<SERVICE DEFAULT>',
|
||||
:hashclient_retry_attempts => '<SERVICE DEFAULT>',
|
||||
:hashclient_retry_delay => '<SERVICE DEFAULT>',
|
||||
:dead_timeout => '<SERVICE DEFAULT>',
|
||||
:manage_backend_package => true,
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with overridden parameters' do
|
||||
let :params do
|
||||
{
|
||||
:config_prefix => 'prefix',
|
||||
:expiration_time => 3600,
|
||||
:backend => 'oslo_cache.memcache_pool',
|
||||
:proxies => ['proxy01:8888', 'proxy02:8888'],
|
||||
:enabled => true,
|
||||
:debug_cache_backend => false,
|
||||
:memcache_servers => ['memcached01:11211', 'memcached02:11211'],
|
||||
:memcache_dead_retry => '60',
|
||||
:memcache_socket_timeout => '300.0',
|
||||
:enable_socket_keepalive => false,
|
||||
:socket_keepalive_idle => 1,
|
||||
:socket_keepalive_interval => 1,
|
||||
:socket_keepalive_count => 1,
|
||||
:memcache_pool_maxsize => '10',
|
||||
:memcache_pool_unused_timeout => '120',
|
||||
:memcache_pool_connection_get_timeout => '360',
|
||||
:memcache_pool_flush_on_reconnect => false,
|
||||
:tls_enabled => false,
|
||||
:enable_retry_client => false,
|
||||
:retry_attempts => 2,
|
||||
:retry_delay => 0,
|
||||
:hashclient_retry_attempts => 2,
|
||||
:hashclient_retry_delay => 1,
|
||||
:dead_timeout => 60,
|
||||
:manage_backend_package => false,
|
||||
}
|
||||
end
|
||||
|
||||
it 'configures cache' do
|
||||
is_expected.to contain_oslo__cache('trove_config').with(
|
||||
:config_prefix => 'prefix',
|
||||
:expiration_time => 3600,
|
||||
:backend => 'oslo_cache.memcache_pool',
|
||||
:backend_argument => '<SERVICE DEFAULT>',
|
||||
:proxies => ['proxy01:8888', 'proxy02:8888'],
|
||||
:enabled => true,
|
||||
:debug_cache_backend => false,
|
||||
:memcache_servers => ['memcached01:11211', 'memcached02:11211'],
|
||||
:memcache_dead_retry => '60',
|
||||
:memcache_socket_timeout => '300.0',
|
||||
:enable_socket_keepalive => false,
|
||||
:socket_keepalive_idle => 1,
|
||||
:socket_keepalive_interval => 1,
|
||||
:socket_keepalive_count => 1,
|
||||
:memcache_pool_maxsize => '10',
|
||||
:memcache_pool_unused_timeout => '120',
|
||||
:memcache_pool_connection_get_timeout => '360',
|
||||
:memcache_pool_flush_on_reconnect => false,
|
||||
:tls_enabled => false,
|
||||
:tls_cafile => '<SERVICE DEFAULT>',
|
||||
:tls_certfile => '<SERVICE DEFAULT>',
|
||||
:tls_keyfile => '<SERVICE DEFAULT>',
|
||||
:tls_allowed_ciphers => '<SERVICE DEFAULT>',
|
||||
:enable_retry_client => false,
|
||||
:retry_attempts => 2,
|
||||
:retry_delay => 0,
|
||||
:hashclient_retry_attempts => 2,
|
||||
:hashclient_retry_delay => 1,
|
||||
:dead_timeout => 60,
|
||||
:manage_backend_package => false,
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
on_supported_os({
|
||||
:supported_os => OSDefaults.get_supported_os
|
||||
}).each do |os,facts|
|
||||
context "on #{os}" do
|
||||
let (:facts) do
|
||||
facts.merge!(OSDefaults.get_facts())
|
||||
end
|
||||
|
||||
it_configures 'trove::cache'
|
||||
end
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in New Issue
Block a user