Add ability to configure cache

As Nova user I would like to have ability to
configure cache parameters via Puppet, so we need
to add missing parameters to manifests.

Change-Id: I601163fd233396e456f459e58f39c7772e16ec81
This commit is contained in:
Alexey Deryugin 2016-06-08 19:20:24 +03:00
parent 96ec7b5bec
commit 7bfc1807c1
3 changed files with 201 additions and 0 deletions

117
manifests/cache.pp Normal file
View File

@ -0,0 +1,117 @@
# Class nova::cache
#
# nova 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 $::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 $::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 $::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 $::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 $::os_service_default
#
# [*enabled*]
# (Optional) Global toggle for caching. (boolean value)
# Defaults to $::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 $::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 $::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 $::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).
# (integer value)
# Defaults to $::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 $::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 $::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 $::os_service_default
#
class nova::cache (
$config_prefix = $::os_service_default,
$expiration_time = $::os_service_default,
$backend = $::os_service_default,
$backend_argument = $::os_service_default,
$proxies = $::os_service_default,
$enabled = $::os_service_default,
$debug_cache_backend = $::os_service_default,
$memcache_servers = $::os_service_default,
$memcache_dead_retry = $::os_service_default,
$memcache_socket_timeout = $::os_service_default,
$memcache_pool_maxsize = $::os_service_default,
$memcache_pool_unused_timeout = $::os_service_default,
$memcache_pool_connection_get_timeout = $::os_service_default,
) {
include ::nova::deps
oslo::cache { 'nova_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,
memcache_pool_maxsize => $memcache_pool_maxsize,
memcache_pool_unused_timeout => $memcache_pool_unused_timeout,
memcache_pool_connection_get_timeout => $memcache_pool_connection_get_timeout,
}
}

View File

@ -0,0 +1,3 @@
---
features:
- Add ability to configure cache parameters

View File

@ -0,0 +1,81 @@
require 'spec_helper'
describe 'nova::cache' do
let :params do
{ }
end
shared_examples_for 'nova-cache' do
context 'with default parameters' do
it 'configures cache' do
is_expected.to contain_nova_config('cache/config_prefix').with_value('<SERVICE DEFAULT>')
is_expected.to contain_nova_config('cache/expiration_time').with_value('<SERVICE DEFAULT>')
is_expected.to contain_nova_config('cache/backend').with_value('<SERVICE DEFAULT>')
is_expected.to contain_nova_config('cache/backend_argument').with_value('<SERVICE DEFAULT>')
is_expected.to contain_nova_config('cache/proxies').with_value('<SERVICE DEFAULT>')
is_expected.to contain_nova_config('cache/enabled').with_value('<SERVICE DEFAULT>')
is_expected.to contain_nova_config('cache/debug_cache_backend').with_value('<SERVICE DEFAULT>')
is_expected.to contain_nova_config('cache/memcache_servers').with_value('<SERVICE DEFAULT>')
is_expected.to contain_nova_config('cache/memcache_dead_retry').with_value('<SERVICE DEFAULT>')
is_expected.to contain_nova_config('cache/memcache_socket_timeout').with_value('<SERVICE DEFAULT>')
is_expected.to contain_nova_config('cache/memcache_pool_maxsize').with_value('<SERVICE DEFAULT>')
is_expected.to contain_nova_config('cache/memcache_pool_unused_timeout').with_value('<SERVICE DEFAULT>')
is_expected.to contain_nova_config('cache/memcache_pool_connection_get_timeout').with_value('<SERVICE DEFAULT>')
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',
:memcache_pool_maxsize => '10',
:memcache_pool_unused_timeout => '120',
:memcache_pool_connection_get_timeout => '360',
}
end
it 'configures cache' do
is_expected.to contain_nova_config('cache/config_prefix').with_value('prefix')
is_expected.to contain_nova_config('cache/expiration_time').with_value('3600')
is_expected.to contain_nova_config('cache/backend').with_value('oslo_cache.memcache_pool')
is_expected.to contain_nova_config('cache/backend_argument').with_value('<SERVICE DEFAULT>')
is_expected.to contain_nova_config('cache/proxies').with_value('proxy01:8888,proxy02:8888')
is_expected.to contain_nova_config('cache/enabled').with_value('true')
is_expected.to contain_nova_config('cache/debug_cache_backend').with_value('false')
is_expected.to contain_nova_config('cache/memcache_servers').with_value('memcached01:11211,memcached02:11211')
is_expected.to contain_nova_config('cache/memcache_dead_retry').with_value('60')
is_expected.to contain_nova_config('cache/memcache_socket_timeout').with_value('300')
is_expected.to contain_nova_config('cache/memcache_pool_maxsize').with_value('10')
is_expected.to contain_nova_config('cache/memcache_pool_unused_timeout').with_value('120')
is_expected.to contain_nova_config('cache/memcache_pool_connection_get_timeout').with_value('360')
end
end
end
context 'on Debian platforms' do
let :facts do
@default_facts.merge({ :osfamily => 'Debian' })
end
it_configures 'nova-cache'
end
context 'on RedHat platforms' do
let :facts do
@default_facts.merge({ :osfamily => 'RedHat' })
end
it_configures 'nova-cache'
end
end