Skip to content

Commit

Permalink
Merge pull request kubernetes#25052 from ixdy/build-image-name-in-docker
Browse files Browse the repository at this point in the history
Automatic merge from submit-queue

Use HOSTNAME in Docker build image tag hash

Fixes kubernetes#24661 by including `$HOSTNAME` when generating the build image tag hash.

When running the verification checks under Docker, the `$KUBE_ROOT` will be identical across builds, so tags will collide unless we add additional uniqueness. By default, the hostname inside a Docker container is its ID, which should be unique enough for us.

I also deleted a misleading error message from the same check.

@kubernetes/sig-testing
  • Loading branch information
k8s-merge-robot committed May 3, 2016
2 parents 9ded9cd + 83ac3ea commit f29d597
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ function kube::build::verify_prereqs() {
fi
kube::build::ensure_docker_daemon_connectivity || return 1

KUBE_ROOT_HASH=$(kube::build::short_hash "$KUBE_ROOT")
KUBE_ROOT_HASH=$(kube::build::short_hash "${HOSTNAME:-}:${KUBE_ROOT}")
KUBE_BUILD_IMAGE_TAG="build-${KUBE_ROOT_HASH}"
KUBE_BUILD_IMAGE="${KUBE_BUILD_IMAGE_REPO}:${KUBE_BUILD_IMAGE_TAG}"
KUBE_BUILD_CONTAINER_NAME="kube-build-${KUBE_ROOT_HASH}"
Expand Down
10 changes: 6 additions & 4 deletions hack/after-build/verify-generated-protobuf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@ for APIROOT in ${APIROOTS}; do
cp -a "${KUBE_ROOT}/${APIROOT}" "${_tmp}/${APIROOT}"
done

# We would like to use "sudo" when running on Travis and
# not use "sudo" when running on Jenkins.
SUDO="sudo"
sudo -h > /dev/null || SUDO=""
# If not running as root, we need to use sudo to restore the original generated
# protobuf files.
SUDO=""
if [[ "$(id -u)" != '0' ]]; then
SUDO="sudo"
fi

"${KUBE_ROOT}/hack/update-generated-protobuf.sh"
for APIROOT in ${APIROOTS}; do
Expand Down
2 changes: 1 addition & 1 deletion hack/update-generated-protobuf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function prereqs() {
fi
kube::build::ensure_docker_daemon_connectivity || return 1

KUBE_ROOT_HASH=$(kube::build::short_hash "$KUBE_ROOT/go-to-protobuf")
KUBE_ROOT_HASH=$(kube::build::short_hash "${HOSTNAME:-}:${REPO_DIR:-${KUBE_ROOT}}/go-to-protobuf")
KUBE_BUILD_IMAGE_TAG="build-${KUBE_ROOT_HASH}"
KUBE_BUILD_IMAGE="${KUBE_BUILD_IMAGE_REPO}:${KUBE_BUILD_IMAGE_TAG}"
KUBE_BUILD_CONTAINER_NAME="kube-build-${KUBE_ROOT_HASH}"
Expand Down

0 comments on commit f29d597

Please sign in to comment.