Add line terminator to certificate list file

Commit c9e1551 changed file mode to binary from text. When on binary,
Python does not apply newlines so the resulting file has no line
terminator. This has not been an issue up to HAProxy version 1.8, but
testing on HAProxy 2.2.2 fails configuration check.

Workaround this HAProxy issue by adding a line terminator to the
certificate list file.

Task: 40593
Story: 2007974

Change-Id: Iedd22e75a9124a41b776305f2fcb0caaabd07d6a
This commit is contained in:
Carlos Goncalves 2020-08-03 17:18:22 +02:00
parent 6a762f8a07
commit 13fe928c8a

View File

@ -477,7 +477,8 @@ class HaproxyAmphoraLoadBalancerDriver(
if certs: if certs:
# Build and upload the crt-list file for haproxy # Build and upload the crt-list file for haproxy
crt_list = "\n".join(cert_filename_list).encode('utf-8') crt_list = "\n".join(cert_filename_list)
crt_list = f'{crt_list}\n'.encode('utf-8')
md5 = hashlib.md5(crt_list).hexdigest() # nosec md5 = hashlib.md5(crt_list).hexdigest() # nosec
name = '{id}.pem'.format(id=listener.id) name = '{id}.pem'.format(id=listener.id)
self._upload_cert(amphora, obj_id, crt_list, md5, name) self._upload_cert(amphora, obj_id, crt_list, md5, name)