Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix gcloud retries cmd to rightly capture return code #45493

Merged
merged 2 commits into from
May 8, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions test/kubemark/gce/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
function run-gcloud-compute-with-retries {
RETRIES="${RETRIES:-3}"
for attempt in $(seq 1 ${RETRIES}); do
local -r gcloud_result=$(gcloud compute "$@" 2>&1)
local -r ret_val="$?"
# We don't use 'local' to declare gcloud_result as then ret_val always gets value 0.
gcloud_result=$(gcloud compute "$@" 2>&1) || local ret_val="$?"
echo "${gcloud_result}"
if [[ "${ret_val}" -ne "0" ]]; then
if [[ "${ret_val:-0}" -ne "0" ]]; then
if [[ $(echo "${gcloud_result}" | grep -c "already exists") -gt 0 ]]; then
if [[ "${attempt}" == 1 ]]; then
echo -e "${color_red}Failed to $1 $2 $3 as the resource hasn't been deleted from a previous run.${color_norm}" >& 2
Expand Down Expand Up @@ -78,6 +78,7 @@ function create-master-instance-with-resources {
--disk "name=${MASTER_NAME}-pd,device-name=master-pd,mode=rw,boot=no,auto-delete=no"

run-gcloud-compute-with-retries instances add-metadata "${MASTER_NAME}" \
${GCLOUD_COMMON_ARGS} \
--metadata-from-file startup-script="${KUBE_ROOT}/test/kubemark/resources/start-kubemark-master.sh"

if [ "${EVENT_PD:-false}" == "true" ]; then
Expand Down