Renaming instance brokes DNS integration

Bug #1861401 reported by Volodymyr Litovka
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Opinion
Low
Unassigned
neutron
Invalid
Undecided
Unassigned

Bug Description

Colleagues,

Description
===========
Renaming instance (e.g. using "openstack server set --name") brokes DNS integration, since it makes it impossible to bind port with new instance's name. So, if user renamed instance and want to access it using name, he can not.

Steps to reproduce
==================
1) You have an instance with some name (e.g. "web01")

2) You rename it using "openstack server set --name web02 web01"

3) You create port with instance's new name (e.g. web02) in order to attach it to the instance
$ openstack port create --network e-net --fixed-ip subnet=e-subnet --dns-name web02 test_port

4) You're trying to attach the port to the instance:
$ nova interface-attach --port-id <uuid> web02

Expected result
===============
Port binds to the instance and instance can be accessed using hostname "web02"

Actual result
=============
Last command in steps above fails with the following message:

ERROR (ClientException): Unexpected API Error. Please report this at http://bugs.launchpad.net/nova/ and attach the Nova API log if possible.

Nova log says the following:

2020-01-30 11:43:32.652 17476 ERROR nova.api.openstack.wsgi PortNotUsableDNS: Port 0425701f-d958-4c81-931a-9594fba7d7d2 not usable for instance 2d49b781-cef5-4cdd-a310-e74eb98aa514. Value web02 assigned to dns_name attribute does not match instance's hostname web01

MySQL content show that renaming instance changed column "display_name", but "hostname" remained with old name:

mysql> select hostname, display_name from instances where uuid='2d49b781-cef5-4cdd-a310-e74eb98aa514';
+----------+--------------+
| hostname | display_name |
+----------+--------------+
| web01 | web02 |
+----------+--------------+

Thus, DNS integration compares port's dns_name to "hostname" not the "display_name", which makes it unusable after renaming instance. Either renaming instance need to change both "hostname" and "display_name" columns or DNS integration need compare port's dns_name with "display_name".

Environment
===========
Host OS: Ubuntu 18.04 LTS
Openstack: Rocky
$ dpkg -l |grep nova
ii nova-api 2:18.2.3-0ubuntu1~cloud0
ii nova-common 2:18.2.3-0ubuntu1~cloud0
ii nova-conductor 2:18.2.3-0ubuntu1~cloud0
ii nova-novncproxy 2:18.2.3-0ubuntu1~cloud0
ii nova-placement-api 2:18.2.3-0ubuntu1~cloud0
ii nova-scheduler 2:18.2.3-0ubuntu1~cloud0
ii python-nova 2:18.2.3-0ubuntu1~cloud0
ii python-novaclient 2:11.0.0-0ubuntu1~cloud0

Thank you.

Tags: dns
Revision history for this message
Volodymyr Litovka (doka.ua) wrote :

Colleagues,

FYI

changing single line in (for Rocky) nova/network/neutronv2/api.py:

--- nova/network/neutronv2/api.py.orig 2020-02-04 08:32:33.305779575 +0000
+++ nova/network/neutronv2/api.py 2020-02-04 08:32:50.445688233 +0000
@@ -728,7 +728,7 @@
                     # dns_name attribute, it is equal to the instance's
                     # hostname
                     if port.get('dns_name'):
- if port['dns_name'] != instance.hostname:
+ if port['dns_name'] != instance.display_name:
                             raise exception.PortNotUsableDNS(
                                 port_id=request.port_id,
                                 instance=instance.uuid, value=port['dns_name'],

did the job. Same piece of code is present in current master at nova/network/neutron.py

I can submit the patch, but just don't know whether this approach will/will not break something else. It seems, no; but if anybody can clarify, it will be great.

Thank you.

Revision history for this message
Sylvain Bauza (sylvain-bauza) wrote :

Moving this bug to Neutron so they could triage it.
FWIW, Nova has a difference between display_name and hostname BECAUSE we don't want to change the server's hostname when created since people can just recreate another instance with another name if they really will, so instead of modifying an immutable field, we prefer to have display_name.

Changed in nova:
status: New → Opinion
importance: Undecided → Low
Revision history for this message
Slawek Kaplonski (slaweq) wrote :

Based on Sylvain's comment there my understanding is that there is no bug here. As hostname of VM wasn't changed so Neutron didn't allow to attach to the VM port with mismatched dns name. But I'm not dns intergation expert so I will ask someone who knows this part of code more to take a look too.

tags: added: dns
Revision history for this message
Dr. Jens Harbott (j-harbott) wrote :

DNS is expected to match the hostname of an instance, which according to nova above is immutable. If you want an instance with a different hostname, you need to create a new one.

Changed in neutron:
status: New → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.