From 1dbd82a1a989fc89c7dd4fed6e2e05adf0c080b8 Mon Sep 17 00:00:00 2001 From: Michele Baldessari Date: Wed, 21 Oct 2020 15:25:13 +0200 Subject: [PATCH] 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 --- manifests/haproxy.pp | 4 ++++ spec/classes/tripleo_haproxy_spec.rb | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/manifests/haproxy.pp b/manifests/haproxy.pp index fd74b79c6..bff33a91f 100644 --- a/manifests/haproxy.pp +++ b/manifests/haproxy.pp @@ -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', + }), } } diff --git a/spec/classes/tripleo_haproxy_spec.rb b/spec/classes/tripleo_haproxy_spec.rb index d7519fa23..77f301f3e 100644 --- a/spec/classes/tripleo_haproxy_spec.rb +++ b/spec/classes/tripleo_haproxy_spec.rb @@ -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)