Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Feb 24, 2020. It is now read-only.

Conversation

@iaguis
Copy link
Member

@iaguis iaguis commented Mar 4, 2016

It allows the user to specify a host name for the pod. If not specified, it will be "rkt-$PODUUID".

This approach might not be OK if we want to use systemd-resolved, apparently it expects container's machine name to match the hostname.

cc @steveej @yifan-gu @sjpotter

Fixes #2245

@sjpotter
Copy link
Contributor

sjpotter commented Mar 4, 2016

@iaguis so would resolved break if a user changed the hostname within the container themselves? and is that a bad thing?

@iaguis
Copy link
Member Author

iaguis commented Mar 4, 2016

I don't think I have enough context to answer that. Maybe @steveej can shed some light on it.

// According to systemd manual (https://www.freedesktop.org/software/systemd/man/hostname.html) :
// "The /etc/hostname file configures the name of the local system that is set
// during boot using the sethostname system call"
if hostname == "" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not the common place. As the case "kvm" returns directly above.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooops

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated, I don't know why this comment is still showing up on github...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code was not changed, only moved, maybe this is a reason?

@iaguis iaguis force-pushed the iaguis/hostname branch from 5a6cd63 to 13c1560 Compare March 7, 2016 14:46
@steveej
Copy link
Contributor

steveej commented Mar 8, 2016

@sjpotter

@iaguis so would resolved break if a user changed the hostname within the container themselves? and is that a bad thing?

This is not something we can easily answer in general, and therefore nothing we have to worry about immediately. You can read https://www.freedesktop.org/software/systemd/man/nss-mymachines.html# to get an idea what can influence the configuration. I just checked the /etc/nsswitch.conf inside CoreOS, which is also used within the default stage1, and neither mymachine nor myhostname is configured.

@iaguis
Copy link
Member Author

iaguis commented Mar 8, 2016

FWIW with mymachines in /etc/nsswitch.conf, resolution works fine with rkt and a different --hostname.

@jellonek
Copy link
Contributor

jellonek commented Mar 8, 2016

g2k
LGTM

@iaguis iaguis changed the title (WIP) rkt: add --hostname option rkt: add --hostname option Mar 8, 2016
@iaguis
Copy link
Member Author

iaguis commented Mar 8, 2016

If the resolved thing is not something we should worry about for now, I'm OK with merging this.

What do you think, @steveej?

@jellonek
Copy link
Contributor

jellonek commented Mar 8, 2016

Is it possible that someone will add additional functional test for this before merge? It's not something what i need there strongly, but... (i know that i should ask about this @mstachowski when this was added to kvm flavor, but still...)

@iaguis
Copy link
Member Author

iaguis commented Mar 8, 2016

I can add one if we decide it's ok to merge :)

@iaguis
Copy link
Member Author

iaguis commented Mar 8, 2016

Added a functional test

@steveej
Copy link
Contributor

steveej commented Mar 8, 2016

It will break fly :-(

@steveej
Copy link
Contributor

steveej commented Mar 8, 2016

How about we introduce annotations for stage1 ACIs where supported commands (run, exec, gc) and their supported flags (--hostname, --dns, --port, ...) can be declared? stage0 could then check if it can pass all requested flags to the stage1 and either skip them or error out cleanly. Behavior on incompatibility should default to error but also be settable via a stage0 flag.

@jellonek
Copy link
Contributor

Seems to me a bit too complicated, but reasonable. I have no strong feelings about this...

But... This will open a door for new features (and so incompatibility between flavors) supported by one flavor or group of them - this seems more scary and exciting ;)

@iaguis
Copy link
Member Author

iaguis commented Mar 14, 2016

How about we introduce annotations for stage1 ACIs where supported commands (run, exec, gc) and their supported flags (--hostname, --dns, --port, ...) can be declared? stage0 could then check if it can pass all requested flags to the stage1 and either skip them or error out cleanly. Behavior on incompatibility should default to error but also be settable via a stage0 flag.

This is a pretty big change, can we just ignore the flag in fly for now (like we do with the rest) so we can get this and discuss that in a new issue?

@iaguis iaguis added this to the v1.2.0 milestone Mar 14, 2016
| `--dns` | `` | IP Address | Name server to write in `/etc/resolv.conf`. It can be specified several times |
| `--dns-opt` | `` | Option as described in the options section in resolv.conf(5) | DNS option to write in `/etc/resolv.conf`. It can be specified several times |
| `--dns-search` | `` | Domain name | DNS search domain to write in `/etc/resolv.conf`. It can be specified several times |
| `--hostname` | `` | A host name | Pod's hostname. If empty, it will be the "rkt-$PODUUID" |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/the//

@iaguis
Copy link
Member Author

iaguis commented Mar 14, 2016

This is a pretty big change, can we just ignore the flag in fly for now (like we do with the rest) so we can get this and discuss that in a new issue?

I added a commit doing that, addressed the review and added --hostname to the stage1 implementors guide.

@alban
Copy link
Member

alban commented Mar 14, 2016

The --hostname is not in the documentation:
https://github.com/coreos/rkt/blob/master/Documentation/devel/stage1-implementors-guide.md#arguments

I am not sure about adding a new parameter without introducing versioning in annotations as explained here:
#2173 (comment)

@steveej
Copy link
Contributor

steveej commented Mar 15, 2016

How about we introduce annotations for stage1 ACIs where supported commands (run, exec, gc) and their supported flags (--hostname, --dns, --port, ...) can be declared? stage0 could then check if it can pass all requested flags to the stage1 and either skip them or error out cleanly. Behavior on incompatibility should default to error but also be settable via a stage0 flag.

This is a pretty big change, can we just ignore the flag in fly for now (like we do with the rest) so we can get this and discuss that in a new issue?

Could you break it apart to identify the most difficult/time-consuming steps that may be postponed?

@jonboulle
Copy link
Contributor

This is a pretty big change, can we just ignore the flag in fly for now (like we do with the rest) so we can get this and discuss that in a new issue?

Let's do this. There are many outstanding issues with the fly/stage1 thing that need to be addressed, but adding another ignored flag is only making the situation marginally worse.

@yifan-gu
Copy link
Contributor

I think this also affects how we get logs from journactl. journalctl -m _HOSTNAME=rkt-uuid doesn't seem to work now in this example: https://github.com/coreos/rkt/blob/master/Documentation/using-rkt-with-systemd.md#systemd-run

@iaguis
Copy link
Member Author

iaguis commented Mar 17, 2016

You can do journalctl -m _MACHINE_ID=${UUID_WITHOUT_DASHES}.

* `--net[=$NET1,$NET2,...]` to configure the creation of a contained network.
See the [rkt networking documentation](../networking.md) for details.
* `--mds-token=$TOKEN` passes the auth token to the apps via `AC_METADATA_URL` env var
* `--hostname=$HOSTNAME` configures the host name of the pod. If empty, it will be "rkt-$PODUUID". Only available from ABI version 2.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably would be easier to read if there was a separate section like "flags added in interface version 2".

@sjpotter
Copy link
Contributor

yea, we figured that out, but strangely, it doesn't work on my ubuntu box.
( _HOSTNAME or _MACHINE_ID)

@iaguis iaguis force-pushed the iaguis/hostname branch 2 times, most recently from baeeeb5 to 544e009 Compare March 17, 2016 16:36
@iaguis
Copy link
Member Author

iaguis commented Mar 17, 2016

Updated.

stage0/run.go Outdated
}

if cfg.Hostname != "" {
if s1v > 1 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder about defining a constant in interface.go, and then:

if s1v > interfaceVersionHostname {

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dunno, it might be troublesome later. interfaceVersionThisThatAndOneMoreThingIfIRemeberedEverything.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's how German works, right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, instead of a constant, define a function in interface.go:

if interfaceVersionSupportsHostname(s1v) {
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or maybe make s1v an object instead of an integer, so you could add functions to it like func (s1v Stage1InterfaceVersion) SupportsHostname() bool {}

That would be an idea for a separate PR. ;P

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll think about it... :P

@krnowak
Copy link
Collaborator

krnowak commented Mar 17, 2016

LFAD, but maybe you'll want another stamp.

@alban
Copy link
Member

alban commented Mar 17, 2016

LGTM if green

iaguis added a commit that referenced this pull request Mar 17, 2016
@iaguis iaguis merged commit ff0813b into rkt:master Mar 17, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make rkt able to specify hostname for pods

8 participants