Add etcd3gw api_version to cinder backend_url 

tooz etcd3gw driver makes use of api_version in backend_url from cinder.conf

api_version specifies the endpoint used for communication between etcd3gw and
Etcd service.

This patch ensures that the correct api_version is passed to tooz to
implement Etcd <-> etcd3gw compatibility as shown below.

  EtcdV3.4 (el9) supports /v3/
  EtcdV3.2 (el8) supports /v3aplha/

Depends-On: Ib30c1e003f261cd7e1ac6fed87167f9974bf8542
Closes-Bug: 1983668
Change-Id: I8f00c1b4299743e2ad21b25b6a1aeddca6edfd34
This commit is contained in:
katarimanoj 2022-08-09 13:52:43 +05:30
parent 13fe297288
commit ecda0e1421
2 changed files with 23 additions and 6 deletions

View File

@ -160,14 +160,22 @@ class tripleo::profile::base::cinder::volume (
if empty($etcd_host) {
fail('etcd_vip not set in hieradata')
}
case $::operatingsystemmajrelease {
# el8 uses etcd version 3.2, which supports v3alpha path
'8' : { $api_version = 'v3alpha' }
# el9 uses etcd version 3.4, which supports v3 path
default : { $api_version = 'v3' }
}
$options_init = "?api_version=${api_version}"
if $enable_internal_tls {
$protocol = 'https'
$tls_keyfile = $etcd_certificate_specs['service_key']
$tls_certfile = $etcd_certificate_specs['service_certificate']
$options = sprintf('?cert_key=%s&cert_cert=%s', $tls_keyfile, $tls_certfile)
$options_tls = sprintf('&cert_key=%s&cert_cert=%s', $tls_keyfile, $tls_certfile)
$options = "${options_init}${options_tls}"
} else {
$protocol = 'http'
$options = ''
$options = "${options_init}"
}
$backend_url = sprintf('etcd3+%s://%s:%s%s', $protocol, normalize_ip_for_uri($etcd_host), $etcd_port, $options)
class { 'cinder::coordination' :

View File

@ -467,7 +467,7 @@ describe 'tripleo::profile::base::cinder::volume' do
:cluster => 'tripleo-cluster',
)
is_expected.to contain_class('cinder::coordination').with(
:backend_url => 'etcd3+http://127.0.0.1:2379',
:backend_url => "etcd3+http://127.0.0.1:2379?api_version=#{platform_params[:api_version]}",
)
end
@ -483,7 +483,7 @@ describe 'tripleo::profile::base::cinder::volume' do
end
it 'should configure coordination backend_url with https' do
is_expected.to contain_class('cinder::coordination').with(
:backend_url => 'etcd3+https://127.0.0.1:2379?cert_key=/path/to/etcd.key&cert_cert=/path/to/etcd.cert',
:backend_url => "etcd3+https://127.0.0.1:2379?api_version=#{platform_params[:api_version]}&cert_key=/path/to/etcd.key&cert_cert=/path/to/etcd.cert",
)
end
end
@ -496,7 +496,7 @@ describe 'tripleo::profile::base::cinder::volume' do
end
it 'should normalize it in the URI' do
is_expected.to contain_class('cinder::coordination').with(
:backend_url => 'etcd3+http://[fe80::1ff:fe23:4567:890a]:2379',
:backend_url => "etcd3+http://[fe80::1ff:fe23:4567:890a]:2379?api_version=#{platform_params[:api_version]}",
)
end
end
@ -509,7 +509,7 @@ describe 'tripleo::profile::base::cinder::volume' do
end
it 'should craft a correct URI' do
is_expected.to contain_class('cinder::coordination').with(
:backend_url => 'etcd3+http://etcdhost.localdomain:2379',
:backend_url => "etcd3+http://etcdhost.localdomain:2379?api_version=#{platform_params[:api_version]}",
)
end
end
@ -536,7 +536,16 @@ describe 'tripleo::profile::base::cinder::volume' do
facts.merge(OSDefaults.get_facts({ :hostname => 'node.example.com' }))
end
let(:platform_params) do
if facts[:operatingsystemmajrelease] == '8'
{ :api_version => 'v3alpha' }
else
{ :api_version => 'v3' }
end
end
it_behaves_like 'tripleo::profile::base::cinder::volume'
end
end
end