From 455cf1ba649c392e2fe88f04af55adb63af3ec28 Mon Sep 17 00:00:00 2001 From: Grzegorz Grasza Date: Thu, 4 Nov 2021 10:57:54 +0100 Subject: [PATCH] Add socket keepalive options for the pymemcache backend This patch specifies a set of options required to setup the socket keepalive feature of pymemcache (dogpile.cache) cache backend. Original oslo.cache change: https://review.opendev.org/c/openstack/oslo.cache/+/803716 Depends-On: https://review.opendev.org/807851 Change-Id: I5d7822101da301a6910f4da54569315d5c62f0b7 --- manifests/init.pp | 46 +++++++++++++++---- ...dd_keepalive_options-3802510b6d4461e1.yaml | 4 ++ spec/classes/ceilometer_init_spec.rb | 44 +++++++++++------- 3 files changed, 70 insertions(+), 24 deletions(-) create mode 100644 releasenotes/notes/add_keepalive_options-3802510b6d4461e1.yaml diff --git a/manifests/init.pp b/manifests/init.pp index e437813d..fafdf3a4 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -138,6 +138,28 @@ # (Optional) A list of memcached server(s) to use for caching. (list value) # Defaults to $::os_service_default # +# [*cache_enable_socket_keepalive*] +# (Optional) Global toggle for the socket keepalive of dogpile's +# pymemcache backend +# Defaults to $::os_service_default +# +# [*cache_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 $::os_service_default +# +# [*cache_socket_keepalive_interval*] +# (Optional) The time (in seconds) between individual keepalive probes. +# Should be a positive integer most greater than zero. +# Defaults to $::os_service_default +# +# [*cache_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 $::os_service_default +# # [*cache_tls_enabled*] # (Optional) Global toggle for TLS usage when comunicating with # the caching servers. @@ -295,6 +317,10 @@ class ceilometer( $kombu_compression = $::os_service_default, $cache_backend = $::os_service_default, $memcache_servers = $::os_service_default, + $cache_enable_socket_keepalive = $::os_service_default, + $cache_socket_keepalive_idle = $::os_service_default, + $cache_socket_keepalive_interval = $::os_service_default, + $cache_socket_keepalive_count = $::os_service_default, $cache_tls_enabled = $::os_service_default, $cache_tls_cafile = $::os_service_default, $cache_tls_certfile = $::os_service_default, @@ -419,13 +445,17 @@ will be removed in a future release.') } oslo::cache { 'ceilometer_config': - backend => $cache_backend, - memcache_servers => $memcache_servers, - tls_enabled => $cache_tls_enabled, - tls_cafile => $cache_tls_cafile, - tls_certfile => $cache_tls_certfile, - tls_keyfile => $cache_tls_keyfile, - tls_allowed_ciphers => $cache_tls_allowed_ciphers, - manage_backend_package => $manage_backend_package, + backend => $cache_backend, + memcache_servers => $memcache_servers, + enable_socket_keepalive => $cache_enable_socket_keepalive, + socket_keepalive_idle => $cache_socket_keepalive_idle, + socket_keepalive_interval => $cache_socket_keepalive_interval, + socket_keepalive_count => $cache_socket_keepalive_count, + tls_enabled => $cache_tls_enabled, + tls_cafile => $cache_tls_cafile, + tls_certfile => $cache_tls_certfile, + tls_keyfile => $cache_tls_keyfile, + tls_allowed_ciphers => $cache_tls_allowed_ciphers, + manage_backend_package => $manage_backend_package, } } diff --git a/releasenotes/notes/add_keepalive_options-3802510b6d4461e1.yaml b/releasenotes/notes/add_keepalive_options-3802510b6d4461e1.yaml new file mode 100644 index 00000000..e03e57a9 --- /dev/null +++ b/releasenotes/notes/add_keepalive_options-3802510b6d4461e1.yaml @@ -0,0 +1,4 @@ +--- +features: + - | + Add socket keepalive options for the pymemcache (dogpile.cache) backend. diff --git a/spec/classes/ceilometer_init_spec.rb b/spec/classes/ceilometer_init_spec.rb index 611ce0f8..6b7e619d 100644 --- a/spec/classes/ceilometer_init_spec.rb +++ b/spec/classes/ceilometer_init_spec.rb @@ -125,14 +125,18 @@ describe 'ceilometer' do it 'configures cache backend' do is_expected.to contain_oslo__cache('ceilometer_config').with( - :backend => '', - :memcache_servers => '', - :tls_enabled => '', - :tls_cafile => '', - :tls_certfile => '', - :tls_keyfile => '', - :tls_allowed_ciphers => '', - :manage_backend_package => true, + :backend => '', + :memcache_servers => '', + :enable_socket_keepalive => '', + :socket_keepalive_idle => '', + :socket_keepalive_interval => '', + :socket_keepalive_count => '', + :tls_enabled => '', + :tls_cafile => '', + :tls_certfile => '', + :tls_keyfile => '', + :tls_allowed_ciphers => '', + :manage_backend_package => true, ) end @@ -164,19 +168,27 @@ describe 'ceilometer' do context 'with overridden cache parameter' do before { params.merge!( - :cache_backend => 'memcache', - :memcache_servers => 'host1:11211,host2:11211', - :cache_tls_enabled => true, - :manage_backend_package => false, + :cache_backend => 'memcache', + :memcache_servers => 'host1:11211,host2:11211', + :cache_enable_socket_keepalive => false, + :cache_socket_keepalive_idle => 1, + :cache_socket_keepalive_interval => 1, + :cache_socket_keepalive_count => 1, + :cache_tls_enabled => true, + :manage_backend_package => false, ) } it 'configures cache backend' do is_expected.to contain_oslo__cache('ceilometer_config').with( - :backend => 'memcache', - :memcache_servers => 'host1:11211,host2:11211', - :tls_enabled => true, - :manage_backend_package => false, + :backend => 'memcache', + :memcache_servers => 'host1:11211,host2:11211', + :enable_socket_keepalive => false, + :socket_keepalive_idle => 1, + :socket_keepalive_interval => 1, + :socket_keepalive_count => 1, + :tls_enabled => true, + :manage_backend_package => false, ) end end