Fix gate for enabling FQDN agent registration

If a new version of the charm is used to install a version of
OpenStack prior to Stein, do not enable the FQDN registration.

Change-Id: Ib86d6a48ee34c9efc42b4455ac669ef0cb8dc3bb
Closes-Bug: #1846781
This commit is contained in:
Frode Nordahl 2019-10-08 14:13:51 +02:00
parent 93babbca13
commit 2169de6fcd
No known key found for this signature in database
GPG Key ID: 6A5D59A3BA48373F
4 changed files with 24 additions and 8 deletions

View File

@ -786,7 +786,7 @@ class HostIPContext(context.OSContextGenerator):
# We do want to migrate to using FQDNs so we enable this for new
# installations.
db = kv()
if db.get('install_version', 0) >= 1910:
if db.get('nova-compute-charm-use-fqdn', False):
fqdn = socket.getfqdn(host_ip)
if '.' in fqdn:
# only populate the value if getfqdn() is able to find an

View File

@ -62,12 +62,14 @@ from charmhelpers.fetch import (
)
from charmhelpers.contrib.openstack.utils import (
CompareOpenStackReleases,
configure_installation_source,
openstack_upgrade_available,
is_unit_paused_set,
openstack_upgrade_available,
os_release,
pausable_restart_on_change as restart_on_change,
series_upgrade_prepare,
series_upgrade_complete,
series_upgrade_prepare,
)
from charmhelpers.contrib.storage.linux.ceph import (
@ -156,9 +158,13 @@ def install():
apt_update()
apt_install(determine_packages(), fatal=True)
db = kv()
db.set('install_version', 1910)
db.flush()
# Start migration to agent registration with FQDNs for newly installed
# units with OpenStack release Stein or newer.
release = os_release('nova-common')
if CompareOpenStackReleases(release) >= 'stein':
db = kv()
db.set('nova-compute-charm-use-fqdn', True)
db.flush()
@hooks.hook('config-changed')

View File

@ -607,7 +607,8 @@ class NovaComputeContextTests(CharmTestCase):
self.assertEqual({'host_ip': '172.24.0.79'}, host_ip())
self.get_relation_ip.assert_called_with('cloud-compute',
cidr_network=None)
self.kv.return_value = FakeUnitdata(install_version=1910)
self.kv.return_value = FakeUnitdata(
**{'nova-compute-charm-use-fqdn': True})
_getfqdn.return_value = 'some'
host_ip = context.HostIPContext()
self.assertEqual({'host_ip': '172.24.0.79'}, host_ip())

View File

@ -113,15 +113,24 @@ class NovaComputeRelationsTests(CharmTestCase):
self.get_relation_ip.return_value = '10.0.0.50'
self.is_container.return_value = False
def test_install_hook(self):
@patch.object(hooks, 'kv')
@patch.object(hooks, 'os_release')
def test_install_hook(self, _os_release, _kv):
repo = 'cloud:precise-grizzly'
self.test_config.set('openstack-origin', repo)
self.determine_packages.return_value = ['foo', 'bar']
_os_release.return_value = 'rocky'
hooks.install()
self.configure_installation_source.assert_called_with(repo)
self.assertTrue(self.apt_update.called)
self.apt_install.assert_called_with(['foo', 'bar'], fatal=True)
self.assertTrue(self.execd_preinstall.called)
_os_release.return_value = 'stein'
kv = MagicMock()
_kv.return_value = kv
hooks.install()
kv.set.assert_called_once_with('nova-compute-charm-use-fqdn', True)
kv.flush.assert_called_once_with()
@patch.object(hooks, 'ceph_changed')
@patch.object(hooks, 'neutron_plugin_joined')