Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hostname is required for new UTS namespace #285

Closed
wants to merge 1 commit into from

Conversation

laijs
Copy link
Contributor

@laijs laijs commented Dec 29, 2015

Signed-off-by: Lai Jiangshan jiangshanlai@gmail.com

Signed-off-by: Lai Jiangshan <jiangshanlai@gmail.com>
@wking
Copy link
Contributor

wking commented Dec 29, 2015

On Mon, Dec 28, 2015 at 07:46:37PM -0800, Lai Jiangshan wrote:

  • hostname is required for new UTS namespace

I'm -1 to this. “Only create a new UTS namespace if you're setting an
explicit hostname” sounds like a reasonable policy, but I doubt it's
the only reasonable policy. Maybe you're only creating a UTS
namespace to change the domain name. Or maybe you have another tool
that will be setting the hostname. So I'd rather keep this spec
policy-agnostic.

@laijs
Copy link
Contributor Author

laijs commented Dec 29, 2015

What's the hostname for a new UTS namespace?
For every config item, you have only two choices.

  • optional, the spec should define the DEFAULT value, in most cases the default value is the value of the corresponding config item of the host or some constant value.
  • required, OK, let the user set it.

It is hard for me to find a good default value for the hostname for a new UTS namespace, so I choose to mark it required. Any suggestion for the default value?

@wking
Copy link
Contributor

wking commented Dec 29, 2015

On Mon, Dec 28, 2015 at 09:14:59PM -0800, Lai Jiangshan wrote:

What's the hostname for a new UTS namespace?

It defaults to the namespace in the host UTS namespace. For example,
say I start in UTS namespace 1 where the hostname is ‘alice’:

$ hostname
alice

On creating a new UTS namespace 2 inside namespace 1, the hostname is
still ‘alice’:

$ unshare -Uur busybox sh

hostname

alice

But we can set it to ‘bob’.

hostname bob

On creating a new UTS namespace 3 inside namespace 2, the hostname is
still ‘bob’:

unshare -u hostname

bob

For every config item, you have only two choices.

  • optional, the spec should define the DEFAULT value, in most cases
    the default value is the value of the host or some constant value.
  • required, OK, let the user set.

The third option (which I like best) is:

  • optional, the runtime should not try and set this if the user
    doesn't specify a config value.

This lets the underlying platform default (e.g. what the Linux kernel
does) pass through without the runtime getting in the way.

@laijs
Copy link
Contributor Author

laijs commented Dec 29, 2015

  • optional, the runtime should not try and set this if the user
    doesn't specify a config value.

it is the choice one, it is the DEFAULT value/ or default behavior. should the spec claim this default value?

@wking
Copy link
Contributor

wking commented Dec 29, 2015

On Tue, Dec 29, 2015 at 12:36:21AM -0800, Lai Jiangshan wrote:

  • optional, the runtime should not try and set this if the user
    doesn't specify a config value.

it is the choice one, it is the DEFAULT value. should the spec claim
this default value?

Sure, although I think this is general enough that we don't need to
declare it for every setting. How about patching the top of config.md
to add:

If an optional setting is unset, the runtime MUST NOT make any
system calls to apply a default value unless explicitly required to
do so by this specification.

It would probably fit in best right after the current:

The configuration file contains metadata necessary to implement
standard operations against the container. This includes the
process to run, environment variables to inject, sandboxing features
to use, etc.

For example, on Solaris the default hostname is the container ID [1,2]
while on Linux it's the host UTS namespace's hostname. So we don't
want to get into the business of defining what the platform's default
is or requiring consistency between different platforms (folks who
need consistency can set a value for ‘hostname’, etc.).

[2]: freenode's #opencontainers on 2015-12-07

@mrunalp
Copy link
Contributor

mrunalp commented Jan 4, 2016

I don't think that this wording is required as someone may want to continue using the hostname from the host that was assigned by default to the container.

@wking
Copy link
Contributor

wking commented Jan 4, 2016

On Mon, Jan 04, 2016 at 03:43:34PM -0800, Mrunal Patel wrote:

I don't think that this wording is required as someone may want to
continue using the hostname from the host that was assigned by
default to the container.

+1. Although I don't see any requirements in the current spec that
the runtime leave the kernel-assigned default hostname alone, which is
why I think we want wording like 1.

@crosbymichael
Copy link
Member

There are no requirements for settings this if you have a UTS namespace in the kernel therefore we should be impose this restriction in the spec.

@wking wking mentioned this pull request Jan 13, 2016
wking added a commit to wking/opencontainer-runtime-spec that referenced this pull request Jan 27, 2016
With mknod entries in linux.devices and cgroups entries in
linux.resources.devices.  Background discussion in [1].

For specifying device cgroups independent of device creation.  This
makes it easy to distinguish between configs that call for cgroup
adjustments (which have linux.resources entries) from those that
don't.  Without this split, folks interested in making that
distinction would have to parse the device section to determine if it
included cgroup changes.  This will also make it easy to drop either
portion (mknod [2] or cgroups [3]) independently of the other if the
project decides to do so.

Using seperate sections for mknod and cgroups also allows us to avoid
the complicated validation rules needed for the combined format
mknod/cgroup [4].

Now that there is a section specific to supplying devices, I shifted
the default device listing over from config-linux [5].  The /dev/ptmx
entry is a bit awkward, since it's not a device, but it seemed to fit
better over here.  But I would also be fine leaving it with the other
mounts in config-linux.

fileMode, uid, and gid are optional, because mknod(2) doesn't need
them and specifies the handling when they aren't set [6,7].
Similarly, major/minor numbers are only required for S_IFCHR and
S_IFBLK [6].  I've left off wording about required runtime behavior
for unset values, because I'd rather address that with a blanket rule
[8].

For the cgroup, access is optional because the kernel docs show an
example that doesn't write an access field to the devices.deny file
[9].  The current kernel docs don't go into much detail on this
behavior (I expect unset and 'rwm' are equivalent), but if the kernel
doesn't need a value written, the spec should get out of the way and
allow users to not specify a value.

The reference links are sorted into two blocks, with kernel-doc links
sorted alphabetically followed by man pages sorted alphabetically by
section.  The cgroup link is new since 2016-01-13 [10].

[1]: https://groups.google.com/a/opencontainers.org/forum/#!topic/dev/y_Fsa2_jJaM
     Subject: Separate config entries for device mknod and cgroups?
     Date: Mon, 5 Oct 2015 12:46:55 -0700
     Message-ID: <20151005194655.GN28418@odin.tremily.us>
[2]: opencontainers#98
[3]: https://groups.google.com/a/opencontainers.org/forum/#!topic/dev/qWHoKs8Fsrk
     Subject: removal of cgroups from the OCI Linux spec
     Date: Wed, 28 Oct 2015 17:01:59 +0000
     Message-ID: <CAD2oYtO1RMCcUp52w-xXemzDTs+J6t4hS5Mm4mX+uBnVONGDfA@mail.gmail.com>
[4]: opencontainers#101
[5]: opencontainers#171 (comment)
[6]: http://man7.org/linux/man-pages/man2/mknod.2.html#DESCRIPTION
[7]: https://github.com/opencontainers/specs/pull/298/files#r51053835
[8]: opencontainers#285 (comment)
[9]: https://kernel.org/doc/Documentation/cgroup-v1/devices.txt
[10]: https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=34a9304a96d6351c2d35dcdc9293258378fc0bd8

Signed-off-by: W. Trevor King <wking@tremily.us>
Mashimiao pushed a commit to Mashimiao/specs that referenced this pull request Aug 19, 2016
With mknod entries in linux.devices and cgroups entries in
linux.resources.devices.  Background discussion in [1].

For specifying device cgroups independent of device creation.  This
makes it easy to distinguish between configs that call for cgroup
adjustments (which have linux.resources entries) from those that
don't.  Without this split, folks interested in making that
distinction would have to parse the device section to determine if it
included cgroup changes.  This will also make it easy to drop either
portion (mknod [2] or cgroups [3]) independently of the other if the
project decides to do so.

Using seperate sections for mknod and cgroups also allows us to avoid
the complicated validation rules needed for the combined format
mknod/cgroup [4].

Now that there is a section specific to supplying devices, I shifted
the default device listing over from config-linux [5].  The /dev/ptmx
entry is a bit awkward, since it's not a device, but it seemed to fit
better over here.  But I would also be fine leaving it with the other
mounts in config-linux.

fileMode, uid, and gid are optional, because mknod(2) doesn't need
them and specifies the handling when they aren't set [6,7].
Similarly, major/minor numbers are only required for S_IFCHR and
S_IFBLK [6].  I've left off wording about required runtime behavior
for unset values, because I'd rather address that with a blanket rule
[8].

For the cgroup, access is optional because the kernel docs show an
example that doesn't write an access field to the devices.deny file
[9].  The current kernel docs don't go into much detail on this
behavior (I expect unset and 'rwm' are equivalent), but if the kernel
doesn't need a value written, the spec should get out of the way and
allow users to not specify a value.

The reference links are sorted into two blocks, with kernel-doc links
sorted alphabetically followed by man pages sorted alphabetically by
section.  The cgroup link is new since 2016-01-13 [10].

[1]: https://groups.google.com/a/opencontainers.org/forum/#!topic/dev/y_Fsa2_jJaM
     Subject: Separate config entries for device mknod and cgroups?
     Date: Mon, 5 Oct 2015 12:46:55 -0700
     Message-ID: <20151005194655.GN28418@odin.tremily.us>
[2]: opencontainers#98
[3]: https://groups.google.com/a/opencontainers.org/forum/#!topic/dev/qWHoKs8Fsrk
     Subject: removal of cgroups from the OCI Linux spec
     Date: Wed, 28 Oct 2015 17:01:59 +0000
     Message-ID: <CAD2oYtO1RMCcUp52w-xXemzDTs+J6t4hS5Mm4mX+uBnVONGDfA@mail.gmail.com>
[4]: opencontainers#101
[5]: opencontainers#171 (comment)
[6]: http://man7.org/linux/man-pages/man2/mknod.2.html#DESCRIPTION
[7]: https://github.com/opencontainers/specs/pull/298/files#r51053835
[8]: opencontainers#285 (comment)
[9]: https://kernel.org/doc/Documentation/cgroup-v1/devices.txt
[10]: https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=34a9304a96d6351c2d35dcdc9293258378fc0bd8

Signed-off-by: W. Trevor King <wking@tremily.us>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants