canonical / cloud-init

Official upstream for the cloud-init: cloud instance initialization
https://cloud-init.io/
Other
2.88k stars 857 forks source link

fqdn does not accept terminal dot #3962

Closed ubuntu-server-builder closed 1 year ago

ubuntu-server-builder commented 1 year ago

This bug was originally filed in Launchpad as LP: #1966533

Launchpad details
affected_projects = []
assignee = None
assignee_name = None
date_closed = 2022-12-12T13:58:54.102048+00:00
date_created = 2022-03-26T01:17:58.811130+00:00
date_fix_committed = 2022-04-26T13:33:43.950254+00:00
date_fix_released = 2022-12-12T13:58:54.102048+00:00
id = 1966533
importance = medium
is_complete = True
lp_url = https://bugs.launchpad.net/cloud-init/+bug/1966533
milestone = None
owner = evancarroll
owner_name = Evan Carroll
private = False
status = fix_released
submitter = evancarroll
submitter_name = Evan Carroll
tags = ['bitesize']
duplicates = []

Launchpad user Evan Carroll(evancarroll) wrote on 2022-03-26T01:17:58.811130+00:00

A fully qualified domain is not

    foo.bar.com

But instead,

    foo.bar.com.

Otherwise the fqdn hit up the resolver and searches on the network for a matching host. So if the resolver is on network

    foobar.com.

And you query for foo.bar.com it'll look up a host by that name

    foo.bar.com.foobar.com.

To stop this you fully-qualify with a terminal dot. This creates a problem because hostname does not accept a terminal dot,

sudo hostname host-10-2-65-89.openstack.build. hostname: the specified hostname is invalid

And cloud-init blindly submits the input to hostname. Which is weird, because you have to supply an fqdn which actually can not currently be a fqdn. The desired fix for this would be to trim off the dot from the value supplied in fqdn, before providing it to hostname.

ubuntu-server-builder commented 1 year ago

Launchpad user Evan Carroll(evancarroll) wrote on 2022-03-26T01:18:21.717561+00:00

This is inspired on my question and self-research here,

https://devops.stackexchange.com/q/15678/18965

ubuntu-server-builder commented 1 year ago

Launchpad user James Falcon(falcojr) wrote on 2022-03-28T15:29:29.780441+00:00

Thanks for this bug report. Since hostname setting is implementation dependent, we should include a note in the docs that some tools don't accept the trailing dot.

ubuntu-server-builder commented 1 year ago

Launchpad user James Falcon(falcojr) wrote on 2022-04-26T13:33:38.597823+00:00

Doc was updated in https://github.com/canonical/cloud-init/pull/1365