Merge "Support configuring oslo.cache to cache metadata"
This commit is contained in:
commit
299e99ff6d
|
@ -0,0 +1,166 @@
|
|||
# Class ec2api::cache
|
||||
#
|
||||
# ec2api 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).
|
||||
# (floating point 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
|
||||
#
|
||||
# [*manage_backend_package*]
|
||||
# (Optional) (Optional) Whether to install the backend package for the cache.
|
||||
# Defaults to true
|
||||
#
|
||||
# [*tls_enabled*]
|
||||
# (Optional) Global toggle for TLS usage when comunicating with
|
||||
# the caching servers.
|
||||
# Default to $::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 $::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 $::os_service_default
|
||||
#
|
||||
# [*tls_keyfile*]
|
||||
# (Optional) Path to a single file containing the client's private
|
||||
# key in. Otherwhise the private key will be taken from the file
|
||||
# specified in tls_certfile. If tls_enabled is False, this option
|
||||
# is ignored.
|
||||
# Default to $::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 $::os_service_default
|
||||
#
|
||||
class ec2api::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,
|
||||
$manage_backend_package = true,
|
||||
$tls_enabled = $::os_service_default,
|
||||
$tls_cafile = $::os_service_default,
|
||||
$tls_certfile = $::os_service_default,
|
||||
$tls_keyfile = $::os_service_default,
|
||||
$tls_allowed_ciphers = $::os_service_default,
|
||||
) {
|
||||
|
||||
include ec2api::deps
|
||||
|
||||
oslo::cache { 'ec2api_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,
|
||||
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,
|
||||
}
|
||||
}
|
|
@ -29,6 +29,10 @@ class ec2api::deps {
|
|||
-> Ec2api_api_paste_ini<||>
|
||||
~> Anchor['ec2api::config::end']
|
||||
|
||||
# all cache settings should be applied and all packages should be installed
|
||||
# before service startup
|
||||
Oslo::Cache<||> -> Anchor['ec2api::service::begin']
|
||||
|
||||
# all db settings should be applied and all packages should be installed
|
||||
# before dbsync starts
|
||||
Oslo::Db<||> -> Anchor['ec2api::dbsync::begin']
|
||||
|
|
|
@ -38,6 +38,10 @@
|
|||
# Shared secret to sign instance-id request
|
||||
# Default: $::os_service_default
|
||||
#
|
||||
# [*cache_expiration*]
|
||||
# The time (in seconds) to cache metadata
|
||||
# Default: $::os_service_default
|
||||
#
|
||||
# ==== Service
|
||||
#
|
||||
# [*metadata_listen*]
|
||||
|
@ -81,6 +85,7 @@ class ec2api::metadata (
|
|||
$nova_client_cert = $::os_service_default,
|
||||
$nova_client_priv_key = $::os_service_default,
|
||||
$metadata_proxy_shared_secret = $::os_service_default,
|
||||
$cache_expiration = $::os_service_default,
|
||||
# Service
|
||||
$metadata_listen = $::os_service_default,
|
||||
$metadata_listen_port = $::os_service_default,
|
||||
|
@ -107,6 +112,7 @@ class ec2api::metadata (
|
|||
'metadata/nova_client_cert': value => $nova_client_cert;
|
||||
'metadata/nova_client_priv_key': value => $nova_client_priv_key;
|
||||
'metadata/metadata_proxy_shared_secret': value => $metadata_proxy_shared_secret, secret => true;
|
||||
'metadata/cache_expiration': value => $cache_expiration;
|
||||
'DEFAULT/metadata_listen': value => $metadata_listen;
|
||||
'DEFAULT/metadata_listen_port': value => $metadata_listen_port;
|
||||
'DEFAULT/metadata_use_ssl': value => $metadata_use_ssl;
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
features:
|
||||
- |
|
||||
Support for configuring metadata caching using ``oslo.cache`` library has
|
||||
been added.
|
|
@ -0,0 +1,95 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'ec2api::cache' do
|
||||
|
||||
let :params do
|
||||
{}
|
||||
end
|
||||
|
||||
shared_examples_for 'ec2api::cache' do
|
||||
|
||||
context 'with default parameters' do
|
||||
it 'configures cache' do
|
||||
is_expected.to contain_oslo__cache('ec2api_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>',
|
||||
:memcache_pool_maxsize => '<SERVICE DEFAULT>',
|
||||
:memcache_pool_unused_timeout => '<SERVICE DEFAULT>',
|
||||
:memcache_pool_connection_get_timeout => '<SERVICE DEFAULT>',
|
||||
:tls_enabled => '<SERVICE DEFAULT>',
|
||||
:tls_cafile => '<SERVICE DEFAULT>',
|
||||
:tls_certfile => '<SERVICE DEFAULT>',
|
||||
:tls_keyfile => '<SERVICE DEFAULT>',
|
||||
:tls_allowed_ciphers => '<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',
|
||||
:memcache_pool_maxsize => '10',
|
||||
:memcache_pool_unused_timeout => '120',
|
||||
:memcache_pool_connection_get_timeout => '360',
|
||||
:tls_enabled => false,
|
||||
:manage_backend_package => false,
|
||||
}
|
||||
end
|
||||
|
||||
it 'configures cache' do
|
||||
is_expected.to contain_oslo__cache('ec2api_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',
|
||||
:memcache_pool_maxsize => '10',
|
||||
:memcache_pool_unused_timeout => '120',
|
||||
:memcache_pool_connection_get_timeout => '360',
|
||||
:tls_enabled => false,
|
||||
:tls_cafile => '<SERVICE DEFAULT>',
|
||||
:tls_certfile => '<SERVICE DEFAULT>',
|
||||
:tls_keyfile => '<SERVICE DEFAULT>',
|
||||
:tls_allowed_ciphers => '<SERVICE DEFAULT>',
|
||||
: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 'ec2api::cache'
|
||||
end
|
||||
end
|
||||
|
||||
end
|
|
@ -16,6 +16,7 @@ describe 'ec2api::metadata', type: :class do
|
|||
metadata/auth_ca_cert
|
||||
metadata/nova_client_cert
|
||||
metadata/nova_client_priv_key
|
||||
metadata/cache_expiration
|
||||
DEFAULT/metadata_listen
|
||||
DEFAULT/metadata_listen_port
|
||||
DEFAULT/metadata_use_ssl
|
||||
|
|
Loading…
Reference in New Issue