From e26ac52a99b9eb9a90a3a9a4f9806ab5d0be9cc0 Mon Sep 17 00:00:00 2001 From: Bowei Du Date: Sat, 16 Jun 2018 14:57:12 -0400 Subject: [PATCH] Retry on getting PROJECT, dump out project resources Retry on metadata curl with explicit error out if it cannot be contacted. Capture more information about the project resources so it is easier to do post-mortem debugging. --- cmd/e2e-test/run.sh | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/cmd/e2e-test/run.sh b/cmd/e2e-test/run.sh index f99d04b4ce..f773f1d379 100755 --- a/cmd/e2e-test/run.sh +++ b/cmd/e2e-test/run.sh @@ -16,12 +16,41 @@ # run.sh manages the settings required for running containerized in a # Kubernetes cluster. - echo '--- BEGIN ---' -PROJECT=$(curl -H'Metadata-Flavor:Google' metadata.google.internal/computeMetadata/v1/project/project-id 2>/dev/null) +for ATTEMPT in $(seq 60); do + PROJECT=$(curl -H'Metadata-Flavor:Google' metadata.google.internal/computeMetadata/v1/project/project-id 2>/dev/null) + if [[ -n "$PROJECT" ]]; then + break + fi + echo "Warning: could not get Compute project name from the metadata server (attempt ${ATTEMPT})" + sleep 1 +done + +if [[ -z "$PROJECT" ]]; then + echo "Error: could not get Compute project name from the metadata server" + exit 1 +fi + +echo +echo ============================================================================== echo "PROJECT: ${PROJECT}" CMD="/e2e-test -test.v -test.parallel=10 -run -project ${PROJECT} -logtostderr -inCluster -v=2" echo "CMD: ${CMD}" $@ +echo + +echo ============================================================================== +echo E2E TEST +echo ${CMD} "$@" 2>&1 +echo + +RESOURCES="forwarding-rules target-http-proxies target-https-proxies url-maps backend-services" +for RES in ${RESOURCES}; do + echo ============================================================================== + echo "GCP RESOURCE: ${RES}" + gcloud compute ${RES} list --project ${PROJECT} --format yaml +done + +echo ============================================================================== echo "RESULT: $?" echo '--- END ---'