Skip to content

Commit 7babb4f

Browse files
committed
add config for caching metadata in memory
* add config metadata_memory_cache_ttl to enable caching metadata in memory * set default to 5 as project neutron/master Change-Id: Ib6a05ae5033c53c4196f736373752370012d82a6
1 parent d65ffe0 commit 7babb4f

2 files changed

Lines changed: 33 additions & 14 deletions

File tree

manifests/agents/metadata.pp

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -60,24 +60,32 @@
6060
# (optional) Number of backlog requests to configure the metadata server socket with.
6161
# Defaults to 4096
6262
#
63+
# [*metadata_memory_cache_ttl*]
64+
# (optional) Specifies time in seconds a metadata cache entry is valid in
65+
# memory caching backend.
66+
# Set to 0 will cause cache entries to never expire.
67+
# Set to undef or false to disable cache.
68+
# Defaults to 5
69+
#
6370

6471
class neutron::agents::metadata (
6572
$auth_password,
6673
$shared_secret,
67-
$package_ensure = 'present',
68-
$enabled = true,
69-
$manage_service = true,
70-
$debug = false,
71-
$auth_tenant = 'services',
72-
$auth_user = 'neutron',
73-
$auth_url = 'http://localhost:35357/v2.0',
74-
$auth_insecure = false,
75-
$auth_ca_cert = undef,
76-
$auth_region = 'RegionOne',
77-
$metadata_ip = '127.0.0.1',
78-
$metadata_port = '8775',
79-
$metadata_workers = $::processorcount,
80-
$metadata_backlog = '4096'
74+
$package_ensure = 'present',
75+
$enabled = true,
76+
$manage_service = true,
77+
$debug = false,
78+
$auth_tenant = 'services',
79+
$auth_user = 'neutron',
80+
$auth_url = 'http://localhost:35357/v2.0',
81+
$auth_insecure = false,
82+
$auth_ca_cert = undef,
83+
$auth_region = 'RegionOne',
84+
$metadata_ip = '127.0.0.1',
85+
$metadata_port = '8775',
86+
$metadata_workers = $::processorcount,
87+
$metadata_backlog = '4096',
88+
$metadata_memory_cache_ttl = 5,
8189
) {
8290

8391
include neutron::params
@@ -101,6 +109,16 @@
101109
'DEFAULT/metadata_backlog': value => $metadata_backlog;
102110
}
103111

112+
if $metadata_memory_cache_ttl {
113+
neutron_metadata_agent_config {
114+
'DEFAULT/cache_url': value => "memory://?default_ttl=${metadata_memory_cache_ttl}";
115+
}
116+
} else {
117+
neutron_metadata_agent_config {
118+
'DEFAULT/cache_url': ensure => absent;
119+
}
120+
}
121+
104122
if $auth_ca_cert {
105123
neutron_metadata_agent_config {
106124
'DEFAULT/auth_ca_cert': value => $auth_ca_cert;

spec/classes/neutron_agents_metadata_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
should contain_neutron_metadata_agent_config('DEFAULT/metadata_workers').with(:value => facts[:processorcount])
6161
should contain_neutron_metadata_agent_config('DEFAULT/metadata_backlog').with(:value => params[:metadata_backlog])
6262
should contain_neutron_metadata_agent_config('DEFAULT/metadata_proxy_shared_secret').with(:value => params[:shared_secret])
63+
should contain_neutron_metadata_agent_config('DEFAULT/cache_url').with(:value => 'memory://?default_ttl=5')
6364
end
6465
end
6566

0 commit comments

Comments
 (0)