yahoo-eng-team team mailing list archive
-
yahoo-eng-team team
-
Mailing list archive
-
Message #89033
[Bug 1977468] [NEW] Nova sanitize_hostname problematic with fqdn display_name
Public bug reported:
Current implementation of nova/utils.py in function sanitize_hostname
does a simple replace for dots in hostname.
This causes an issue with nova/compute/api.py where _populate_instance_names sets hostname from display_name. We have multiple cases where we want display name to reflect FQDN of the instance.
In this case server1.example.com becomes hostname server1-example-com. This tends to create a cascading array of problems, when the hostname is not the actual hostname, but variation of FQDN. Cloud-init does pick up the generated name and the issues can carry to /etc/hosts (depending on configuration).
It's desirable to have FQDN as display name, as there may be instances
that have the same hostname, but different domain listed in various
views that list instances.
Tools like Ansible's openstack.cloud.server.module do not have the
ability to specify display_name and hostname individually.
It would be preferable to have an option to select the way the name is
sanitized. Aka. cut down everything after first dot (possibly with more
logic to check for valid FQDN) or to have current way of just replacing
dots '.' with dashes '-'. I don't see either as specifically correct way
of doing things, trying to deduce a hostname from display name is an
opinionated thing.
I did a dirty fix for my specific problem by splitting the hostname from
first dot and picking up the first part as hostname:
--- /tmp/utils.py.orig 2022-06-02 22:02:48.152040276 +0300
+++ /tmp/utils.py 2022-06-02 22:22:00.319168645 +0300
@@ -365,6 +365,8 @@
# Remove characters outside the Unicode range U+0000-U+00FF
hostname = hostname.encode('latin-1', 'ignore').decode('latin-1')
+ if hostname.find('.') >= 0:
+ hostname = hostname.split('.')[0]
hostname = truncate_hostname(hostname)
hostname = re.sub(r'[ _\.]', '-', hostname)
hostname = re.sub(r'[^\w.-]+', '', hostname)
** Affects: nova
Importance: Undecided
Status: New
--
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to OpenStack Compute (nova).
https://bugs.launchpad.net/bugs/1977468
Title:
Nova sanitize_hostname problematic with fqdn display_name
Status in OpenStack Compute (nova):
New
Bug description:
Current implementation of nova/utils.py in function sanitize_hostname
does a simple replace for dots in hostname.
This causes an issue with nova/compute/api.py where _populate_instance_names sets hostname from display_name. We have multiple cases where we want display name to reflect FQDN of the instance.
In this case server1.example.com becomes hostname server1-example-com. This tends to create a cascading array of problems, when the hostname is not the actual hostname, but variation of FQDN. Cloud-init does pick up the generated name and the issues can carry to /etc/hosts (depending on configuration).
It's desirable to have FQDN as display name, as there may be instances
that have the same hostname, but different domain listed in various
views that list instances.
Tools like Ansible's openstack.cloud.server.module do not have the
ability to specify display_name and hostname individually.
It would be preferable to have an option to select the way the name is
sanitized. Aka. cut down everything after first dot (possibly with
more logic to check for valid FQDN) or to have current way of just
replacing dots '.' with dashes '-'. I don't see either as specifically
correct way of doing things, trying to deduce a hostname from display
name is an opinionated thing.
I did a dirty fix for my specific problem by splitting the hostname
from first dot and picking up the first part as hostname:
--- /tmp/utils.py.orig 2022-06-02 22:02:48.152040276 +0300
+++ /tmp/utils.py 2022-06-02 22:22:00.319168645 +0300
@@ -365,6 +365,8 @@
# Remove characters outside the Unicode range U+0000-U+00FF
hostname = hostname.encode('latin-1', 'ignore').decode('latin-1')
+ if hostname.find('.') >= 0:
+ hostname = hostname.split('.')[0]
hostname = truncate_hostname(hostname)
hostname = re.sub(r'[ _\.]', '-', hostname)
hostname = re.sub(r'[^\w.-]+', '', hostname)
To manage notifications about this bug go to:
https://bugs.launchpad.net/nova/+bug/1977468/+subscriptions
Follow ups