Skip to content

oc cluster up in user namespace mode: unbreak available ports check #14169

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

Conversation

php-coder
Copy link
Contributor

In order to have access to HostConfig.Userns field, I have to update version of go-dockerclient.

PTAL @csrwng @bparees
CC @mfojtik @pweil-

Addressed to #12643

return false, err
}
for _, val := range info.SecurityOptions {
if val == "name=userns" {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This check depends on the format of SecurityOptions and could be broken by updates in Docker but I think that I couldn't do anything better than this. Using strings.Contains() won't make this check better IMHO.

@@ -112,7 +125,11 @@ func (h *Runner) Env(env ...string) *Runner {

// Privileged tells Docker to run the container as privileged
func (h *Runner) Privileged() *Runner {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Privileged option doesn't work in user namespace mode, so I'm emulating it's behavior. Because signature of Privileged hasn't changed, we don't need to update existing code.

Copy link

Choose a reason for hiding this comment

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

privileged + host user namespace combo works. It may be safe here that if this method is called always call HostUserns. Not setting h.hostConfig.Privileged is going to result in different behavior so it should still be set.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I remember that Docker doesn't allow --privileged option so I thought that API also doesn't accept it. Ok, I'll try it on Monday.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! I've updated the code accordingly.

@@ -714,14 +714,19 @@ func (c *ClientStartConfig) EnsureDefaultRedirectURIs(out io.Writer) error {

// CheckAvailablePorts ensures that ports used by OpenShift are available on the Docker host
func (c *CommonStartConfig) CheckAvailablePorts(out io.Writer) error {
userNamespace, err := c.DockerHelper().UserNamespaceEnabled()
Copy link
Contributor Author

@php-coder php-coder May 12, 2017

Choose a reason for hiding this comment

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

Initial idea was to invoke this function during helpers creation but in this case we couldn't report about possible error. The only way that I found is to invoke it from CheckAvailablePorts(). That's why signature of TestPorts() has been modified.

Copy link
Contributor

Choose a reason for hiding this comment

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

Why not ? (report about possible error)
If an error is returned by the docker info call, then cluster up should terminate. You can pass a dockerhelper to the NewRunHelper function.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's less robust if you rely on the caller/client to figure out if you have user namespaces turned on.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The comments were addressed. PTAL.

Copy link
Contributor

@csrwng csrwng left a comment

Choose a reason for hiding this comment

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

some comments

@@ -46,6 +47,12 @@ func (h *Runner) Name(name string) *Runner {
return h
}

// UserNamespace sets user namespace mode flag that affects behavior of other options.
Copy link
Contributor

Choose a reason for hiding this comment

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

I would like to make this part of the constructor for this helper (NewRunHelper). I don't think we should rely on the client to set it to the proper value.

@@ -714,14 +714,19 @@ func (c *ClientStartConfig) EnsureDefaultRedirectURIs(out io.Writer) error {

// CheckAvailablePorts ensures that ports used by OpenShift are available on the Docker host
func (c *CommonStartConfig) CheckAvailablePorts(out io.Writer) error {
userNamespace, err := c.DockerHelper().UserNamespaceEnabled()
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not ? (report about possible error)
If an error is returned by the docker info call, then cluster up should terminate. You can pass a dockerhelper to the NewRunHelper function.

@@ -714,14 +714,19 @@ func (c *ClientStartConfig) EnsureDefaultRedirectURIs(out io.Writer) error {

// CheckAvailablePorts ensures that ports used by OpenShift are available on the Docker host
func (c *CommonStartConfig) CheckAvailablePorts(out io.Writer) error {
userNamespace, err := c.DockerHelper().UserNamespaceEnabled()
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's less robust if you rely on the caller/client to figure out if you have user namespaces turned on.

@php-coder php-coder force-pushed the oc_cluster_up_and_ports_in_userns_env branch 2 times, most recently from eb35c3f to c8553a2 Compare May 15, 2017 18:21
if err != nil {
return "", "", 0, err
} else if userNsMode {
h.hostConfig.Privileged = false
Copy link
Contributor

Choose a reason for hiding this comment

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

Why set this false? If the client has called Privileged on this Runner, then UserNsMode would be set to "host", which would work with Privileged set to true, right?

Actually I would get rid of the HostUserns method introduced above and instead, check here if Privileged is set, then if it is, then set h.hostConfig.UsernsMode to "host". Otherwise, leave it alone.

I would think you don't want to set hostConfig.UsernsMode to host if user namespaces is not abled.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why set this false?

Because privileged option can't be used in user namespace mode (see the error message in the original issue: Privileged mode is incompatible with user namespaces).

check here if Privileged is set

Yes, thanks. I'll update this condition tomorrow.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Condition has been updated. PTAL.

@php-coder php-coder force-pushed the oc_cluster_up_and_ports_in_userns_env branch 2 times, most recently from 21e9a01 to 378d20e Compare May 16, 2017 12:52
@csrwng
Copy link
Contributor

csrwng commented May 16, 2017

The cluster up part LGTM

@csrwng
Copy link
Contributor

csrwng commented May 16, 2017

It'd be good for someone who works on rebases like @deads2k to make sure that updating the fsouza client won't cause any issues.

@php-coder php-coder force-pushed the oc_cluster_up_and_ports_in_userns_env branch from 378d20e to d84c262 Compare May 16, 2017 14:45
@php-coder
Copy link
Contributor Author

@csrwng I've moved code for adjusting HostConfig from runWithOutput() to Create() function to make it also work in case when Start() function was being used to run container.

@csrwng
Copy link
Contributor

csrwng commented May 16, 2017

thx, still LGTM

@deads2k
Copy link
Contributor

deads2k commented May 16, 2017

It'd be good for someone who works on rebases like @deads2k to make sure that updating the fsouza client won't cause any issues.

make sure the levels match between kube master and this.

@php-coder
Copy link
Contributor Author

make sure the levels match between kube master and this.

@deads2k which levels? Do you mean versions?

@deads2k
Copy link
Contributor

deads2k commented May 16, 2017

@deads2k which levels? Do you mean versions?

Yeah, kube and origin should agree on the commit SHA to use in order to make the rebase reasonable (or sometimes even possible).

@php-coder
Copy link
Contributor Author

Yeah, kube and origin should agree on the commit SHA to use in order to make the rebase reasonable (or sometimes even possible).

As I can see Kubernetes doesn't have fsouza/go-dockerclient dependency at this time. Does it mean that we can merge this PR?

@mfojtik
Copy link
Contributor

mfojtik commented May 18, 2017

@bparees is there a card about getting rid of fsouza client?

@bparees
Copy link
Contributor

bparees commented May 18, 2017

@bparees
Copy link
Contributor

bparees commented May 18, 2017

but we now maintain a separate vendored copy of fsouza in pkg/build/vendor so we can run at a different level than the rest of origin.

@php-coder
Copy link
Contributor Author

but we now maintain a separate vendored copy of fsouza in pkg/build/vendor so we can run at a different level than the rest of origin.

Unfortunately oc cluster code doesn't use it and that's why I need this bump. I tried to update fsouza to the same version as we have in pkg/build/vendor but it was really hard because it leads to massive dependencies update (for example, docker api that requires something related to swarm).

@php-coder
Copy link
Contributor Author

What is the outcome? Could we merge it now? If not then when? In the beginning of the next release?

@csrwng
Copy link
Contributor

csrwng commented May 25, 2017

@php-coder the code looks good to me, but would like confirmation that it's ok to update the fsouza docker client. /cc @smarterclayton

@php-coder
Copy link
Contributor Author

the code looks good to me, but would like confirmation that it's ok to update the fsouza docker client

@smarterclayton Ping

@smarterclayton
Copy link
Contributor

LGTM [merge]

@php-coder
Copy link
Contributor Author

test flake #14496 and #14497

@csrwng
Copy link
Contributor

csrwng commented Jun 8, 2017

[merge]

@openshift-bot
Copy link
Contributor

Evaluated for origin merge up to d84c262

@openshift-bot
Copy link
Contributor

[Test]ing while waiting on the merge queue

@openshift-bot
Copy link
Contributor

Evaluated for origin test up to d84c262

@openshift-bot
Copy link
Contributor

continuous-integration/openshift-jenkins/test FAILURE (https://ci.openshift.redhat.com/jenkins/job/test_pull_request_origin/2020/) (Base Commit: ba62cde)

@php-coder
Copy link
Contributor Author

test flake #14385

@openshift-bot
Copy link
Contributor

openshift-bot commented Jun 8, 2017

continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/merge_pull_request_origin/932/) (Base Commit: 4b98e27) (Image: devenv-rhel7_6333)

@openshift-bot openshift-bot merged commit 1257438 into openshift:master Jun 9, 2017
@php-coder php-coder deleted the oc_cluster_up_and_ports_in_userns_env branch June 9, 2017 10:22
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.

8 participants