Skip to content
This repository was archived by the owner on Mar 9, 2022. It is now read-only.

Revert "Add HOSTNAME to env by default for pod containers" #898

Merged
merged 1 commit into from
Sep 6, 2018

Conversation

Random-Liu
Copy link
Member

@Random-Liu Random-Liu commented Sep 6, 2018

This reverts commit 4c3e195.

See reason: #895 (comment)

Signed-off-by: Lantao Liu [email protected]

@yujuhong
Copy link
Member

yujuhong commented Sep 6, 2018

/lgtm

@yujuhong yujuhong merged commit 9cd964f into containerd:master Sep 6, 2018
@Random-Liu Random-Liu deleted the revert-#895 branch September 6, 2018 23:31
@yujuhong
Copy link
Member

yujuhong commented Sep 6, 2018

From the kube-addon-manager log:

INFO: Leader is bootstrap-e2e-master
INFO: Not elected leader, going back to sleep.
INFO: Leader is bootstrap-e2e-master
INFO: Not elected leader, going back to sleep.
INFO: Leader is bootstrap-e2e-master
INFO: Not elected leader, going back to sleep.
INFO: Leader is bootstrap-e2e-master

The addon manager did not think it's the leader bootstrap-e2e-master and refused to continue creating all the addons (including the cluster roles):
https://github.com/kubernetes/kubernetes/blob/d0439d417b0563d44c65b6e400e2070964dea7d1/cluster/addons/addon-manager/kube-addons.sh#L162-L164

@yujuhong
Copy link
Member

yujuhong commented Sep 6, 2018

By the way, kube-addon-manager runs in the host network

@yujuhong
Copy link
Member

yujuhong commented Sep 6, 2018

By the way, kube-addon-manager runs in the host network

kubelet probably doesn't set hostname for pods running in the host network. Not sure how docker handles this.

@estesp
Copy link
Member

estesp commented Sep 7, 2018

Interesting; it definitely looks like HOSTNAME is part of the problem here.

This is the code where Docker engine sets up HOSTNAME as a default env var in every container (https://github.com/moby/moby/blob/master/container/container.go#L694-L718), which is called from the OCI spec generator without any kind of checking if netns == host.

I also looked at dockershim and don't see any env replacement or changes happening; I can't even find the string "HOSTNAME" in any files in pkg/kubelet. So, something is definitely different, but I'm not sure what is occurring here.

@estesp
Copy link
Member

estesp commented Sep 7, 2018

hmm, looks like the missing piece is that by the time that code runs in Docker, if --net=host it has set the metadata config's hostname to the actual host hostname; not sure if that is the case with the way this is happened here; Docker for Mac example:

docker run --rm --net=host alpine sh -c 'echo $HOSTNAME'
linuxkit-025000000001

The container's hostname is the LinuxKit VM hostname.

@yujuhong
Copy link
Member

yujuhong commented Sep 7, 2018

I also looked at dockershim and don't see any env replacement or changes happening; I can't even find the string "HOSTNAME" in any files in pkg/kubelet. So, something is definitely different, but I'm not sure what is occurring here.

Kubelet passes the hostname through the podsandbox config, but it doesn't add an env variable directly.

hmm, looks like the missing piece is that by the time that code runs in Docker, if --net=host it has set the metadata config's hostname to the actual host hostname

That sounds reasonable. Docker probably derives this information before passing it through the config.

@Random-Liu
Copy link
Member Author

Random-Liu commented Sep 10, 2018

https://github.com/moby/moby/blob/master/daemon/container_operations.go#L936-L943

I'll make the change. And we may want to define the behavior in CRI.

@Random-Liu Random-Liu mentioned this pull request Sep 10, 2018
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.

5 participants