From b9e060a6303577d263c896976691d1bd1a343d86 Mon Sep 17 00:00:00 2001 From: Jeff Grafton Date: Fri, 13 Jan 2017 14:49:38 -0800 Subject: [PATCH] Update scripts to look for binary artifacts in bazel-bin/ --- cluster/common.sh | 52 ++++++++++++++++++++++++---------------------- cluster/kubeadm.sh | 1 + cluster/kubectl.sh | 1 + hack/lib/util.sh | 9 +++++++- 4 files changed, 37 insertions(+), 26 deletions(-) diff --git a/cluster/common.sh b/cluster/common.sh index c6b89ea67d859..72e986ee1655c 100755 --- a/cluster/common.sh +++ b/cluster/common.sh @@ -412,6 +412,30 @@ function tars_from_version() { fi } +# Search for the specified tarball in the various known output locations, +# echoing the location if found. +# +# Assumed vars: +# KUBE_ROOT +# +# Args: +# $1 name of tarball to search for +function find-tar() { + local -r tarball=$1 + locations=( + "${KUBE_ROOT}/server/${tarball}" + "${KUBE_ROOT}/_output/release-tars/${tarball}" + "${KUBE_ROOT}/bazel-bin/build/release-tars/${tarball}" + ) + location=$( (ls -t "${locations[@]}" 2>/dev/null || true) | head -1 ) + + if [[ ! -f "${location}" ]]; then + echo "!!! Cannot find ${tarball}" >&2 + exit 1 + fi + echo "${location}" +} + # Verify and find the various tar files that we are going to use on the server. # # Assumed vars: @@ -421,36 +445,14 @@ function tars_from_version() { # SALT_TAR # KUBE_MANIFESTS_TAR function find-release-tars() { - SERVER_BINARY_TAR="${KUBE_ROOT}/server/kubernetes-server-linux-amd64.tar.gz" - if [[ ! -f "${SERVER_BINARY_TAR}" ]]; then - SERVER_BINARY_TAR="${KUBE_ROOT}/_output/release-tars/kubernetes-server-linux-amd64.tar.gz" - fi - if [[ ! -f "${SERVER_BINARY_TAR}" ]]; then - echo "!!! Cannot find kubernetes-server-linux-amd64.tar.gz" >&2 - exit 1 - fi - - SALT_TAR="${KUBE_ROOT}/server/kubernetes-salt.tar.gz" - if [[ ! -f "${SALT_TAR}" ]]; then - SALT_TAR="${KUBE_ROOT}/_output/release-tars/kubernetes-salt.tar.gz" - fi - if [[ ! -f "${SALT_TAR}" ]]; then - echo "!!! Cannot find kubernetes-salt.tar.gz" >&2 - exit 1 - fi + SERVER_BINARY_TAR=$(find-tar kubernetes-server-linux-amd64.tar.gz) + SALT_TAR=$(find-tar kubernetes-salt.tar.gz) # This tarball is used by GCI, Ubuntu Trusty, and Container Linux. KUBE_MANIFESTS_TAR= if [[ "${MASTER_OS_DISTRIBUTION:-}" == "trusty" || "${MASTER_OS_DISTRIBUTION:-}" == "gci" || "${MASTER_OS_DISTRIBUTION:-}" == "container-linux" ]] || \ [[ "${NODE_OS_DISTRIBUTION:-}" == "trusty" || "${NODE_OS_DISTRIBUTION:-}" == "gci" || "${NODE_OS_DISTRIBUTION:-}" == "container-linux" ]] ; then - KUBE_MANIFESTS_TAR="${KUBE_ROOT}/server/kubernetes-manifests.tar.gz" - if [[ ! -f "${KUBE_MANIFESTS_TAR}" ]]; then - KUBE_MANIFESTS_TAR="${KUBE_ROOT}/_output/release-tars/kubernetes-manifests.tar.gz" - fi - if [[ ! -f "${KUBE_MANIFESTS_TAR}" ]]; then - echo "!!! Cannot find kubernetes-manifests.tar.gz" >&2 - exit 1 - fi + KUBE_MANIFESTS_TAR=$(find-tar kubernetes-manifests.tar.gz) fi } diff --git a/cluster/kubeadm.sh b/cluster/kubeadm.sh index 557cb10b90c6d..54cfb3d3dc539 100755 --- a/cluster/kubeadm.sh +++ b/cluster/kubeadm.sh @@ -76,6 +76,7 @@ if [[ -z "${KUBEADM_PATH:-}" ]]; then "${KUBE_ROOT}/_output/bin/kubeadm" "${KUBE_ROOT}/_output/dockerized/bin/${host_os}/${host_arch}/kubeadm" "${KUBE_ROOT}/_output/local/bin/${host_os}/${host_arch}/kubeadm" + "${KUBE_ROOT}/bazel-bin/cmd/kubectl/kubeadm" "${KUBE_ROOT}/platforms/${host_os}/${host_arch}/kubeadm" ) kubeadm=$( (ls -t "${locations[@]}" 2>/dev/null || true) | head -1 ) diff --git a/cluster/kubectl.sh b/cluster/kubectl.sh index 7c37f28f83564..2e0c3c4de556b 100755 --- a/cluster/kubectl.sh +++ b/cluster/kubectl.sh @@ -88,6 +88,7 @@ if [[ -z "${KUBECTL_PATH:-}" ]]; then "${KUBE_ROOT}/_output/bin/kubectl" "${KUBE_ROOT}/_output/dockerized/bin/${host_os}/${host_arch}/kubectl" "${KUBE_ROOT}/_output/local/bin/${host_os}/${host_arch}/kubectl" + "${KUBE_ROOT}/bazel-bin/cmd/kubectl/kubectl" "${KUBE_ROOT}/platforms/${host_os}/${host_arch}/kubectl" ) kubectl=$( (ls -t "${locations[@]}" 2>/dev/null || true) | head -1 ) diff --git a/hack/lib/util.sh b/hack/lib/util.sh index e6cada20eca21..976888591447b 100755 --- a/hack/lib/util.sh +++ b/hack/lib/util.sh @@ -167,12 +167,19 @@ kube::util::host_platform() { kube::util::find-binary-for-platform() { local -r lookfor="$1" local -r platform="$2" - local -r locations=( + local locations=( "${KUBE_ROOT}/_output/bin/${lookfor}" "${KUBE_ROOT}/_output/dockerized/bin/${platform}/${lookfor}" "${KUBE_ROOT}/_output/local/bin/${platform}/${lookfor}" "${KUBE_ROOT}/platforms/${platform}/${lookfor}" ) + # Also search for binary in bazel build tree. + # In some cases we have to name the binary $BINARY_bin, since there was a + # directory named $BINARY next to it. + locations+=($(find "${KUBE_ROOT}/bazel-bin/" -type f -executable \ + \( -name "${lookfor}" -o -name "${lookfor}_bin" \) 2>/dev/null || true) ) + + # List most recently-updated location. local -r bin=$( (ls -t "${locations[@]}" 2>/dev/null || true) | head -1 ) echo -n "${bin}" }