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

Properly share UTS namespaces in a pod #3741

Merged
merged 4 commits into from
Aug 7, 2019

Conversation

haircommander
Copy link
Collaborator

Hostname wasn't previously shared when a container shared a UTS namespace. Fix this, and add a test

fixes: #3547

@haircommander
Copy link
Collaborator Author

@matpen PTAL

pkg/spec/spec.go Outdated Show resolved Hide resolved
@mheon
Copy link
Member

mheon commented Aug 6, 2019

/approve

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 6, 2019
@mheon
Copy link
Member

mheon commented Aug 6, 2019

LGTM

Copy link
Member

@TomSweeneyRedHat TomSweeneyRedHat left a comment

Choose a reason for hiding this comment

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

one questions, LGTM otherwise

pkg/spec/spec.go Show resolved Hide resolved
Copy link
Member

@jwhonce jwhonce left a comment

Choose a reason for hiding this comment

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

Logging improvements for when run in a multi-user environment.

pkg/spec/spec.go Outdated
} else if config.NetMode.IsHost() || config.UtsMode.IsHost() {
hostname, err = os.Hostname()
if err != nil {
return nil, errors.Wrap(err, "unable to retrieve hostname")
Copy link
Member

Choose a reason for hiding this comment

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

Logging the attempted hostname would help with debugging.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I would expect hostname to be empty here, because we errored on a call to os.Hostname(). I certainly don't expect it to have anything of value, but I can note that it failed to get the host's hostname

pkg/spec/spec.go Outdated
@@ -606,6 +616,9 @@ func addUTSNS(config *CreateConfig, g *generate.Generator) error {
if utsMode.IsHost() {
return g.RemoveLinuxNamespace(string(spec.UTSNamespace))
}
if utsMode.IsContainer() {
logrus.Debug("using container utsmode")
Copy link
Member

Choose a reason for hiding this comment

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

Which container is using utsmode?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is following the format of the other namespace parsing functions. None have access to the container ID, so it's not printed for any of them

Copy link
Member

Choose a reason for hiding this comment

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

You do see where in a N-user/container environment this is just noise and zero value?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I certainly do, I'll remove all of them then

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

EDIT: I can fix this actually

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed

pkg/spec/spec.go Show resolved Hide resolved
@openshift-ci-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: haircommander, jwhonce, mheon

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@haircommander haircommander force-pushed the uts-fix branch 2 times, most recently from 0a6af4e to 81e9665 Compare August 6, 2019 19:31
@jwhonce
Copy link
Member

jwhonce commented Aug 6, 2019

/hold
/lgtm

@openshift-ci-robot openshift-ci-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm Indicates that a PR is ready to be merged. labels Aug 6, 2019
Sharing a UTS namespace means sharing the hostname. Fix situations where a container in a pod didn't properly share the hostname of the pod.

Signed-off-by: Peter Hunt <[email protected]>
@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Aug 7, 2019
@mheon
Copy link
Member

mheon commented Aug 7, 2019

Test failures look legitimate?

@haircommander
Copy link
Collaborator Author

Test failures look legitimate?

it sure was haha

If we call Container(), we expect the namespace to be prefixed with "container:".
Add this check, and refactor to use named const strings instead of string literals

Signed-off-by: Peter Hunt <[email protected]>
@haircommander
Copy link
Collaborator Author

finally green @mheon @baude @jwhonce @rhatdan @TomSweeneyRedHat PTAL

@mheon
Copy link
Member

mheon commented Aug 7, 2019

/hold cancel
/lgtm

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 7, 2019
@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Aug 7, 2019
@openshift-merge-robot openshift-merge-robot merged commit 35ecf49 into containers:master Aug 7, 2019
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 26, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"sudo: unable to resolve host" when running sudo in pod
6 participants