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

enable build pods to tolerate running on crio while talking to docker #16491

Merged
merged 3 commits into from
Sep 28, 2017

Conversation

bparees
Copy link
Contributor

@bparees bparees commented Sep 21, 2017

No description provided.

@openshift-ci-robot openshift-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Sep 21, 2017
@openshift-merge-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bparees

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

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@openshift-merge-robot openshift-merge-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. needs-api-review labels Sep 21, 2017
@bparees
Copy link
Contributor Author

bparees commented Sep 21, 2017

@mrunalp @openshift/devex ptal

the s2i vendor changes will be replaced with a bump commit shortly.

func readResolvConfHostPath() (string, error) {
// find the /etc/resolv.conf host path based on what is mounted into this
// container.
resolvConf, err := os.Open("/proc/1/mountinfo")
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 going to fail when we turn on shared pid namespace, isn't it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no idea. will containers no longer have their own /proc filesystem with their own pid 1 at that point?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, this won't work with pid namespace sharing. Cleaner way is using crio inspect endpoint but hopefully, we can move away from docker before we have to do that.

// readPid determines the actual host pid of the pid 1 process in this container
func readPid() (string, error) {
// get pid from /proc/1/sched , e.g.: "java (8151, #threads: 53)"
pidFile, err := os.Open("/proc/1/sched")
Copy link
Contributor

Choose a reason for hiding this comment

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

Wow... that's hacky.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

and, let me emphasize, temporary until we move to pure crio support, however long that takes.

Copy link
Member

Choose a reason for hiding this comment

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

Cleaner way for getting pid as well as resolv path is from crio inspect endpoint but we didn't want that.. and yes this doesn't work with pid namespaces but hopefully we can migrate away from docker for builds by then or switch to using crio inspect endpoint.

// readResolveConfHostPath determines the path to the resolv.conf file for this
// container, as it exists on the host machine. (/etc/resolv.conf is mounted
// into the container from the host path).
func readResolvConfHostPath() (string, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This stuff needs to go into its own package. It's getting pretty ugly in here. These aren't build utils, they're build environment / os coupling.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

do you really want to encourage other people to consume this stuff? again it should all go away in the future.

@@ -305,7 +310,8 @@ func (d *DockerBuilder) dockerBuild(dir string, tag string, secrets []buildapi.S
NoCache: noCache,
Pull: forcePull,
BuildArgs: buildArgs,
NetworkMode: string(getDockerNetworkMode()),
NetworkMode: network,
BuildBinds: fmt.Sprintf("[\"%s:/etc/resolv.conf\"]", resolvConfHostPath),
Copy link
Contributor

Choose a reason for hiding this comment

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

If I can inject : into the resolve conf host path, can I break this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it'll break, i don't know that it'll get you anywhere.

if you can inject some quotes and a comma along with the colon you could presumably do pretty interesting things in terms of bindmounting host content into your build container.

I'm not sure how a user would have any control over that path though.

Regardless, we can certainly audit/strip those characters from the resolvConfHostPath.

@@ -297,6 +297,11 @@ func (d *DockerBuilder) dockerBuild(dir string, tag string, secrets []buildapi.S
return err
}

network, resolvConfHostPath, err := getContainerNetworkMode()
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be a lot better if this is an interface passed into docker builder, and none of this code had any idea of what this stuff was.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

what exactly are you proposing be an interface? A ContainerNetworkModeGetter interface?

@bparees bparees force-pushed the crio_networking branch 2 times, most recently from 1199dd6 to 57b6f4f Compare September 21, 2017 21:42
@bparees
Copy link
Contributor Author

bparees commented Sep 21, 2017

/retest

1 similar comment
@bparees
Copy link
Contributor Author

bparees commented Sep 22, 2017

/retest

@runcom
Copy link
Member

runcom commented Sep 22, 2017

/test crio

@bparees bparees force-pushed the crio_networking branch 2 times, most recently from 7aa8ccd to 902e5ec Compare September 22, 2017 19:30
@bparees
Copy link
Contributor Author

bparees commented Sep 22, 2017

/retest

@bparees bparees changed the title enable build pods to tolerate running on crio while talking to docker [WIP] enable build pods to tolerate running on crio while talking to docker Sep 23, 2017
@openshift-ci-robot openshift-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 23, 2017
@runcom
Copy link
Member

runcom commented Sep 25, 2017

/test crio

@bparees bparees changed the title [WIP] enable build pods to tolerate running on crio while talking to docker enable build pods to tolerate running on crio while talking to docker Sep 26, 2017
@@ -178,6 +178,7 @@ func (bs *SourceBuildStrategy) CreateBuildPod(build *buildapi.Build) (*v1.Pod, e

setOwnerReference(pod, build)
setupDockerSocket(pod)
setupCrioSocket(pod)
Copy link
Member

Choose a reason for hiding this comment

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

Should there be a check to add this only if the socket source path exists?

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 didn't see a good way to do that(after all this logic is running in a controller that doesn't know anything about the target node for the build pod) and it doesn't do any harm to do the mount even if the source path doesn't exist.

Copy link
Member

Choose a reason for hiding this comment

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

So, the controller doesn't add the mount to the pod if it can't find the source? If the mount is passed down to the runc config.json, it will fail to start the container if it can't find the source.

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 controller adds the mount. if runc is the container engine, then the source will be there.

and docker seemingly does not care if it does not exist, because this is working when i run using docker as the container engine.

@bparees
Copy link
Contributor Author

bparees commented Sep 27, 2017

@mrunalp comments addressed

@mrunalp
Copy link
Member

mrunalp commented Sep 27, 2017

LGTM

@bparees bparees added the lgtm Indicates that a PR is ready to be merged. label Sep 27, 2017
@bparees
Copy link
Contributor Author

bparees commented Sep 27, 2017

@bparees
Copy link
Contributor Author

bparees commented Sep 27, 2017

/retest

@openshift-merge-robot openshift-merge-robot removed the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 28, 2017
@bparees bparees added approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/bug Categorizes issue or PR as related to a bug. labels Sep 28, 2017
@openshift-ci-robot
Copy link

openshift-ci-robot commented Sep 28, 2017

@bparees: The following test failed, say /retest to rerun them all:

Test name Commit Details Rerun command
ci/openshift-jenkins/extended_conformance_crio d94ceaf link /test crio

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@bparees
Copy link
Contributor Author

bparees commented Sep 28, 2017

/retest

@openshift-merge-robot
Copy link
Contributor

Automatic merge from submit-queue

@openshift-merge-robot openshift-merge-robot merged commit a8ac70a into openshift:master Sep 28, 2017
@bparees bparees deleted the crio_networking branch September 29, 2017 17:11
@smarterclayton
Copy link
Contributor

I can't find any reference to buildbinds in projectatomic/docker - where is the code that actually implements that located?

@smarterclayton
Copy link
Contributor

Also, why did we expand the docker api?

@bparees
Copy link
Contributor Author

bparees commented Feb 25, 2018

docker build -v provides this on the cli, I don't remember what the issue was w/ the docker api itself not exposing it (or how docker build handles it if the api doesn't provide it)

@smarterclayton
Copy link
Contributor

smarterclayton commented Feb 26, 2018 via email

@bparees
Copy link
Contributor Author

bparees commented Feb 26, 2018

It does not. Not on regular docker.

you mean "docker build -v" isn't even an option in regular docker?

@smarterclayton
Copy link
Contributor

smarterclayton commented Feb 26, 2018 via email

@runcom
Copy link
Member

runcom commented Feb 26, 2018

It's not indeed, we've added that long time ago @rhatdan

@bparees
Copy link
Contributor Author

bparees commented Feb 26, 2018

guessing it got added as a "might as well" when the logic was being added to bindmount subscription secrets into the build container.

@smarterclayton
Copy link
Contributor

Where's the implementation for this? I can't find it in projectatomic/docker for some reason.

@runcom
Copy link
Member

runcom commented Feb 27, 2018

It's in branches 1.12.6, 1.13.1

@smarterclayton
Copy link
Contributor

smarterclayton commented Feb 27, 2018 via email

@runcom
Copy link
Member

runcom commented Feb 27, 2018

"buildbinds" comes from the patched library, I think it's just the struct in the go client library, not in projectatomic/docker, That is translated to json as "buildbinds"

api/server/router/build/build_routes.go
97:     var buildBinds = []string{}
98:     buildBindsJSON := r.FormValue("buildbinds")
99:     if buildBindsJSON != "" {
100:            if err := json.NewDecoder(strings.NewReader(buildBindsJSON)).Decode(&buildBinds); err != nil {
103:            options.Binds = buildBinds

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/bug Categorizes issue or PR as related to a bug. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants