Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions cloudbuild/run-presubmit-on-k8s.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,29 @@ gcloud container clusters get-credentials "${CLOUDSDK_CONTAINER_CLUSTER}"
kubectl run "${POD_NAME}" \
--image="${IMAGE}" \
--pod-running-timeout=15m \
--overrides='[{
"op": "add",
"path": "/spec/containers/0/resources/requests",
"value": { "cpu": "750m", "memory": "2Gi", "ephemeral-storage": "2Gi" }
}]' \
--override-type=json \
--restart=Never \
--env="COMMIT_SHA=${COMMIT_SHA}" \
--env="IMAGE_VERSION=${DATAPROC_IMAGE_VERSION}" \
--command -- bash /init-actions/cloudbuild/presubmit.sh

# Delete POD on exit and desribe it before deletion if exit was unsuccessful
# Delete POD on exit and describe it before deletion if exit was unsuccessful
trap '[[ $? != 0 ]] && kubectl describe "pod/${POD_NAME}"; kubectl delete pods "${POD_NAME}"' EXIT

kubectl wait --for=condition=Ready "pod/${POD_NAME}" --timeout=600s
kubectl wait --for=condition=Ready "pod/${POD_NAME}" --timeout=15m

kubectl logs -f "${POD_NAME}"

# Wait until POD will be terminated
wait_secs=200
wait_secs=300
while ((wait_secs > 0)) && ! kubectl describe "pod/${POD_NAME}" | grep -q Terminated; do
sleep 5
((wait_secs-=5))
sleep 10
((wait_secs-=10))
done

readonly EXIT_CODE=$(kubectl get pod "${POD_NAME}" \
Expand Down