summaryrefslogtreecommitdiff
path: root/trove
diff options
context:
space:
mode:
authorAndrew Bogott <abogott@wikimedia.org>2021-05-12 19:41:27 -0500
committerLingxian Kong <anlin.kong@gmail.com>2021-05-31 22:34:34 +0000
commitac8fd38e5e3a16e00b5dc6aef4c6c1666989a3ba (patch)
treeb9dd1b4fa36ba730c8383689ad60f2d65e1c7e98 /trove
parentfa658e0901a633efcb145ea90029d3af9941e17c (diff)
downloadtrove-ac8fd38e5e3a16e00b5dc6aef4c6c1666989a3ba.tar.gz
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
Diffstat (limited to 'trove')
-rwxr-xr-xtrove/taskmanager/models.py3
-rw-r--r--trove/tests/unittests/taskmanager/test_models.py9
2 files changed, 8 insertions, 4 deletions
diff --git a/trove/taskmanager/models.py b/trove/taskmanager/models.py
index 4acb9203..aa93090d 100755
--- a/trove/taskmanager/models.py
+++ b/trove/taskmanager/models.py
@@ -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,
diff --git a/trove/tests/unittests/taskmanager/test_models.py b/trove/tests/unittests/taskmanager/test_models.py
index b81194a3..b5ea9814 100644
--- a/trove/tests/unittests/taskmanager/test_models.py
+++ b/trove/tests/unittests/taskmanager/test_models.py
@@ -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,