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

set cgroup parent on build child containers #14688

Merged
merged 2 commits into from
Jun 16, 2017

Conversation

bparees
Copy link
Contributor

@bparees bparees commented Jun 15, 2017

No description provided.

@bparees
Copy link
Contributor Author

bparees commented Jun 15, 2017

builds on top of openshift/source-to-image#756

@bparees
Copy link
Contributor Author

bparees commented Jun 15, 2017

need to do the s2i bump here once the PR(openshift/source-to-image#756) merges, but @csrwng @derekwaynecarr @smarterclayton ptal.

@@ -130,6 +130,10 @@ func execPostCommitHook(client DockerClient, postCommitSpec api.BuildPostCommitS
if err != nil {
return fmt.Errorf("read cgroup limits: %v", err)
}
parent, err := GetCgroupParent()
Copy link
Contributor

Choose a reason for hiding this comment

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

Starting in 3.6, there's no case where this could fail? I.e. all systems with cgroups we'd run origin on will work?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that seems like a question for @derekwaynecarr

if there are systems where we can read the cpu/memory(which we do require today), but can't do this to read the cgroup parent, that's something only he can probably answer.


// GetCgroupParent determines the parent cgroup for a container from
// within that container.
func GetCgroupParent() (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.

nit ... does this need to be public?

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, will change. I initially had grander visions for it.


// GetCgroupParent determines the parent cgroup for a container from
// within that container.
func GetCgroupParent() (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.

could use a unit test

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added

// non-systemd, take everything except the last segment.
cgroupParent = strings.Join(parts[:len(parts)-1], "/")
}
glog.V(5).Infof("running docker build under cgroup parent %v", cgroupParent)
Copy link
Contributor

Choose a reason for hiding this comment

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

return value?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sigh. yes :)

@bparees
Copy link
Contributor Author

bparees commented Jun 15, 2017

[testextended][extended:core(build with a quota)]

@bparees bparees force-pushed the cgroup_parents branch 2 times, most recently from 8d70ec6 to a671b39 Compare June 15, 2017 23:00
@bparees
Copy link
Contributor Author

bparees commented Jun 15, 2017

unit test added.

@bparees
Copy link
Contributor Author

bparees commented Jun 15, 2017

since the discussion was hidden by new commits...there's an open question here:

Starting in 3.6, there's no case where this could fail? I.e. all systems with cgroups we'd run origin on will work?

if there are systems where we can read the cpu/memory(which we do require today), but can't do this to read the cgroup parent, that's something only @derekwaynecarr can probably answer.

I could certainly change the logic to just punt on setting the cgroup parent if we get an error...that would make it robust but leave us open to running builds w/ no cpu limits (since we're no longer explicitly setting those limits w/ this PR).

@smarterclayton
Copy link
Contributor

smarterclayton commented Jun 16, 2017 via email

@smarterclayton
Copy link
Contributor

smarterclayton commented Jun 16, 2017 via email

@derekwaynecarr
Copy link
Member

LGTM

@sjenning - be aware of what the builds are doing when they launch their own containers in the pod level cgroup for your cpu pinning work. as i discussed with @bparees , i am not sure we can support them if a kubelet has static cpu pinning enabled as we will not know about their container to move it on/off an exclusive core.

@bparees
Copy link
Contributor Author

bparees commented Jun 16, 2017

I much prefer to fail closed

i figured, just throwing it out there.

Might be a good idea to have some verify on an ubuntu system

I spun up an ubuntu ec2 instance and poked around. it was using systemd, but docker was not using systemd cgroups. When i looked at the /proc/self/cgroup value I saw what @derekwaynecarr had predicted and what this code looks for: values that don't end in ".scope".

What i have not done is validate that the value this code extracts in that case, is indeed the correct value for the parent cgroup on that system. I can try to get this running in an ubuntu machine tomorrow if we need that level of additional validation.

@csrwng
Copy link
Contributor

csrwng commented Jun 16, 2017

LGTM

@derekwaynecarr
Copy link
Member

derekwaynecarr commented Jun 16, 2017 via email

@bparees
Copy link
Contributor Author

bparees commented Jun 16, 2017

@bparees - it looked like your test case covered that, no?

@derekwaynecarr my unit test covers the parsing of the content, but i haven't actually confirmed that the value it parses out, actually works when used as the cgroup parent value (on a non-systemd system).

@bparees
Copy link
Contributor Author

bparees commented Jun 16, 2017

ok I exercised this fully on ubuntu w/ Cgroup Driver: cgroupfs

[merge]

@openshift-bot
Copy link
Contributor

Evaluated for origin testextended up to 16f5632

@openshift-bot
Copy link
Contributor

openshift-bot commented Jun 16, 2017

continuous-integration/openshift-jenkins/merge Waiting: You are in the build queue at position: 14

@openshift-bot
Copy link
Contributor

Evaluated for origin merge up to 16f5632

@openshift-bot
Copy link
Contributor

[Test]ing while waiting on the merge queue

@openshift-bot
Copy link
Contributor

Evaluated for origin test up to 16f5632

@openshift-bot
Copy link
Contributor

continuous-integration/openshift-jenkins/testextended SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_request_origin_extended/641/) (Base Commit: d40783e) (PR Branch Commit: 16f5632) (Extended Tests: core(build with a quota))

@openshift-bot
Copy link
Contributor

continuous-integration/openshift-jenkins/test SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_request_origin/2329/) (Base Commit: d40783e) (PR Branch Commit: 16f5632)

@smarterclayton smarterclayton merged commit aeb4f30 into openshift:master Jun 16, 2017
// getCgroupParent determines the parent cgroup for a container from
// within that container.
func getCgroupParent() (string, error) {
cgMap, err := cgroups.ParseCgroupFile("/proc/self/cgroup")
Copy link
Contributor

@liggitt liggitt Jun 17, 2017

Choose a reason for hiding this comment

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

this function only exists on linux

$ make
hack/build-go.sh  
++ Building go targets for darwin/amd64: cmd/openshift cmd/oc cmd/kubefed
# github.com/openshift/origin/pkg/build/builder
pkg/build/builder/util.go:180: undefined: cgroups.ParseCgroupFile

Copy link
Contributor Author

Choose a reason for hiding this comment

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

well it will only run inside a linux container so that's ok but i'm not sure what we do about the cross-compile build process. I assume this isn't the first instance of something like this.

Copy link
Contributor

Choose a reason for hiding this comment

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

opened #14717

@bparees bparees deleted the cgroup_parents branch June 19, 2017 14:32
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.

6 participants