Skip to content

Commit

Permalink
Update build and wait-for-image.sh scripts as well
Browse files Browse the repository at this point in the history
  • Loading branch information
aabmass committed Aug 15, 2024
1 parent 56ecd3f commit 1499bad
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 35 deletions.
35 changes: 7 additions & 28 deletions cloudbuild-e2e-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,40 +13,19 @@
# limitations under the License.

steps:
# If the image doesn't exist, create a skip file for the next step to know
- name: "gcr.io/cloud-builders/gcloud"
entrypoint: "bash"
args:
- -c
- |
existing_tags=$(
gcloud container images list-tags \
--filter="tags:${SHORT_SHA}" --format=json \
${_TEST_SERVER_IMAGE_NAME}
)
if [ "$existing_tags" == "[]" ]; then
echo "Image doesn't exist, will build it"
else
echo "Image already exists, will skip building"
touch skip
fi
# If skip doesn't exist, build and push
- name: docker
id: build-test-server
entrypoint: "sh"
args:
- -c
- |
if [ -e "skip" ]; then
return
else
docker build --tag=${_TEST_SERVER_IMAGE} --file=e2e-test-server/Dockerfile .
docker push ${_TEST_SERVER_IMAGE}
if docker manifest inspect ${_TEST_SERVER_IMAGE} > /dev/null; then
echo "Image already exists, will skip building"
exit
fi
docker build --tag=${_TEST_SERVER_IMAGE} --file=e2e-test-server/Dockerfile .
docker push ${_TEST_SERVER_IMAGE}
logsBucket: gs://opentelemetry-ops-e2e-cloud-build-logs
substitutions:
_TEST_SERVER_IMAGE: ${_TEST_SERVER_IMAGE_NAME}:${SHORT_SHA}
_TEST_SERVER_IMAGE_NAME: us-central1-docker.pkg.dev/${PROJECT_ID}/e2e-testing/opentelemetry-operations-python-e2e-test-server
_TEST_SERVER_IMAGE: us-central1-docker.pkg.dev/${PROJECT_ID}/e2e-testing/opentelemetry-operations-python-e2e-test-server:${SHORT_SHA}
11 changes: 4 additions & 7 deletions e2e-test-server/wait-for-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,11 @@
# limitations under the License.

while true; do
docker pull $_TEST_SERVER_IMAGE
pull_success=$?

if [ $pull_success -ne 0 ]; then
echo "Image couldn't be pulled yet, will continue to retry"
else
echo "Image pulled successfully, continuing onto test"
if docker manifest inspect ${_TEST_SERVER_IMAGE} > /dev/null; then
echo "Image is available, continuing onto test"
break
else
echo "Image not available yet, will continue to retry"
fi
sleep 5
done

0 comments on commit 1499bad

Please sign in to comment.