Consistent ordering of ADDRESS_TYPES when traversing dict

charms_openstack.adapters.ADDRESS_TYPES is traversed when filling
in network split information for haproxy configuration file generation.
The ADDRESS_TYPES constant is built from the keys of a simple python
dictionary, which provides no guaranteed ordering. This causes the
charm to render slight variations of the haproxy.cfg file and the
haproxy service is restarted as a result.

This is fixed by simply sorting the keys to ensure consistent ordering.
The list is reverse sorted so that the iteration occurs in the order
of public -> internal -> admin.

Change-Id: I89b2ee42b5827d0fe5bbb2ff7051e1bb5bd08c63
Closes-Bug: #1800980
This commit is contained in:
Billy Olsen 2018-11-23 10:07:05 -07:00
parent 785cdb8d61
commit 7c54bc9597
1 changed files with 1 additions and 1 deletions

View File

@ -30,7 +30,7 @@ import charmhelpers.core.hookenv as hookenv
import charmhelpers.core.host as ch_host
import charms_openstack.ip as os_ip
ADDRESS_TYPES = os_ip.ADDRESS_MAP.keys()
ADDRESS_TYPES = sorted(os_ip.ADDRESS_MAP.keys(), reverse=True)
# handle declarative adapter properties using a decorator and simple functions