Set shell options for reliability.

Tweak a few other small things in our shell scripts.
This commit is contained in:
Joe Beda
2014-10-06 13:25:27 -07:00
parent d43a6ec5a3
commit 96c1bc17ca
37 changed files with 304 additions and 198 deletions

View File

@@ -14,6 +14,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
set -e
set -o errexit
set -o nounset
set -o pipefail
KUBE_COVER=" " KUBE_RACE=" " hack/test-go.sh "" -test.run="^X" -benchtime=1s -bench=. -benchmem
KUBE_COVER=" " KUBE_RACE=" " hack/test-go.sh "" -test.run="^X" -benchtime=1s -bench=. -benchmem

View File

@@ -199,6 +199,7 @@ export KUBE_GO_PACKAGE
set -o errexit
set -o nounset
set -o pipefail
go_pkg_dir="${KUBE_TARGET}/src/${KUBE_GO_PACKAGE}"
go_pkg_basedir=$(dirname "${go_pkg_dir}")
mkdir -p "${go_pkg_basedir}"

View File

@@ -16,6 +16,10 @@
# This script will build a dev release and push it to an existing cluster.
set -o errexit
set -o nounset
set -o pipefail
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
# Build a release

View File

@@ -17,7 +17,9 @@
# This script will build a dev release and bring up a new cluster with that
# release.
set -e
set -o errexit
set -o nounset
set -o pipefail
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..

View File

@@ -17,9 +17,11 @@
# Launches an nginx container and verifies it can be reached. Assumes that
# we're being called by hack/e2e-test.sh (we use some env vars it sets up).
# Exit on error
set -e
set -o errexit
set -o nounset
set -o pipefail
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../..
source "${KUBE_ROOT}/cluster/kube-env.sh"
source "${KUBE_ROOT}/cluster/$KUBERNETES_PROVIDER/util.sh"
@@ -41,17 +43,17 @@ function teardown() {
trap "teardown" EXIT
POD_ID_LIST=$($KUBECFG '-template={{range.Items}}{{.ID}} {{end}}' -l replicationController=myNginx list pods)
pod_id_list=$($KUBECFG '-template={{range.Items}}{{.ID}} {{end}}' -l replicationController=myNginx list pods)
# Container turn up on a clean cluster can take a while for the docker image pull.
ALL_RUNNING=0
while [ $ALL_RUNNING -ne 1 ]; do
all_running=0
while [[ $all_running -ne 1 ]]; do
echo "Waiting for all containers in pod to come up."
sleep 5
ALL_RUNNING=1
for id in $POD_ID_LIST; do
CURRENT_STATUS=$($KUBECFG -template '{{and .CurrentState.Info.mynginx.State.Running .CurrentState.Info.net.State.Running}}' get pods/$id)
if [ "$CURRENT_STATUS" != "{0001-01-01 00:00:00 +0000 UTC}" ]; then
ALL_RUNNING=0
all_running=1
for id in $pod_id_list; do
current_status=$($KUBECFG -template '{{and .CurrentState.Info.mynginx.State.Running .CurrentState.Info.net.State.Running}}' get pods/$id) || true
if [[ "$current_status" != "{0001-01-01 00:00:00 +0000 UTC}" ]]; then
all_running=0
fi
done
done
@@ -65,9 +67,9 @@ sleep 5
# Verify that something is listening (nginx should give us a 404)
for (( i=0; i<${#KUBE_MINION_IP_ADDRESSES[@]}; i++)); do
IP_ADDRESS=${KUBE_MINION_IP_ADDRESSES[$i]}
echo "Trying to reach nginx instance that should be running at ${IP_ADDRESS}:8080..."
curl "http://${IP_ADDRESS}:8080"
ip_address=${KUBE_MINION_IP_ADDRESSES[$i]}
echo "Trying to reach nginx instance that should be running at ${ip_address}:8080..."
curl "http://${ip_address}:8080"
done
exit 0

View File

@@ -18,8 +18,11 @@
# works. Assumes that we're being called by hack/e2e-test.sh (we use some env
# vars it sets up).
set -e
set -o errexit
set -o nounset
set -o pipefail
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../..
source "${KUBE_ROOT}/cluster/kube-env.sh"
source "${KUBE_ROOT}/cluster/$KUBERNETES_PROVIDER/util.sh"

View File

@@ -20,6 +20,7 @@ set -o errexit
set -o nounset
set -o pipefail
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../..
source "${KUBE_ROOT}/cluster/kube-env.sh"
source "${KUBE_ROOT}/cluster/$KUBERNETES_PROVIDER/util.sh"

View File

@@ -17,6 +17,10 @@
# Starts a Kubernetes cluster, runs the e2e test suite, and shuts it
# down.
set -o errexit
set -o nounset
set -o pipefail
# Use testing config
export KUBE_CONFIG_FILE="config-test.sh"
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
@@ -34,9 +38,6 @@ ALREADY_UP=${1:-0}
LEAVE_UP=${2:-0}
TEAR_DOWN=${3:-0}
# Exit on error
set -e
if [[ $TEAR_DOWN -ne 0 ]]; then
detect-project
trap test-teardown EXIT

View File

@@ -14,9 +14,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
set -o errexit
set -o nounset
set -o pipefail
cd third_party
git clone https://github.com/coreos/etcd.git
cd etcd
git checkout ab4bcc18694644d12f0c038339d8d039072502b1
git checkout ab4bcc18694644d12f0c038339d8d039072502b1
./build

View File

@@ -16,7 +16,9 @@
# This script installs std -race on Travis (see https://code.google.com/p/go/issues/detail?id=6479)
set -e
set -o errexit
set -o nounset
set -o pipefail
if [ "${TRAVIS}" == "true" ]; then
GO_VERSION=($(go version))

View File

@@ -17,18 +17,21 @@
# This command checks that the built commands can function together for
# simple scenarios. It does not require Docker so it can run in travis.
set -o errexit
set -o nounset
set -o pipefail
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
source "${KUBE_ROOT}/hack/util.sh"
source "${KUBE_ROOT}/hack/config-go.sh"
function cleanup()
{
set +e
kill ${APISERVER_PID} 1>&2 2>/dev/null
kill ${CTLRMGR_PID} 1>&2 2>/dev/null
kill ${KUBELET_PID} 1>&2 2>/dev/null
kill ${PROXY_PID} 1>&2 2>/dev/null
kill ${ETCD_PID} 1>&2 2>/dev/null
[[ -n ${APISERVER_PID-} ]] && kill ${APISERVER_PID} 1>&2 2>/dev/null
[[ -n ${CTLRMGR_PID-} ]] && kill ${CTLRMGR_PID} 1>&2 2>/dev/null
[[ -n ${KUBELET_PID-} ]] && kill ${KUBELET_PID} 1>&2 2>/dev/null
[[ -n ${PROXY_PID-} ]] && kill ${PROXY_PID} 1>&2 2>/dev/null
[[ -n ${ETCD_PID-} ]] && kill ${ETCD_PID} 1>&2 2>/dev/null
rm -rf ${ETCD_DIR} 1>&2 2>/dev/null
echo
echo "Complete"

View File

@@ -14,8 +14,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
set -e
set -o errexit
set -o nounset
set -o pipefail
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
source "${KUBE_ROOT}/hack/config-go.sh"
@@ -138,7 +139,7 @@ if [[ "${iterations}" -gt 1 ]]; then
fi
fi
if [[ -n "$1" ]]; then
if [[ -n "${1-}" ]]; then
covdir="/tmp/k8s_coverage/$(date "+%s")"
echo saving coverage output in "${covdir}"
for arg; do

View File

@@ -14,6 +14,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
set -o errexit
set -o nounset
set -o pipefail
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
result=0

View File

@@ -16,6 +16,11 @@
# GoFmt apparently is changing @ head...
set -o errexit
set -o nounset
set -o pipefail
GO_VERSION=($(go version))
if [[ -z $(echo "${GO_VERSION[2]}" | grep -E 'go1.2|go1.3') ]]; then