Gentoo Archives: gentoo-dev

From: Christian Kniep <ckniep@××××××.com>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] rfc: /etc/hostname on gentoo
Date: Tue, 23 Aug 2016 07:01:00
Message-Id: AB1D9996-B607-4295-AC10-06C923C238C1@gaikai.com
In Reply to: Re: [gentoo-dev] rfc: /etc/hostname on gentoo by Daniel Campbell
1 Hey y’all,
2
3 just to elaborate on the problem and clear up the fuzz I made.
4
5 I am facing to be distro-agnostic, thus I do not know in advance if I am running on DockerForMac (which uses Alpine Linux), some weird Ubuntu vagrant setup of mine or a fleet of gentoo hosts.
6 Docker Service schedules the service as it pleases (oversimplification). For services I fancy using global services in which the described services is started on each node of the SWAM cluster.
7
8 A demo of how this looks like (fast-forward to minute 28): https://www.youtube.com/watch?v=g-YNST-COdI
9
10 I have four nodes in my cluster:
11
12 ###
13 docker node ls
14 ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS
15 4iffi5tt5jlk03ub7nd7cf5r2 gentoo1 Ready Active
16 5m0x0vqtjugkwi13gkaa4ijk2 gentoo2 Ready Active
17 6eu0fiz0ch8e7pnbbzh8pj545 gentoo3 Ready Active Leader
18 ckrxwdppbehyz806o7gxgashl * gentoo4 Ready Active Reachable
19 $
20 ###
21
22 If I use an environment variable like this:
23
24 ###
25 $ docker service create --name nginx --mode=global -e SERVICE_HOSTNAME=$(hostname -f) nginx
26 ###
27
28 Each of the tasks (a container to-be-run on one of the nodes) will now find an environment variable SERVICE_HOSTNAME, but it will a) be the same among all containers and b) it will show the hostname from which the service was created.
29
30 Therefore environment variables are not going to get me far.
31
32 On docker host with non-gentoo I can just run this (e.g. on my DockerForMac):
33
34 ###
35 $ docker service create --mount type=bind,source=/etc/hostname,target=/etc/docker-hostname:ro --name nginx nginx
36 ###
37
38 By doing so I am able to determine on which host I am running on each tasks without much hassle.
39
40 ###
41 $ docker exec -ti 56e8b2eaecc3 cat /etc/docker-hostname
42 ###
43
44 I am using this for a zookeeper service which should reuse the same MYID when restarted on a given node.
45 Otherwise I would end up with a restarting container on a given node, which would get himself a new MYID and after a couple of restarts I am out of the range of MYID (up to 255).
46
47 Cheers and again, sorry for the misunderstanding
48 Christian
49
50
51 > On 23 Aug 2016, at 08:39, Daniel Campbell <zlg@g.o> wrote:
52 >
53 > On 08/22/2016 03:09 PM, William Hubbs wrote:
54 >> On Mon, Aug 22, 2016 at 09:28:44PM +0200, Hans de Graaff wrote:
55 >>> On Mon, 2016-08-22 at 10:58 -0500, William Hubbs wrote:
56 >>>> All,
57 >>>>
58 >>>> it looks like app-emulation/docker expects /etc/hostname to exist.
59 >>>
60 >>> Is there a bug for this? docker seems to work fine for me on a system
61 >>> without this file present.
62 >>
63 >> Ok, now for the clarification.
64 >>
65 >> Someone here at the office was wanting a cross-platform way to find out
66 >> the hostname of the host the container is running on inside the
67 >> container. We made another suggestion for that, so forget about the
68 >> docker angle on this for now.
69 >>
70 >> But, /etc/hostname is a multi-distro standard for where the hostname is
71 >> located, so I would like to make openrc prefer it over the setting in
72 >> /etc/conf.d/hostname if it exists.A
73 >>
74 >> I suppose whether we populate it by default might be a separate
75 >> question.
76 >>
77 >> William
78 >>
79 > Changing the way one configures the hostname because one or a few
80 > packages A) need this knowledge, and B) hardcode /etc/hostname is not
81 > worth changing the canonical way to update it and getting people to
82 > change their habits.
83 >
84 > It makes a bit more sense to rely on previous configuration
85 > (/etc/conf.d/hostname) and write a tiny 'script' that populates
86 > /etc/hostname. bash could do it (naively) in two lines:
87 >
88 > source /etc/conf.d/hostname
89 > echo "$hostname" > /etc/hostname
90 >
91 > The 'multi-distro standard' is du jour at best and imo not a compelling
92 > reason to follow.
93 >
94 > --
95 > Daniel Campbell - Gentoo Developer
96 > OpenPGP Key: 0x1EA055D6 @ hkp://keys.gnupg.net
97 > fpr: AE03 9064 AE00 053C 270C 1DE4 6F7A 9091 1EA0 55D6
98 >

Attachments

File name MIME type
smime.p7s application/pkcs7-signature

Replies

Subject Author
Re: [gentoo-dev] rfc: /etc/hostname on gentoo Michael Orlitzky <mjo@g.o>