mfanjie / tips

0 stars 0 forks source link

kubernetes build with error of cannot allocate memory #6

Open mfanjie opened 8 years ago

mfanjie commented 8 years ago

make quick-release KUBE_RELEASE_RUN_TESTS=n build/release.sh +++ [0215 16:31:11] Verifying Prerequisites.... +++ [0215 16:31:11] No docker host is set. Checking options for setting one... +++ [0215 16:31:11] docker-machine was found. Host does not exist: "kube-dev" +++ [0215 16:31:11] Creating a machine to build Kubernetes Machine "kube-dev" is already running. build/../build/common.sh: line 178: DOCKER_MACHINE_NAME: readonly variable +++ [0215 16:32:04] A Docker host using docker-machine named 'kube-dev' is ready to go! You don't have a local copy of the golang:1.5.3 docker image. This image is 450MB. Download it now? [y/n] y

+++ [0215 16:32:08] Pulling docker image: golang:1.5.3 1.5.3: Pulling from library/golang dbacfa057b30: Pull complete 7a01cc5f27b1: Pull complete 3842411e5c4c: Pull complete d6fc4b5b4917: Pull complete 610726ff984a: Pull complete 4848229cb7ad: Pull complete dba29d279e3d: Pull complete 7092bf398df8: Pull complete 4539bbd9c182: Pull complete 6f86fa67be2a: Pull complete 108e13e4582b: Pull complete 0e5813b3a018: Pull complete 75f7c96e22b6: Pull complete 12057194b5fc: Pull complete Digest: sha256:d7d0d2c60393ae5b3315bfe0b4eb3770b460c276cdfb9dd32d69e03db159e00e Status: Downloaded newer image for golang:1.5.3 +++ [0215 16:39:06] Building Docker image kube-build:cross-1.5.3-1. +++ [0215 16:49:25] Building Docker image kube-build:build-b4a36a2a04. +++ [0215 16:51:42] Running build command.... +++ [0215 16:51:42] Creating data container +++ [0215 08:51:43] Multiple platforms requested, but available 0G < threshold 11G, building platforms in serial +++ [0215 08:51:43] Building go targets for linux/amd64: cmd/kube-proxy cmd/kube-apiserver cmd/kube-controller-manager cmd/kubelet cmd/kubemark cmd/hyperkube cmd/linkcheck plugin/cmd/kube-scheduler

k8s.io/kubernetes/cmd/kubelet

/usr/local/go/pkg/tool/linux_amd64/link: running gcc failed: fork/exec /usr/bin/gcc: cannot allocate memory

k8s.io/kubernetes/cmd/hyperkube

/usr/local/go/pkg/tool/linux_amd64/link: running gcc failed: fork/exec /usr/bin/gcc: cannot allocate memory

!!! Error in /go/src/k8s.io/kubernetes/hack/lib/golang.sh:395 'go install "${goflags[@]:+${goflags[@]}}" -ldflags "${goldflags}" "${nonstatics[@]:+${nonstatics[@]}}"' exited with status 2 Call stack: 1: /go/src/k8s.io/kubernetes/hack/lib/golang.sh:395 kube::golang::build_binaries_for_platform(...) 2: /go/src/k8s.io/kubernetes/hack/lib/golang.sh:536 kube::golang::build_binaries(...) 3: hack/build-cross.sh:28 main(...) Exiting with status 1 !!! Error in /go/src/k8s.io/kubernetes/hack/lib/golang.sh:457 '( kube::golang::setup_env; local host_platform; host_platform=$(kube::golang::host_platform); local goflags goldflags; eval "goflags=(${KUBE_GOFLAGS:-})"; goldflags="${KUBE_GOLDFLAGS:-} $(kube::version::ldflags)"; local use_go_build; local -a targets=(); local arg; for arg in "$@"; do if [[ "${arg}" == "--use_go_build" ]]; then use_go_build=true; else if [[ "${arg}" == -* ]]; then goflags+=("${arg}"); else targets+=("${arg}"); fi; fi; done; if [[ ${#targets[@]} -eq 0 ]]; then targets=("${KUBE_ALL_TARGETS[@]}"); fi; local -a platforms=("${KUBE_BUILD_PLATFORMS[@]:+${KUBE_BUILD_PLATFORMS[@]}}"); if [[ ${#platforms[@]} -eq 0 ]]; then platforms=("${host_platform}"); fi; local binaries; binaries=($(kube::golang::binaries_from_targets "${targets[@]}")); local parallel=false; if [[ ${#platforms[@]} -gt 1 ]]; then local gigs; gigs=$(kube::golang::get_physmem); if [[ ${gigs} -ge ${KUBE_PARALLEL_BUILD_MEMORY} ]]; then kube::log::status "Multiple platforms requested and available ${gigs}G >= threshold ${KUBE_PARALLEL_BUILD_MEMORY}G, building platforms in parallel"; parallel=true; else kube::log::status "Multiple platforms requested, but available ${gigs}G < threshold ${KUBE_PARALLEL_BUILD_MEMORY}G, building platforms in serial"; parallel=false; fi; fi; if [[ "${parallel}" == "true" ]]; then kube::log::status "Building go targets for ${platforms[@]} in parallel (output will appear in a burst when complete):" "${targets[@]}"; local platform; for platform in "${platforms[@]}"; do ( kube::golang::set_platform_envs "${platform}"; kube::log::status "${platform}: go build started"; kube::golang::build_binaries_for_platform ${platform} ${use_gobuild:-}; kube::log::status "${platform}: go build finished" ) &> "/tmp//${platform//\//}.build" & done; local fails=0; for job in $(jobs -p); do wait ${job} || let "fails+=1"; done; for platform in "${platforms[@]}"; do cat "/tmp//${platform//\//_}.build"; done; exit ${fails}; else for platform in "${platforms[@]}"; do kube::log::status "Building go targets for ${platform}:" "${targets[@]}"; kube::golang::set_platform_envs "${platform}"; kube::golang::build_binaries_for_platform ${platform} ${use_go_build:-}; done; fi )' exited with status 1 Call stack: 1: /go/src/k8s.io/kubernetes/hack/lib/golang.sh:457 kube::golang::build_binaries(...) 2: hack/build-cross.sh:28 main(...) Exiting with status 1 !!! Error in build/../build/common.sh:567 '"${docker_cmd[@]}" "$@"' exited with status 1 Call stack: 1: build/../build/common.sh:567 kube::build::run_build_command(...) 2: build/release.sh:32 main(...) Exiting with status 1 make: *\ [quick-release] Error 1

mfanjie commented 8 years ago

add virtualbox memory when create kube-dev machine by

  1. editing Vagrantfile docker-machine create --driver "${DOCKER_MACHINE_DRIVER}" \ --virtualbox-memory 6144 \ "${DOCKER_MACHINE_NAME}" > /dev/null || {
  2. stop kube-dev machine and change the memory of kube-dev VM on virtualbox console