summaryrefslogtreecommitdiffhomepage
path: root/tools/images
diff options
context:
space:
mode:
authorZach Koopmans <zkoopmans@google.com>2020-03-30 10:43:31 -0700
committergVisor bot <gvisor-bot@google.com>2020-03-30 10:44:55 -0700
commit4aee3706406d6b102540ad5bea272b7c893da827 (patch)
tree3fb159987149d9daf153a8f7af03f5b6a6757817 /tools/images
parent1876f10e150a89b871e0d9a15d627f88aba1ddd2 (diff)
Internal change.
PiperOrigin-RevId: 303773475
Diffstat (limited to 'tools/images')
-rwxr-xr-xtools/images/build.sh9
1 files changed, 7 insertions, 2 deletions
diff --git a/tools/images/build.sh b/tools/images/build.sh
index be462d556..f89f39cbd 100755
--- a/tools/images/build.sh
+++ b/tools/images/build.sh
@@ -63,13 +63,18 @@ trap cleanup EXIT
# Wait for the instance to become available (up to 5 minutes).
declare timeout=300
declare success=0
+declare internal=""
declare -r start=$(date +%s)
declare -r end=$((${start}+${timeout}))
while [[ "$(date +%s)" -lt "${end}" ]] && [[ "${success}" -lt 3 ]]; do
- if gcloud compute ssh --zone "${ZONE}" "${USERNAME}"@"${INSTANCE_NAME}" -- env - true 2>/dev/null; then
+ if gcloud compute ssh --zone "${internal}" "${ZONE}" "${USERNAME}"@"${INSTANCE_NAME}" -- env - true 2>/dev/null; then
success=$((${success}+1))
+ elif gcloud compute ssh --zone --internal-ip "${ZONE}" "${USERNAME}"@"${INSTANCE_NAME}" -- env - true 2>/dev/null; then
+ success=$((${success}+1))
+ internal="--internal-ip"
fi
done
+
if [[ "${success}" -eq "0" ]]; then
echo "connect timed out after ${timeout} seconds."
exit 1
@@ -77,7 +82,7 @@ fi
# Run the install scripts provided.
for arg; do
- gcloud compute ssh --zone "${ZONE}" "${USERNAME}"@"${INSTANCE_NAME}" -- sudo bash - <"${arg}" >/dev/null
+ gcloud compute ssh --zone "${internal}" "${ZONE}" "${USERNAME}"@"${INSTANCE_NAME}" -- sudo bash - <"${arg}" >/dev/null
done
# Stop the instance; required before creating an image.