Filter out link-local ipv6 address in loadbalancer

On puppet 3, which uses facter 2, the $::ipaddress6 fact explicitly
filters out all link-local address[1]. On puppet 4, which uses facter 3,
the $::ipaddress6 fact only removes the link-local address if can find a
better one[2]. The beaker tests reveal that haproxy won't bind to the
ipv6 local address and will fail to start, with errors like:

  Starting proxy balance_git_daemon: cannot bind socket [fe80::5054:ff:fec5:7095:9418]

This matters in CI test cases where the test nodes don't have real ipv6
addresses.

This patch restores the puppet 3 behavior of ignoring the ipv6 address if
it's a link-local address.

[1] https://github.com/puppetlabs/facter/blob/2.x/lib/facter/ipaddress6.rb#L31
[2] https://docs.puppet.com/facter/3.1/release_notes.html#regression-fix-avoid-reporting-link-local-ipv6-addresses-if-a-valid-address-is-available

Change-Id: I481403a3a988211effd22c8524171379aea9ccf9
This commit is contained in:
Colleen Murphy 2018-06-18 22:28:43 +02:00
parent a44b818c21
commit 7fe0c1eaee
1 changed files with 11 additions and 1 deletions

View File

@ -81,8 +81,18 @@ class cgit::lb (
defaults_options => $defaults_options,
}
# NOTE(cmurphy) If the only available ipv6 address is a link-local address,
# facter won't filter it out:
# https://docs.puppet.com/facter/3.1/release_notes.html#regression-fix-avoid-reporting-link-local-ipv6-addresses-if-a-valid-address-is-available
# But we don't want haproxy to try to bind to a link local address, so filter
# it out
if $::ipaddress6 =~ /^fe[89a-f]/ {
$_ipaddress6 = undef
} else {
$_ipaddress6 = $::ipaddress6
}
# The three listen defines here are what the world will hit.
$haproxy_addresses = delete_undef_values([$::ipaddress, $::ipaddress6])
$haproxy_addresses = delete_undef_values([$::ipaddress, $_ipaddress6])
haproxy::listen { 'balance_git_http':
ipaddress => $haproxy_addresses,