build: move some of hack/lib/ into a new cluster/lib/

Some functionality in hack/lib is currently depended on by
cluster/common.sh so kube-up from the full release tar (which
does not include hack/) is currently broken. With this PR we
create cluster/lib/ and move the necessary bits from hack/
over to get kube-up working again.

Fixes: 96d1b8d1b2
Signed-off-by: Mike Danese <mikedanese@google.com>
pull/6/head
Mike Danese 2016-01-11 15:23:21 -08:00
parent 651206fd90
commit 22cfa5ea7e
8 changed files with 42 additions and 34 deletions

View File

@ -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

View File

@ -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

27
cluster/lib/util.sh Normal file
View File

@ -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}
}

View File

@ -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

View File

@ -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() {

View File

@ -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" \

View File

@ -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