Make nova_metadata use source LB strategy

Generating the metadata for a VM that has been freshly booted
is a fairly expensive operation. Let's use a source balance option
in the nova_metadata haproxy stanza so that the requests from
the same compute node end up on the same controller, hence increasing
the locality of this operation.

Generated haproxy stanza looks like:
listen nova_metadata
  bind 172.17.1.150:8775 transparent ssl crt /etc/pki/tls/certs/haproxy/overcloud-haproxy-internal_api.pem
  mode http
  balance source
  hash-type consistent
  http-request set-header X-Forwarded-Proto https if { ssl_fc }
  http-request set-header X-Forwarded-Proto http if !{ ssl_fc }
  http-request set-header X-Forwarded-Port %[dst_port]
  option httpchk
  option httplog
  server controller-0.internalapi.foo.local 172.17.1.90:8775 ca-file /etc/ipa/ca.crt check fall 5 inter 2000 rise 2 ssl verify required verifyhost controller-0.internalapi.foo.local
  server controller-1.internalapi.foo.local 172.17.1.95:8775 ca-file /etc/ipa/ca.crt check fall 5 inter 2000 rise 2 ssl verify required verifyhost controller-1.internalapi.foo.local
  server controller-2.internalapi.foo.local 172.17.1.87:8775 ca-file /etc/ipa/ca.crt check fall 5 inter 2000 rise 2 ssl verify required verifyhost controller-2.internalapi.foo.local

We also add the consistent hash-type as it should improve the cache
behaviour when a controller disappears or gets added.

Change-Id: I4847ae10b03cf7b0571976097262bc8069c4e070
This commit is contained in:
Michele Baldessari 2020-10-21 15:25:13 +02:00
parent 23478b8128
commit 1dbd82a1a9
2 changed files with 7 additions and 2 deletions

View File

@ -1033,6 +1033,10 @@ class tripleo::haproxy (
mode => 'http',
service_network => $nova_metadata_network,
member_options => union($haproxy_member_options, $internal_tls_member_options),
listen_options => merge($default_listen_options, {
'balance' => 'source',
'hash-type' => 'consistent',
}),
}
}

View File

@ -210,17 +210,18 @@ describe 'tripleo::haproxy' do
end
end
describe "source-based sticky sessions w/o use of consistent hashing" do
describe "source-based sticky sessions" do
before :each do
params.merge!({
:etcd => true,
:ceph_grafana => true,
:ceph_dashboard => true,
:nova_novncproxy => true,
:nova_metadata => true,
})
end
%w(etcd ceph_grafana ceph_dashboard nova_novncproxy).each do |svc|
%w(etcd ceph_grafana ceph_dashboard nova_novncproxy nova_metadata).each do |svc|
it 'should configure haproxy ' + svc + ' endpoint' do
is_expected.to contain_haproxy__listen(svc)
p = catalogue.resource('tripleo::haproxy::endpoint', svc).send(:parameters)