Skip to content

Commit

Permalink
Update scripts to look for binary artifacts in bazel-bin/
Browse files Browse the repository at this point in the history
  • Loading branch information
ixdy committed Jan 14, 2017
1 parent bc4b6ac commit b9e060a
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 26 deletions.
52 changes: 27 additions & 25 deletions cluster/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
}

Expand Down
1 change: 1 addition & 0 deletions cluster/kubeadm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down
1 change: 1 addition & 0 deletions cluster/kubectl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down
9 changes: 8 additions & 1 deletion hack/lib/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
}
Expand Down

0 comments on commit b9e060a

Please sign in to comment.