Skip to content

Commit 13c09c6

Browse files
Jenkinsopenstack-gerrit
Jenkins
authored andcommitted
Merge "Implement nova::cache in stable/mitaka" into stable/mitaka
2 parents 3ec47ae + ec7dfea commit 13c09c6

File tree

3 files changed

+201
-0
lines changed

3 files changed

+201
-0
lines changed

manifests/cache.pp

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
# Class nova::cache
2+
#
3+
# nova cache configuration
4+
#
5+
# == parameters
6+
#
7+
# [*config_prefix*]
8+
# (Optional) Prefix for building the configuration dictionary for
9+
# the cache region. This should not need to be changed unless there
10+
# is another dogpile.cache region with the same configuration name.
11+
# (string value)
12+
# Defaults to $::os_service_default
13+
#
14+
# [*expiration_time*]
15+
# (Optional) Default TTL, in seconds, for any cached item in the
16+
# dogpile.cache region. This applies to any cached method that
17+
# doesn't have an explicit cache expiration time defined for it.
18+
# (integer value)
19+
# Defaults to $::os_service_default
20+
#
21+
# [*backend*]
22+
# (Optional) Dogpile.cache backend module. It is recommended that
23+
# Memcache with pooling (oslo_cache.memcache_pool) or Redis
24+
# (dogpile.cache.redis) be used in production deployments. (string value)
25+
# Defaults to $::os_service_default
26+
#
27+
# [*backend_argument*]
28+
# (Optional) Arguments supplied to the backend module. Specify this option
29+
# once per argument to be passed to the dogpile.cache backend.
30+
# Example format: "<argname>:<value>". (list value)
31+
# Defaults to $::os_service_default
32+
#
33+
# [*proxies*]
34+
# (Optional) Proxy classes to import that will affect the way the
35+
# dogpile.cache backend functions. See the dogpile.cache documentation on
36+
# changing-backend-behavior. (list value)
37+
# Defaults to $::os_service_default
38+
#
39+
# [*enabled*]
40+
# (Optional) Global toggle for caching. (boolean value)
41+
# Defaults to $::os_service_default
42+
#
43+
# [*debug_cache_backend*]
44+
# (Optional) Extra debugging from the cache backend (cache keys,
45+
# get/set/delete/etc calls). This is only really useful if you need
46+
# to see the specific cache-backend get/set/delete calls with the keys/values.
47+
# Typically this should be left set to false. (boolean value)
48+
# Defaults to $::os_service_default
49+
#
50+
# [*memcache_servers*]
51+
# (Optional) Memcache servers in the format of "host:port".
52+
# (dogpile.cache.memcache and oslo_cache.memcache_pool backends only).
53+
# (list value)
54+
# Defaults to $::os_service_default
55+
#
56+
# [*memcache_dead_retry*]
57+
# (Optional) Number of seconds memcached server is considered dead before
58+
# it is tried again. (dogpile.cache.memcache and oslo_cache.memcache_pool
59+
# backends only). (integer value)
60+
# Defaults to $::os_service_default
61+
#
62+
# [*memcache_socket_timeout*]
63+
# (Optional) Timeout in seconds for every call to a server.
64+
# (dogpile.cache.memcache and oslo_cache.memcache_pool backends only).
65+
# (integer value)
66+
# Defaults to $::os_service_default
67+
#
68+
# [*memcache_pool_maxsize*]
69+
# (Optional) Max total number of open connections to every memcached server.
70+
# (oslo_cache.memcache_pool backend only). (integer value)
71+
# Defaults to $::os_service_default
72+
#
73+
# [*memcache_pool_unused_timeout*]
74+
# (Optional) Number of seconds a connection to memcached is held unused
75+
# in the pool before it is closed. (oslo_cache.memcache_pool backend only)
76+
# (integer value)
77+
# Defaults to $::os_service_default
78+
#
79+
# [*memcache_pool_connection_get_timeout*]
80+
# (Optional) Number of seconds that an operation will wait to get a memcache
81+
# client connection. (integer value)
82+
# Defaults to $::os_service_default
83+
#
84+
class nova::cache (
85+
$config_prefix = $::os_service_default,
86+
$expiration_time = $::os_service_default,
87+
$backend = $::os_service_default,
88+
$backend_argument = $::os_service_default,
89+
$proxies = $::os_service_default,
90+
$enabled = $::os_service_default,
91+
$debug_cache_backend = $::os_service_default,
92+
$memcache_servers = $::os_service_default,
93+
$memcache_dead_retry = $::os_service_default,
94+
$memcache_socket_timeout = $::os_service_default,
95+
$memcache_pool_maxsize = $::os_service_default,
96+
$memcache_pool_unused_timeout = $::os_service_default,
97+
$memcache_pool_connection_get_timeout = $::os_service_default,
98+
) {
99+
100+
include ::nova::deps
101+
102+
nova_config {
103+
'cache/config_prefix': value => $config_prefix;
104+
'cache/expiration_time': value => $expiration_time;
105+
'cache/backend': value => $backend;
106+
'cache/backend_argument': value => join(any2array($backend_argument), ',');
107+
'cache/proxies': value => join(any2array($proxies), ',');
108+
'cache/enabled': value => $enabled;
109+
'cache/debug_cache_backend': value => $debug_cache_backend;
110+
'cache/memcache_servers': value => join(any2array($memcache_servers), ',');
111+
'cache/memcache_dead_retry': value => $memcache_dead_retry;
112+
'cache/memcache_socket_timeout': value => $memcache_socket_timeout;
113+
'cache/memcache_pool_maxsize': value => $memcache_pool_maxsize;
114+
'cache/memcache_pool_unused_timeout': value => $memcache_pool_unused_timeout;
115+
'cache/memcache_pool_connection_get_timeout': value => $memcache_pool_connection_get_timeout;
116+
}
117+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
features:
3+
- Add ability to configure cache parameters.
4+
This feature was implemented in puppet-nova during Newton but
5+
backported in Mitaka because Nova deprecated memcached_servers
6+
in Mitaka. The backport is not using puppet-oslo but the results
7+
are the same.

spec/classes/nova_cache_spec.rb

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
require 'spec_helper'
2+
3+
describe 'nova::cache' do
4+
5+
let :params do
6+
{ }
7+
end
8+
9+
shared_examples_for 'nova-cache' do
10+
11+
context 'with default parameters' do
12+
it 'configures cache' do
13+
is_expected.to contain_nova_config('cache/config_prefix').with_value('<SERVICE DEFAULT>')
14+
is_expected.to contain_nova_config('cache/expiration_time').with_value('<SERVICE DEFAULT>')
15+
is_expected.to contain_nova_config('cache/backend').with_value('<SERVICE DEFAULT>')
16+
is_expected.to contain_nova_config('cache/backend_argument').with_value('<SERVICE DEFAULT>')
17+
is_expected.to contain_nova_config('cache/proxies').with_value('<SERVICE DEFAULT>')
18+
is_expected.to contain_nova_config('cache/enabled').with_value('<SERVICE DEFAULT>')
19+
is_expected.to contain_nova_config('cache/debug_cache_backend').with_value('<SERVICE DEFAULT>')
20+
is_expected.to contain_nova_config('cache/memcache_servers').with_value('<SERVICE DEFAULT>')
21+
is_expected.to contain_nova_config('cache/memcache_dead_retry').with_value('<SERVICE DEFAULT>')
22+
is_expected.to contain_nova_config('cache/memcache_socket_timeout').with_value('<SERVICE DEFAULT>')
23+
is_expected.to contain_nova_config('cache/memcache_pool_maxsize').with_value('<SERVICE DEFAULT>')
24+
is_expected.to contain_nova_config('cache/memcache_pool_unused_timeout').with_value('<SERVICE DEFAULT>')
25+
is_expected.to contain_nova_config('cache/memcache_pool_connection_get_timeout').with_value('<SERVICE DEFAULT>')
26+
end
27+
end
28+
29+
context 'with overridden parameters' do
30+
let :params do
31+
{
32+
:config_prefix => 'prefix',
33+
:expiration_time => '3600',
34+
:backend => 'oslo_cache.memcache_pool',
35+
:proxies => ['proxy01:8888', 'proxy02:8888'],
36+
:enabled => true,
37+
:debug_cache_backend => false,
38+
:memcache_servers => ['memcached01:11211', 'memcached02:11211'],
39+
:memcache_dead_retry => '60',
40+
:memcache_socket_timeout => '300',
41+
:memcache_pool_maxsize => '10',
42+
:memcache_pool_unused_timeout => '120',
43+
:memcache_pool_connection_get_timeout => '360',
44+
}
45+
end
46+
47+
it 'configures cache' do
48+
is_expected.to contain_nova_config('cache/config_prefix').with_value('prefix')
49+
is_expected.to contain_nova_config('cache/expiration_time').with_value('3600')
50+
is_expected.to contain_nova_config('cache/backend').with_value('oslo_cache.memcache_pool')
51+
is_expected.to contain_nova_config('cache/backend_argument').with_value('<SERVICE DEFAULT>')
52+
is_expected.to contain_nova_config('cache/proxies').with_value('proxy01:8888,proxy02:8888')
53+
is_expected.to contain_nova_config('cache/enabled').with_value('true')
54+
is_expected.to contain_nova_config('cache/debug_cache_backend').with_value('false')
55+
is_expected.to contain_nova_config('cache/memcache_servers').with_value('memcached01:11211,memcached02:11211')
56+
is_expected.to contain_nova_config('cache/memcache_dead_retry').with_value('60')
57+
is_expected.to contain_nova_config('cache/memcache_socket_timeout').with_value('300')
58+
is_expected.to contain_nova_config('cache/memcache_pool_maxsize').with_value('10')
59+
is_expected.to contain_nova_config('cache/memcache_pool_unused_timeout').with_value('120')
60+
is_expected.to contain_nova_config('cache/memcache_pool_connection_get_timeout').with_value('360')
61+
end
62+
end
63+
end
64+
65+
on_supported_os({
66+
:supported_os => OSDefaults.get_supported_os
67+
}).each do |os,facts|
68+
context "on #{os}" do
69+
let (:facts) do
70+
facts.merge!(OSDefaults.get_facts())
71+
end
72+
73+
it_configures 'nova-cache'
74+
end
75+
end
76+
77+
end

0 commit comments

Comments
 (0)