diff --git a/cluster/common.sh b/cluster/common.sh index 39a62965e0..f3553fafa2 100755 --- a/cluster/common.sh +++ b/cluster/common.sh @@ -24,8 +24,8 @@ KUBE_ROOT=$(dirname "${BASH_SOURCE}")/.. DEFAULT_KUBECONFIG="${HOME}/.kube/config" -source "${KUBE_ROOT}/hack/lib/util.sh" -source "${KUBE_ROOT}/hack/lib/logging.sh" +source "${KUBE_ROOT}/cluster/lib/util.sh" +source "${KUBE_ROOT}/cluster/lib/logging.sh" # KUBE_RELEASE_VERSION_REGEX matches things like "v1.2.3" or "v1.2.3-alpha.4" # # NOTE This must match the version_regex in build/common.sh diff --git a/cluster/gce/util.sh b/cluster/gce/util.sh index febdd71ee4..f57f953e59 100755 --- a/cluster/gce/util.sh +++ b/cluster/gce/util.sh @@ -21,6 +21,7 @@ KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../.. source "${KUBE_ROOT}/cluster/gce/${KUBE_CONFIG_FILE-"config-default.sh"}" source "${KUBE_ROOT}/cluster/common.sh" +source "${KUBE_ROOT}/cluster/lib/util.sh" if [[ "${OS_DISTRIBUTION}" == "debian" || "${OS_DISTRIBUTION}" == "coreos" || "${OS_DISTRIBUTION}" == "trusty" ]]; then source "${KUBE_ROOT}/cluster/gce/${OS_DISTRIBUTION}/helper.sh" @@ -301,21 +302,6 @@ function detect-master () { echo "Using master: $KUBE_MASTER (external IP: $KUBE_MASTER_IP)" } -# Wait for background jobs to finish. Exit with -# an error status if any of the jobs failed. -function wait-for-jobs { - local fail=0 - local job - for job in $(jobs -p); do - wait "${job}" || fail=$((fail + 1)) - done - if (( fail != 0 )); then - echo -e "${color_red}${fail} commands failed. Exiting.${color_norm}" >&2 - # Ignore failures for now. - # exit 2 - fi -} - # Robustly try to create a static ip. # $1: The name of the ip to create # $2: The name of the region to create the ip in. @@ -687,7 +673,9 @@ function kube-up { fi # Wait for last batch of jobs - wait-for-jobs + kube::util::wait-for-jobs || { + echo -e "${color_red}${fail} commands failed.${color_norm}" >&2 + } echo "Creating minions." @@ -1192,7 +1180,10 @@ function kube-push { for (( i=0; i<${#NODE_NAMES[@]}; i++)); do push-node "${NODE_NAMES[$i]}" & done - wait-for-jobs + + kube::util::wait-for-jobs || { + echo -e "${color_red}${fail} commands failed.${color_norm}" >&2 + } # TODO(zmerlynn): Re-create instance-template with the new # node-kube-env. This isn't important until the node-ip-range issue diff --git a/hack/lib/logging.sh b/cluster/lib/logging.sh similarity index 100% rename from hack/lib/logging.sh rename to cluster/lib/logging.sh diff --git a/cluster/lib/util.sh b/cluster/lib/util.sh new file mode 100644 index 0000000000..decfa81160 --- /dev/null +++ b/cluster/lib/util.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +# Copyright 2015 The Kubernetes Authors All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Wait for background jobs to finish. Return with +# an error status if any of the jobs failed. +kube::util::wait-for-jobs() { + local fail=0 + local job + for job in $(jobs -p); do + wait "${job}" || fail=$((fail + 1)) + done + return ${fail} +} + diff --git a/hack/lib/init.sh b/hack/lib/init.sh index 7077f77766..9fa47ca2df 100644 --- a/hack/lib/init.sh +++ b/hack/lib/init.sh @@ -31,7 +31,8 @@ KUBE_OUTPUT="${KUBE_ROOT}/${KUBE_OUTPUT_SUBPATH}" KUBE_OUTPUT_BINPATH="${KUBE_OUTPUT}/bin" source "${KUBE_ROOT}/hack/lib/util.sh" -source "${KUBE_ROOT}/hack/lib/logging.sh" +source "${KUBE_ROOT}/cluster/lib/util.sh" +source "${KUBE_ROOT}/cluster/lib/logging.sh" kube::log::install_errexit diff --git a/hack/lib/util.sh b/hack/lib/util.sh index 993e5d9cb6..00179f888e 100755 --- a/hack/lib/util.sh +++ b/hack/lib/util.sh @@ -176,17 +176,6 @@ kube::util::find-binary() { echo -n "${bin}" } -# Wait for background jobs to finish. Return with -# an error status if any of the jobs failed. -kube::util::wait-for-jobs() { - local fail=0 - local job - for job in $(jobs -p); do - wait "${job}" || fail=$((fail + 1)) - done - return ${fail} -} - # Run all known doc generators (today gendocs, genman, and genbashcomp for kubectl) # $1 is the directory to put those generated documents kube::util::gen-docs() { diff --git a/hack/verify-flags/exceptions.txt b/hack/verify-flags/exceptions.txt index 1c89e96417..ce896116df 100644 --- a/hack/verify-flags/exceptions.txt +++ b/hack/verify-flags/exceptions.txt @@ -84,8 +84,8 @@ hack/jenkins/update-jobs.sh: docker cp jenkins_jobs.ini job-builder:/etc/jenk hack/jenkins/update-jobs.sh: echo "jenkins_jobs.ini not found in workspace" >&2 hack/jenkins/update-jobs.sh: # jenkins_jobs.ini contains administrative credentials for Jenkins. hack/jenkins/update-jobs.sh: if [[ -e jenkins_jobs.ini ]]; then -hack/lib/logging.sh: local source_file=${BASH_SOURCE[$frame_no]} -hack/lib/logging.sh: local source_file=${BASH_SOURCE[$stack_skip]} +cluster/lib/logging.sh: local source_file=${BASH_SOURCE[$frame_no]} +cluster/lib/logging.sh: local source_file=${BASH_SOURCE[$stack_skip]} hack/local-up-cluster.sh: runtime_config="--runtime-config=${RUNTIME_CONFIG}" hack/local-up-cluster.sh: runtime_config="" hack/test-cmd.sh: --runtime_config="extensions/v1beta1/deployments=true" \ diff --git a/test/component/scheduler/perf/test-performance.sh b/test/component/scheduler/perf/test-performance.sh index 50257ecb12..c8c8a4b39a 100755 --- a/test/component/scheduler/perf/test-performance.sh +++ b/test/component/scheduler/perf/test-performance.sh @@ -20,7 +20,7 @@ set -o pipefail pushd "../../../.." source "./hack/lib/util.sh" -source "./hack/lib/logging.sh" +source "./cluster/lib/logging.sh" source "./hack/lib/etcd.sh" popd