Skip to content
This repository was archived by the owner on Feb 14, 2023. It is now read-only.

Commit 8e6bf43

Browse files
Kauana dos SantosAlex Standke
Kauana dos Santos
and
Alex Standke
committed
add retries to push-apps
- sometimes it fails, seemingly because the cf isn't ready yet [#174366108](https://www.pivotaltracker.com/story/show/174366108) Co-authored-by: Alex Standke <[email protected]>
1 parent da3f11a commit 8e6bf43

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

ci/tasks/cf4k8s/push-app.sh

+23-7
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,43 @@ function target_cf() {
1414
local cf_domain=$(cat "${ROOT}/cf-install-values/cf-install-values.yml" | \
1515
grep system_domain | awk '{print $2}' | tr -d '"')
1616

17-
cf api --skip-ssl-validation "https://api.${cf_domain}"
17+
cf_with_retry api --skip-ssl-validation "https://api.${cf_domain}"
1818
local password=$(cat "${ROOT}/cf-install-values/cf-install-values.yml" | \
1919
grep cf_admin_password | awk '{print $2}')
20-
cf auth "admin" "${password}"
20+
cf_with_retry auth "admin" "${password}"
2121
}
2222

2323
function create_org_and_space() {
24-
cf create-org "${ORG_NAME}"
25-
cf create-space -o "${ORG_NAME}" "${SPACE_NAME}"
24+
cf_with_retry create-org "${ORG_NAME}"
25+
cf_with_retry create-space -o "${ORG_NAME}" "${SPACE_NAME}"
2626
}
2727

2828
function deploy_app() {
2929
local name="${1}"
30-
cf push "${name}" -o "cfrouting/httpbin" -i "${INSTANCES}"
30+
cf_with_retry push "${name}" -o "cfrouting/httpbin" -i "${INSTANCES}"
31+
}
32+
33+
function cf_with_retry() {
34+
cf_command=$*
35+
36+
set +euo pipefail
37+
38+
for i in {1..3}
39+
do
40+
echo "Running cf ${cf_command}..."
41+
cf $cf_command && set -euo pipefail && return
42+
sleep 10
43+
done
44+
45+
echo "cf_with_retry command has failed 3 times"
46+
exit
3147
}
3248

3349
function main() {
3450
target_cf
3551
create_org_and_space
36-
cf target -o "${ORG_NAME}" -s "${SPACE_NAME}"
37-
cf enable-feature-flag diego_docker
52+
cf_with_retry target -o "${ORG_NAME}" -s "${SPACE_NAME}"
53+
cf_with_retry enable-feature-flag diego_docker
3854
deploy_app "${APP_NAME}"
3955
}
4056

0 commit comments

Comments
 (0)