Skip to content

Don't smoosh hostname and domainname in API#20200

Merged
calavera merged 1 commit intomoby:masterfrom
thockin:14282-hostname-domainname-v2
Mar 18, 2016
Merged

Don't smoosh hostname and domainname in API#20200
calavera merged 1 commit intomoby:masterfrom
thockin:14282-hostname-domainname-v2

Conversation

@thockin
Copy link
Copy Markdown
Contributor

@thockin thockin commented Feb 10, 2016

Fixes #14282

I think this is a better solution than #20196. Rather than make the CLI split --hostname, let it happen at the backend. This preserve's the user's intentions all the way through. No API change needed. No behavioral change from the CLI. The results of docker inspect will be different for --hostname=foo.bar.com containers, but the user-visible behavior is the same. The only behavioral change is for API users that specify both hostname and domainname, in which case the container's hostname will just be the hostname field. Otherwise it behaves exactly the same.

Tests and docs are not updated yet, pending someone saying they don't hate this. And yes, it obviously has to go into libnetwork, not here. I'll do all that if folks say this is OK.

@GordonTheTurtle GordonTheTurtle added status/0-triage dco/no Automatically set by a bot when one of the commits lacks proper signature labels Feb 10, 2016
@thockin thockin changed the title Don't smoosh hostname and domainname in API WIP: Don't smoosh hostname and domainname in API Feb 10, 2016
@estesp
Copy link
Copy Markdown
Contributor

estesp commented Feb 10, 2016

Haven't had a chance to play with this, but it looks like a promising fix to the originally thorny problem of figuring out the intent vs. distro differences that brought up the original bug.

When you say docker inspect is changed, I assume you mean it will just show the entire FQDN as Hostname with a blank Domainname for the CLI usecase of --host=hostname.domainname, which would have been shown separately due to the splitting logic being at the "front-end" prior to this PR.

I think the only downside is that for non-API uses with a FQDN in --host, this PR doesn't fix the max length problem for the SetHostname syscall. I remember one of the difficulties when I worked on the original "fix" is that even though the Docker container config has the concept of a separate hostname/domainname, libcontainer does not, and the passthrough is the somewhat clunky env. variable HOSTNAME set into the process config buffer, which the execdriver then uses to set up the libcontainer variant of the container's config. However, at least this allows for proper use via the API and with the libnetwork changes, gives you a more appropriate setup for differentiating hostname and domainname, and more importantly fixes the hostname length max issue for that use case.

@thockin
Copy link
Copy Markdown
Contributor Author

thockin commented Feb 10, 2016

Yes, your assessment of the This doesn't fix the length issue

On Wed, Feb 10, 2016 at 11:51 AM, Phil Estes notifications@github.com
wrote:

Haven't had a chance to play with this, but it looks like a promising fix
to the originally thorny problem of figuring out the intent vs. distro
differences that brought up the original bug.

When you say docker inspect is changed, I assume you mean it will just
show the entire FQDN as Hostname with a blank Domainname for the CLI
usecase of --host=hostname.domainname, which would have been shown
separately due to the splitting logic being at the "front-end" prior to
this PR.

I think the only downside is that for non-API uses with a FQDN in --host,
this PR doesn't fix the max length problem for the SetHostname syscall. I
remember one of the difficulties when I worked on the original "fix" is
that even though the Docker container config has the concept of a separate
hostname/domainname, libcontainer does not
https://github.com/opencontainers/runc/blob/master/libcontainer/configs/config.go#L108-L109,
and the passthrough is the somewhat clunky env. variable HOSTNAME set
into the process config buffer, which the execdriver then uses
https://github.com/docker/docker/blob/master/daemon/execdriver/driver_unix.go#L140
to set up the libcontainer variant of the container's config. However, at
least this allows for proper use via the API and with the libnetwork
changes, gives you a more appropriate setup for differentiating hostname
and domainname, and more importantly fixes the h ostname length max issue
for that use case.


Reply to this email directly or view it on GitHub
#20200 (comment).

@thockin
Copy link
Copy Markdown
Contributor Author

thockin commented Feb 10, 2016 via email

@thaJeztah
Copy link
Copy Markdown
Member

@thockin can you sign-off your commit? 😇

@estesp
Copy link
Copy Markdown
Contributor

estesp commented Feb 11, 2016

Now that the initial overall WIP has been floated for discussion, I would suggest the libnetwork PR can be created for review as well, and those 2 file changes dropped from this PR. Don't know if @mavenugo or others want to weigh in here, or wait for a libnetwork PR. I personally think this is a reasonable fix for a long-standing issue around hostname vs. fqdn.

@mavenugo
Copy link
Copy Markdown
Contributor

thanks @thockin @estesp. yes, we will look into this mainly to make sure it doesn't introduce any serious regression.
ping @sanimej

@thockin
Copy link
Copy Markdown
Contributor Author

thockin commented Feb 11, 2016

Thanks.

I will prep a "real" patch against libnetwork and sign this and update docs
in the next couple days

On Thu, Feb 11, 2016 at 9:15 AM, Madhu Venugopal notifications@github.com
wrote:

thanks @thockin https://github.com/thockin @estesp
https://github.com/estesp. yes, we will look into this mainly to make
sure it doesn't introduce any serious regression.
ping @sanimej https://github.com/sanimej


Reply to this email directly or view it on GitHub
#20200 (comment).

@lowenna
Copy link
Copy Markdown
Member

lowenna commented Feb 12, 2016

Some missing CI jobs here. They need kicking off again. Signing the commit and force pushing should resolve that.

@sanimej
Copy link
Copy Markdown

sanimej commented Feb 12, 2016

@thockin The change looks ok for fixing the API. But in the current form it breaks the existing behavior for net host. I think we can retain the current behavior by not splitting the os.Hostname() into host and domain name in initializeNetworking

        if container.HostConfig.NetworkMode.IsHost() {
                container.Config.Hostname, err = os.Hostname()
                if err != nil {
                        return err
                }

                parts := strings.SplitN(container.Config.Hostname, ".", 2) 
                if len(parts) > 1 {
                        container.Config.Hostname = parts[0]
                        container.Config.Domainname = parts[1]
                }       

        }

@thockin
Copy link
Copy Markdown
Contributor Author

thockin commented Feb 13, 2016

@sanimej re --net-host : Do you think it is sufficient to set the hostname and not the domainname? Or should we actually get the domainname (exec hostname -d) and set the domainname field?

@GordonTheTurtle GordonTheTurtle removed the dco/no Automatically set by a bot when one of the commits lacks proper signature label Feb 13, 2016
@thockin
Copy link
Copy Markdown
Contributor Author

thockin commented Feb 13, 2016

Also - thoughts on what docs need to be updated?

@sanimej
Copy link
Copy Markdown

sanimej commented Feb 15, 2016

@thockin For --net=host mode its sufficient to set only the hostname. This will cover the case where hostname is an fqdn. When the hostname is not an fqdn, /etc/hosts should typically have the fqdn. Since the /etc/hosts file is copied in the --net=host mode container should get the right dnsdomainname.

@sanimej
Copy link
Copy Markdown

sanimej commented Feb 15, 2016

@thaJeztah Can you please help in identifying the docs that need to be updated for this change ? I don't see hostname & fqdn being specifically discussed in any of the docs. But probably we have to update the API documentation to clarify the behavior ?

@thaJeztah
Copy link
Copy Markdown
Member

@sanimej I'll have a look at the docs; from a design perspective, does this LGTY (the networking team?) if it does, we can move this forward to code review

@sanimej
Copy link
Copy Markdown

sanimej commented Feb 15, 2016

@thaJeztah Yes, This is a reasonable solution without adding any UI or API changes.

There is one expected change in docker inspect output though; as mentioned earlier by @estesp

When you say docker inspect is changed, I assume you mean it will just show the entire FQDN as Hostname with a blank Domainname for the CLI usecase of --host=hostname.domainname, which would have been shown separately due to the splitting logic being at the "front-end" prior to this PR.

@icecrime icecrime added the status/failing-ci Indicates that the PR in its current state fails the test suite label Feb 29, 2016
@thaJeztah
Copy link
Copy Markdown
Member

For the documentation, I think we need;

IIUC, the --hostname on the CLI will keep the same behavior?

@thockin
Copy link
Copy Markdown
Contributor Author

thockin commented Mar 11, 2016

Rebased and test fixed, I think

@thaJeztah
Copy link
Copy Markdown
Member

Thanks @thockin

@thaJeztah thaJeztah removed the status/failing-ci Indicates that the PR in its current state fails the test suite label Mar 11, 2016
@thaJeztah
Copy link
Copy Markdown
Member

oh cr*p, @thockin looks like it needs another rebase already 😢

This allows users to provide a FQDN as hostname or to use distinct hostname and
domainname parts.  Depends on moby/libnetwork#950

Signed-off-by: Tim Hockin <thockin@google.com>
@thockin
Copy link
Copy Markdown
Contributor Author

thockin commented Mar 15, 2016

rebased

On Tue, Mar 15, 2016 at 3:48 AM, Sebastiaan van Stijn <
notifications@github.com> wrote:

oh cr*p, @thockin https://github.com/thockin looks like it needs
another rebase already [image: 😢]


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub:
#20200 (comment)

@thaJeztah
Copy link
Copy Markdown
Member

ping @estesp @cpuguy83 PTAL

@estesp
Copy link
Copy Markdown
Contributor

estesp commented Mar 15, 2016

LGTM. Thanks @thockin

@thockin
Copy link
Copy Markdown
Contributor Author

thockin commented Mar 16, 2016

Anything I need to do regarding the failed windows tests?

@cpuguy83
Copy link
Copy Markdown
Member

Can we "fix" the inspect output for older clients?

@thockin
Copy link
Copy Markdown
Contributor Author

thockin commented Mar 16, 2016

@cpuguy83 I think I am out of my depth on that question.

@calavera
Copy link
Copy Markdown
Contributor

LGTM, let's move this forward to docs review.

@thaJeztah
Copy link
Copy Markdown
Member

thanks, LGTM - not sure if there's anything else to document 😄

@calavera calavera added this to the 1.11.0 milestone Mar 18, 2016
@calavera
Copy link
Copy Markdown
Contributor

Docs LGTM too.

calavera added a commit that referenced this pull request Mar 18, 2016
Don't smoosh hostname and domainname in API
@calavera calavera merged commit ae75435 into moby:master Mar 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants