Comment 1 for bug 1657305

Revision history for this message
David Ames (thedac) wrote :

According to John Meinel:

'The charms should be updated to use "network-get <bindname> --preferred-address" instead of just "unit-get private-address". unit-get doesn't pass the information to Juju for us to know which bit of the configuration we're supposed to be reporting.'

In the OpenStack charms most of the time we use charmhelpers.contrib.openstack.ip resolve_address() which does the right thing checking network-get first.

However, we have some isolated instances where unit_get(private-address) is defaulted to. Which according to John can be unpredictable.

Specifically, calls to get_host_ip() functions that return the private-address by default in nova-compute and percona-cluster. Leading to unpredictable IPs in configuration files.

We need to also check other charms for this issue.

Nova compute HostIPContext returns the private-address:
class HostIPContext(context.OSContextGenerator):
    def __call__(self):
        ctxt = {}
        if config('prefer-ipv6'):
            host_ip = get_ipv6_addr()[0]
        else:
            host_ip = get_host_ip(unit_get('private-address'))

        if host_ip:
            # NOTE: do not format this even for ipv6 (see bug 1499656)
            ctxt['host_ip'] = host_ip

        return ctxt

percona-cluster in render_config returns the private-address:
    context = {
        'cluster_name': 'juju_cluster',
        'private_address': get_host_ip(),