← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1977468] Re: Nova sanitize_hostname problematic with fqdn display_name

 

I agree that deducing hostname from display name is problematic.
Therefore I don't think we should further complicate the logic currently
in place. But instead move away from it. I suggest to provide the
hostname specifically with the hostname field in the POST /servers REST
API request. I suggest to reach out to the openstack-ansible[1]
developers and ask to expose this field via ansible.

If you are using FQDNs then please also read and provide feedback in the
currently discussed specification about FQDN handling[2].

I'm marking this as Invalid. Please put it back to New if you disagree.

[1] https://storyboard.openstack.org/#!/project/openstack/ansible-collections-openstack
[2] https://review.opendev.org/c/openstack/nova-specs/+/840974

** Changed in: nova
       Status: New => Invalid

-- 
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):
  Invalid

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



References