Merge pull request #54071 from HubSpot/kube-build-parent-cgroup

Automatic merge from submit-queue (batch tested with PRs 54071, 58393). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Optionally launch build containers inside a specific parent cgroup

**What this PR does / why we need it**: Adds support to the build process for launching containers inside a specific parent cgroup via the `--cgroup-parent` docker arg. We needed this to enforce resource usage when building Kubernetes in our CI environment.

**Special notes for your reviewer**: None

**Release note**:

```release-note
NONE
```
This commit is contained in:
Kubernetes Submit Queue 2018-01-23 16:41:30 -08:00 committed by GitHub
commit 0d9e247aaa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -601,6 +601,11 @@ function kube::build::run_build_command_ex() {
--env "GOGCFLAGS=${GOGCFLAGS:-}"
)
if [[ -n "${DOCKER_CGROUP_PARENT:-}" ]]; then
kube::log::status "Using ${DOCKER_CGROUP_PARENT} as container cgroup parent"
docker_run_opts+=(--cgroup-parent "${DOCKER_CGROUP_PARENT}")
fi
# If we have stdin we can run interactive. This allows things like 'shell.sh'
# to work. However, if we run this way and don't have stdin, then it ends up
# running in a daemon-ish mode. So if we don't have a stdin, we explicitly