Don't create nova instances with fqdn as their name

If dns integration is enabled, a db instance's 'hostname'
refers to the dns-determined fqdn of a database instance. It will
probably be something like whatever.trove.example.org

Passing that fqdn into nova gets us a VM whose hostname
is whatever.trove.example.org. Presumably that host is itself
in a domain, so we wind up with an fqdn on the VM of something like
whatever.trove.example.org.example.org. Seems wrong.

Furthermore, if this is running in a cloud that already has
automatic DNS integration (a standard neutron/designate thing)
then we wind up trying to create a record in the 'example.org'
domain with the record name of whatever.trove.example.org
which is likely to confuse designate along with human
users.

Story: 2008915
Task: 42506
Change-Id: I6d223f9d1a15a1ed0a0269730a544c321cf6595f
This commit is contained in:
Andrew Bogott 2021-05-12 19:41:27 -05:00 committed by Lingxian Kong
parent fa658e0901
commit ac8fd38e5e
2 changed files with 8 additions and 4 deletions

View File

@ -982,13 +982,12 @@ class FreshInstanceTasks(FreshInstance, NotifyMixin, ConfigurationMixin):
metadata = {'trove_project_id': self.tenant_id,
'trove_user_id': self.context.user,
'trove_instance_id': self.id}
name = self.hostname or self.name
bdmap_v2 = block_device_mapping_v2
config_drive = CONF.use_nova_server_config_drive
key_name = CONF.nova_keypair
server = self.nova_client.servers.create(
name, image_id, flavor_id, key_name=key_name, nics=nics,
self.name, image_id, flavor_id, key_name=key_name, nics=nics,
block_device_mapping_v2=bdmap_v2,
files=files, userdata=userdata,
availability_zone=availability_zone,

View File

@ -304,7 +304,12 @@ class FreshInstanceTasksTest(BaseFreshInstanceTasksTest):
@patch.object(taskmanager_models.FreshInstanceTasks, 'hostname',
new_callable=PropertyMock,
return_value='fake-hostname')
def test_servers_create_block_device_mapping_v2(self, mock_hostname):
@patch.object(taskmanager_models.FreshInstanceTasks, 'name',
new_callable=PropertyMock,
return_value='fake-name')
def test_servers_create_block_device_mapping_v2(self,
mock_hostname,
mock_name):
self.freshinstancetasks.prepare_userdata = Mock(return_value=None)
mock_nova_client = self.freshinstancetasks.nova_client = Mock()
mock_servers_create = mock_nova_client.servers.create
@ -314,7 +319,7 @@ class FreshInstanceTasksTest(BaseFreshInstanceTasksTest):
'trove_user_id': 'test_user',
'trove_instance_id': self.freshinstancetasks.id}
mock_servers_create.assert_called_with(
'fake-hostname', 'fake-image',
'fake-name', 'fake-image',
'fake-flavor', files={},
userdata=None,
block_device_mapping_v2=None,