Merge "Format [oslo_cache] memcache_server when IPv6 is used" into stable/victoria

This commit is contained in:
Zuul 2022-04-08 08:37:59 +00:00 committed by Gerrit Code Review
commit e3016859b2
6 changed files with 244 additions and 17 deletions

View File

@ -87,6 +87,14 @@
# (Optional) Memcached port to use. # (Optional) Memcached port to use.
# Defaults to hiera('memcached_port', 11211) # Defaults to hiera('memcached_port', 11211)
# #
# [*memcached_ipv6*]
# (Optional) Whether Memcached uses IPv6 network instead of IPv4 network.
# Defauls to hiera('memcached_ipv6', false)
#
# [*cache_backend*]
# (Optional) oslo.cache backend used for caching.
# Defaults to hiera('heat::cache::backend', false)
#
# DEPRECATED PARAMETERS # DEPRECATED PARAMETERS
# #
# [*memcached_ips*] # [*memcached_ips*]
@ -111,10 +119,12 @@ class tripleo::profile::base::heat (
$oslomsg_notify_use_ssl = hiera('oslo_messaging_notify_use_ssl', '0'), $oslomsg_notify_use_ssl = hiera('oslo_messaging_notify_use_ssl', '0'),
$memcached_hosts = hiera('memcached_node_names', []), $memcached_hosts = hiera('memcached_node_names', []),
$memcached_port = hiera('memcached_port', 11211), $memcached_port = hiera('memcached_port', 11211),
$memcached_ipv6 = hiera('memcached_ipv6', false),
$cache_backend = hiera('heat::cache::backend', false),
# DEPRECATED PARAMETERS # DEPRECATED PARAMETERS
$memcached_ips = undef $memcached_ips = undef
) { ) {
$memcached_hosts_real = pick($memcached_ips, $memcached_hosts) $memcached_hosts_real = any2array(pick($memcached_ips, $memcached_hosts))
include tripleo::profile::base::heat::authtoken include tripleo::profile::base::heat::authtoken
@ -152,14 +162,22 @@ class tripleo::profile::base::heat (
include heat::cors include heat::cors
include heat::logging include heat::logging
if is_ipv6_address($memcached_hosts_real[0]) { if $memcached_ipv6 or is_ipv6_address($memcached_hosts_real[0]) {
$memcache_servers = prefix(suffix(any2array(normalize_ip_for_uri($memcached_hosts_real)), ":${memcached_port}"), 'inet6:') if $cache_backend in ['oslo_cache.memcache_pool', 'dogpile.cache.memcached'] {
# NOTE(tkajinm): The inet6 prefix is required for backends using
# python-memcached
$cache_memcache_servers = $memcached_hosts_real.map |$server| { "inet6:[${server}]:${memcached_port}" }
} else { } else {
$memcache_servers = suffix(any2array(normalize_ip_for_uri($memcached_hosts_real)), ":${memcached_port}") # NOTE(tkajinam): The other backends like pymemcache don't require
# the inet6 prefix
$cache_memcache_servers = suffix(any2array(normalize_ip_for_uri($memcached_hosts_real)), ":${memcached_port}")
}
} else {
$cache_memcache_servers = suffix(any2array(normalize_ip_for_uri($memcached_hosts_real)), ":${memcached_port}")
} }
class { 'heat::cache': class { 'heat::cache':
memcache_servers => $memcache_servers memcache_servers => $cache_memcache_servers
} }
} }

View File

@ -162,6 +162,14 @@
# (Optional) Memcached port to use. # (Optional) Memcached port to use.
# Defaults to hiera('memcached_port', 11211) # Defaults to hiera('memcached_port', 11211)
# #
# [*memcached_ipv6*]
# (Optional) Whether Memcached uses IPv6 network instead of IPv4 network.
# Defauls to hiera('memcached_ipv6', false)
#
# [*cache_backend*]
# (Optional) oslo.cache backend used for caching.
# Defaults to hiera('keystone::cache::backend', false)
#
# DEPRECATED PARAMETERS # DEPRECATED PARAMETERS
# #
# [*memcached_ips*] # [*memcached_ips*]
@ -202,10 +210,12 @@ class tripleo::profile::base::keystone (
$keystone_openidc_enabled = hiera('keystone_openidc_enabled', false), $keystone_openidc_enabled = hiera('keystone_openidc_enabled', false),
$memcached_hosts = hiera('memcached_node_names', []), $memcached_hosts = hiera('memcached_node_names', []),
$memcached_port = hiera('memcached_port', 11211), $memcached_port = hiera('memcached_port', 11211),
$memcached_ipv6 = hiera('memcached_ipv6', false),
$cache_backend = hiera('keystone::cache::backend', false),
# DEPRECATED PARAMETERS # DEPRECATED PARAMETERS
$memcached_ips = undef $memcached_ips = undef
) { ) {
$memcached_hosts_real = pick($memcached_ips, $memcached_hosts) $memcached_hosts_real = any2array(pick($memcached_ips, $memcached_hosts))
if $bootstrap_node and $::hostname == downcase($bootstrap_node) { if $bootstrap_node and $::hostname == downcase($bootstrap_node) {
$sync_db = true $sync_db = true
@ -231,10 +241,23 @@ class tripleo::profile::base::keystone (
if $step >= 4 or ( $step >= 3 and $sync_db ) { if $step >= 4 or ( $step >= 3 and $sync_db ) {
$oslomsg_rpc_use_ssl_real = sprintf('%s', bool2num(str2bool($oslomsg_rpc_use_ssl))) $oslomsg_rpc_use_ssl_real = sprintf('%s', bool2num(str2bool($oslomsg_rpc_use_ssl)))
$oslomsg_notify_use_ssl_real = sprintf('%s', bool2num(str2bool($oslomsg_notify_use_ssl))) $oslomsg_notify_use_ssl_real = sprintf('%s', bool2num(str2bool($oslomsg_notify_use_ssl)))
$memcached_servers = suffix(any2array(normalize_ip_for_uri($memcached_hosts_real)), ":${memcached_port}")
if $memcached_ipv6 or is_ipv6_address($memcached_hosts_real[0]) {
if $cache_backend in ['oslo_cache.memcache_pool', 'dogpile.cache.memcached'] {
# NOTE(tkajinm): The inet6 prefix is required for backends using
# python-memcached
$cache_memcache_servers = $memcached_hosts_real.map |$server| { "inet6:[${server}]:${memcached_port}" }
} else {
# NOTE(tkajinam): The other backends like pymemcache don't require
# the inet6 prefix
$cache_memcache_servers = suffix(any2array(normalize_ip_for_uri($memcached_hosts_real)), ":${memcached_port}")
}
} else {
$cache_memcache_servers = suffix(any2array(normalize_ip_for_uri($memcached_hosts_real)), ":${memcached_port}")
}
class { 'keystone::cache': class { 'keystone::cache':
memcache_servers => $memcached_servers, memcache_servers => $cache_memcache_servers
} }
class { 'keystone': class { 'keystone':
@ -290,7 +313,7 @@ class tripleo::profile::base::keystone (
} }
if $keystone_openidc_enabled { if $keystone_openidc_enabled {
$memcached_servers = suffix(any2array(normalize_ip_for_uri($memcached_hosts_real)), ":${memcached_port}")
class { 'keystone::federation::openidc': class { 'keystone::federation::openidc':
memcached_servers => $memcached_servers, memcached_servers => $memcached_servers,
} }

View File

@ -82,6 +82,14 @@
# (Optional) Memcached port to use. # (Optional) Memcached port to use.
# Defaults to hiera('memcached_port', 11211) # Defaults to hiera('memcached_port', 11211)
# #
# [*memcached_ipv6*]
# (Optional) Whether Memcached uses IPv6 network instead of IPv4 network.
# Defauls to hiera('memcached_ipv6', false)
#
# [*cache_backend*]
# (Optional) oslo.cache backend used for caching.
# Defaults to hiera('nova::cache::backend', false)
#
# DEPRECATED PARAMETERS # DEPRECATED PARAMETERS
# #
# [*memcached_ips*] # [*memcached_ips*]
@ -105,10 +113,12 @@ class tripleo::profile::base::nova (
$step = Integer(hiera('step')), $step = Integer(hiera('step')),
$memcached_hosts = hiera('memcached_node_names', []), $memcached_hosts = hiera('memcached_node_names', []),
$memcached_port = hiera('memcached_port', 11211), $memcached_port = hiera('memcached_port', 11211),
$memcached_ipv6 = hiera('memcached_ipv6', false),
$cache_backend = hiera('nova::cache::backend', false),
# DEPRECATED PARAMETERS # DEPRECATED PARAMETERS
$memcached_ips = undef $memcached_ips = undef
) { ) {
$memcached_hosts_real = pick($memcached_ips, $memcached_hosts) $memcached_hosts_real = any2array(pick($memcached_ips, $memcached_hosts))
if $bootstrap_node and $::hostname == downcase($bootstrap_node) { if $bootstrap_node and $::hostname == downcase($bootstrap_node) {
$sync_db = true $sync_db = true
@ -116,12 +126,6 @@ class tripleo::profile::base::nova (
$sync_db = false $sync_db = false
} }
if is_ipv6_address($memcached_hosts_real[0]) {
$memcache_servers = prefix(suffix(any2array(normalize_ip_for_uri($memcached_hosts_real)), ":${memcached_port}"), 'inet6:')
} else {
$memcache_servers = suffix(any2array(normalize_ip_for_uri($memcached_hosts_real)), ":${memcached_port}")
}
if $step >= 4 or ($step >= 3 and $sync_db) { if $step >= 4 or ($step >= 3 and $sync_db) {
$oslomsg_rpc_use_ssl_real = sprintf('%s', bool2num(str2bool($oslomsg_rpc_use_ssl))) $oslomsg_rpc_use_ssl_real = sprintf('%s', bool2num(str2bool($oslomsg_rpc_use_ssl)))
$oslomsg_notify_use_ssl_real = sprintf('%s', bool2num(str2bool($oslomsg_notify_use_ssl))) $oslomsg_notify_use_ssl_real = sprintf('%s', bool2num(str2bool($oslomsg_notify_use_ssl)))
@ -130,10 +134,25 @@ class tripleo::profile::base::nova (
} else { } else {
$oslomsg_rpc_hosts_real = $oslomsg_rpc_hosts $oslomsg_rpc_hosts_real = $oslomsg_rpc_hosts
} }
if $memcached_ipv6 or is_ipv6_address($memcached_hosts_real[0]) {
if $cache_backend in ['oslo_cache.memcache_pool', 'dogpile.cache.memcached'] {
# NOTE(tkajinm): The inet6 prefix is required for backends using
# python-memcached
$cache_memcache_servers = $memcached_hosts_real.map |$server| { "inet6:[${server}]:${memcached_port}" }
} else {
# NOTE(tkajinam): The other backends like pymemcache don't require
# the inet6 prefix
$cache_memcache_servers = suffix(any2array(normalize_ip_for_uri($memcached_hosts_real)), ":${memcached_port}")
}
} else {
$cache_memcache_servers = suffix(any2array(normalize_ip_for_uri($memcached_hosts_real)), ":${memcached_port}")
}
include nova::config include nova::config
include nova::logging include nova::logging
class { 'nova::cache': class { 'nova::cache':
memcache_servers => $memcache_servers, memcache_servers => $cache_memcache_servers
} }
class { 'nova': class { 'nova':
default_transport_url => os_transport_url({ default_transport_url => os_transport_url({

View File

@ -152,6 +152,62 @@ eos
is_expected.to_not contain_class('heat::cron::purge_deleted') is_expected.to_not contain_class('heat::cron::purge_deleted')
end end
end end
context 'with step 4 and memcache ipv6' do
let(:params) { {
:step => 4,
:memcached_hosts => '::1',
} }
it 'should format the memcache_server parameter' do
is_expected.to contain_class('heat::cache').with(
:memcache_servers => ['[::1]:11211']
)
end
end
context 'with step 4, memcache ipv6 and memcached backend' do
let(:params) { {
:step => 4,
:memcached_hosts => '::1',
:cache_backend => 'dogpile.cache.memcached',
} }
it 'should format the memcache_server parameter' do
is_expected.to contain_class('heat::cache').with(
:memcache_servers => ['inet6:[::1]:11211']
)
end
end
context 'with step 4 and the ipv6 parameter' do
let(:params) { {
:step => 4,
:memcached_hosts => 'node.example.com',
:memcached_ipv6 => true,
} }
it 'should format the memcache_server parameter' do
is_expected.to contain_class('heat::cache').with(
:memcache_servers => ['node.example.com:11211']
)
end
end
context 'with step 4, the ipv6 parameter and memcached backend' do
let(:params) { {
:step => 4,
:memcached_hosts => 'node.example.com',
:memcached_ipv6 => true,
:cache_backend => 'dogpile.cache.memcached',
} }
it 'should format the memcache_server parameter' do
is_expected.to contain_class('heat::cache').with(
:memcache_servers => ['inet6:[node.example.com]:11211']
)
end
end
end end
on_supported_os.each do |os, facts| on_supported_os.each do |os, facts|

View File

@ -187,6 +187,62 @@ describe 'tripleo::profile::base::keystone' do
is_expected.to contain_class('keystone::cron::trust_flush') is_expected.to contain_class('keystone::cron::trust_flush')
end end
end end
context 'with step 4 and memcache ipv6' do
let(:params) { {
:step => 4,
:memcached_hosts => '::1',
} }
it 'should format the memcache_server parameter' do
is_expected.to contain_class('keystone::cache').with(
:memcache_servers => ['[::1]:11211']
)
end
end
context 'with step 4, memcache ipv6 and memcached backend' do
let(:params) { {
:step => 4,
:memcached_hosts => '::1',
:cache_backend => 'dogpile.cache.memcached',
} }
it 'should format the memcache_server parameter' do
is_expected.to contain_class('keystone::cache').with(
:memcache_servers => ['inet6:[::1]:11211']
)
end
end
context 'with step 4 and the ipv6 parameter' do
let(:params) { {
:step => 4,
:memcached_hosts => 'node.example.com',
:memcached_ipv6 => true,
} }
it 'should format the memcache_server parameter' do
is_expected.to contain_class('keystone::cache').with(
:memcache_servers => ['node.example.com:11211']
)
end
end
context 'with step 4, the ipv6 parameter and memcached backend' do
let(:params) { {
:step => 4,
:memcached_hosts => 'node.example.com',
:memcached_ipv6 => true,
:cache_backend => 'dogpile.cache.memcached',
} }
it 'should format the memcache_server parameter' do
is_expected.to contain_class('keystone::cache').with(
:memcache_servers => ['inet6:[node.example.com]:11211']
)
end
end
end end
on_supported_os.each do |os, facts| on_supported_os.each do |os, facts|

View File

@ -107,6 +107,61 @@ describe 'tripleo::profile::base::nova' do
} }
end end
context 'with step 4 and memcache ipv6' do
let(:params) { {
:step => 4,
:memcached_hosts => '::1',
} }
it 'should format the memcache_server parameter' do
is_expected.to contain_class('nova::cache').with(
:memcache_servers => ['[::1]:11211']
)
end
end
context 'with step 4, memcache ipv6 and memcached backend' do
let(:params) { {
:step => 4,
:memcached_hosts => '::1',
:cache_backend => 'dogpile.cache.memcached',
} }
it 'should format the memcache_server parameter' do
is_expected.to contain_class('nova::cache').with(
:memcache_servers => ['inet6:[::1]:11211']
)
end
end
context 'with step 4 and the ipv6 parameter' do
let(:params) { {
:step => 4,
:memcached_hosts => 'node.example.com',
:memcached_ipv6 => true,
} }
it 'should format the memcache_server parameter' do
is_expected.to contain_class('nova::cache').with(
:memcache_servers => ['node.example.com:11211']
)
end
end
context 'with step 4, the ipv6 parameter and memcached backend' do
let(:params) { {
:step => 4,
:memcached_hosts => 'node.example.com',
:memcached_ipv6 => true,
:cache_backend => 'dogpile.cache.memcached',
} }
it 'should format the memcache_server parameter' do
is_expected.to contain_class('nova::cache').with(
:memcache_servers => ['inet6:[node.example.com]:11211']
)
end
end
end end