Skip to content
Merged
Show file tree
Hide file tree
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
41 changes: 3 additions & 38 deletions tools/cloud-build/daily-tests/builds/ansible-vm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -123,50 +123,15 @@ steps:
gsutil rm "gs://daily-tests-tf-state/*/\$$DEPLOYMENT_NAME/**.tflock" 2>/dev/null || true

RUN_CLEANUP=true
# Trap function that runs the rescue playbook (terraform destroy)
# if the pod is terminated by Kueue, fails, or is cancelled.
cleanup_pod() {
local exit_code=\$$?
trap - EXIT SIGTERM SIGINT ERR
set +e

if [ "\$$RUN_CLEANUP" = "false" ]; then
exit 0
fi
if [ \$$exit_code -eq 0 ]; then exit_code=1; fi

echo ""
echo "=========================================================================="
echo "CAUGHT SIGTERM OR SCRIPT ERROR!"
echo "Halting primary Ansible execution..."
echo "=========================================================================="
if [ -n "\$${ANSIBLE_PID:-}" ]; then
kill -TERM \$$ANSIBLE_PID 2>/dev/null || true
wait \$$ANSIBLE_PID 2>/dev/null || true
echo "Waiting 15s for Terraform to release GCS backend state locks..."
sleep 15
fi

echo ""
echo "INITIATING RESCUE PLAYBOOK: Destroying leaked infrastructure for \$$DEPLOYMENT_NAME..."
echo "- hosts: localhost" > /workspace/cleanup-playbook.yml
echo " tasks:" >> /workspace/cleanup-playbook.yml
echo " - ansible.builtin.include_tasks:" >> /workspace/cleanup-playbook.yml
echo " file: tools/cloud-build/daily-tests/ansible_playbooks/tasks/rescue_gcluster_failure.yml" >> /workspace/cleanup-playbook.yml

ansible-playbook /workspace/cleanup-playbook.yml -e deployment_name="\$$DEPLOYMENT_NAME" -e workspace="/workspace" || true

echo "Graceful cleanup finished."
exit \$$exit_code
}
source /workspace/tools/cloud-build/kueue_cleanup_pod.sh
trap cleanup_pod EXIT SIGTERM SIGINT

bash tools/get_binary.sh "\$$_TEST_PREFIX"
bash tools/get_binary.sh "${_TEST_PREFIX}"
BLUEPRINT="tools/cloud-build/daily-tests/blueprints/ansible-vm.yaml"
bash tools/add_ttl_label.sh \$$BLUEPRINT

ansible-playbook tools/cloud-build/daily-tests/ansible_playbooks/base-integration-test.yml \
--user="$$OSLOGIN_USER" --extra-vars="project=\$$PROJECT_ID build=$$BUILD_ID_SHORT full_build_id=$BUILD_ID" \
--user="$$OSLOGIN_USER" --extra-vars="project=$PROJECT_ID build=$$BUILD_ID_SHORT full_build_id=$BUILD_ID" \
--extra-vars="@tools/cloud-build/daily-tests/tests/ansible-vm.yml" \
--extra-vars="triage_gcs_bucket_override=$$TRIAGE_GCS_BUCKET" \
--extra-vars="triage_project_number_override=$$TRIAGE_PROJECT_NUMBER" \
Expand Down
37 changes: 1 addition & 36 deletions tools/cloud-build/daily-tests/builds/batch-mpi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -128,42 +128,7 @@ steps:
gsutil rm "gs://daily-tests-tf-state/*/\$$DEPLOYMENT_NAME/**.tflock" 2>/dev/null || true

RUN_CLEANUP=true
# Trap function that runs the rescue playbook (terraform destroy)
# if the pod is terminated by Kueue, fails, or is cancelled.
cleanup_pod() {
local exit_code=\$$?
trap - EXIT SIGTERM SIGINT ERR
set +e

if [ "\$$RUN_CLEANUP" = "false" ]; then
exit 0
fi
if [ \$$exit_code -eq 0 ]; then exit_code=1; fi

echo ""
echo "=========================================================================="
echo "CAUGHT SIGTERM OR SCRIPT ERROR!"
echo "Halting primary Ansible execution..."
echo "=========================================================================="
if [ -n "\$${ANSIBLE_PID:-}" ]; then
kill -TERM \$$ANSIBLE_PID 2>/dev/null || true
wait \$$ANSIBLE_PID 2>/dev/null || true
echo "Waiting 15s for Terraform to release GCS backend state locks..."
sleep 15
fi

echo ""
echo "INITIATING RESCUE PLAYBOOK: Destroying leaked infrastructure for \$$DEPLOYMENT_NAME..."
echo "- hosts: localhost" > /workspace/cleanup-playbook.yml
echo " tasks:" >> /workspace/cleanup-playbook.yml
echo " - ansible.builtin.include_tasks:" >> /workspace/cleanup-playbook.yml
echo " file: tools/cloud-build/daily-tests/ansible_playbooks/tasks/rescue_gcluster_failure.yml" >> /workspace/cleanup-playbook.yml

ansible-playbook /workspace/cleanup-playbook.yml -e deployment_name="\$$DEPLOYMENT_NAME" -e workspace="/workspace" || true

echo "Graceful cleanup finished."
exit \$$exit_code
}
source /workspace/tools/cloud-build/kueue_cleanup_pod.sh
trap cleanup_pod EXIT SIGTERM SIGINT

bash tools/get_binary.sh "${_TEST_PREFIX}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,42 +122,7 @@ steps:
gsutil rm "gs://daily-tests-tf-state/*/\$$DEPLOYMENT_NAME/**.tflock" 2>/dev/null || true

RUN_CLEANUP=true
# Trap function that runs the rescue playbook (terraform destroy)
# if the pod is terminated by Kueue, fails, or is cancelled.
cleanup_pod() {
local exit_code=\$$?
trap - EXIT SIGTERM SIGINT ERR
set +e

if [ "\$$RUN_CLEANUP" = "false" ]; then
exit 0
fi
if [ \$$exit_code -eq 0 ]; then exit_code=1; fi

echo ""
echo "=========================================================================="
echo "CAUGHT SIGTERM OR SCRIPT ERROR!"
echo "Halting primary Ansible execution..."
echo "=========================================================================="
if [ -n "\$${ANSIBLE_PID:-}" ]; then
kill -TERM \$$ANSIBLE_PID 2>/dev/null || true
wait \$$ANSIBLE_PID 2>/dev/null || true
echo "Waiting 15s for Terraform to release GCS backend state locks..."
sleep 15
fi

echo ""
echo "INITIATING RESCUE PLAYBOOK: Destroying leaked infrastructure for \$$DEPLOYMENT_NAME..."
echo "- hosts: localhost" > /workspace/cleanup-playbook.yml
echo " tasks:" >> /workspace/cleanup-playbook.yml
echo " - ansible.builtin.include_tasks:" >> /workspace/cleanup-playbook.yml
echo " file: tools/cloud-build/daily-tests/ansible_playbooks/tasks/rescue_gcluster_failure.yml" >> /workspace/cleanup-playbook.yml

ansible-playbook /workspace/cleanup-playbook.yml -e deployment_name="\$$DEPLOYMENT_NAME" -e workspace="/workspace" || true

echo "Graceful cleanup finished."
exit \$$exit_code
}
source /workspace/tools/cloud-build/kueue_cleanup_pod.sh
trap cleanup_pod EXIT SIGTERM SIGINT

bash tools/get_binary.sh "${_TEST_PREFIX}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,42 +120,7 @@ steps:
gsutil rm "gs://daily-tests-tf-state/*/\$$DEPLOYMENT_NAME/**.tflock" 2>/dev/null || true

RUN_CLEANUP=true
# Trap function that runs the rescue playbook (terraform destroy)
# if the pod is terminated by Kueue, fails, or is cancelled.
cleanup_pod() {
local exit_code=\$$?
trap - EXIT SIGTERM SIGINT ERR
set +e

if [ "\$$RUN_CLEANUP" = "false" ]; then
exit 0
fi
if [ \$$exit_code -eq 0 ]; then exit_code=1; fi

echo ""
echo "=========================================================================="
echo "CAUGHT SIGTERM OR SCRIPT ERROR!"
echo "Halting primary Ansible execution..."
echo "=========================================================================="
if [ -n "\$${ANSIBLE_PID:-}" ]; then
kill -TERM \$$ANSIBLE_PID 2>/dev/null || true
wait \$$ANSIBLE_PID 2>/dev/null || true
echo "Waiting 15s for Terraform to release GCS backend state locks..."
sleep 15
fi

echo ""
echo "INITIATING RESCUE PLAYBOOK: Destroying leaked infrastructure for \$$DEPLOYMENT_NAME..."
echo "- hosts: localhost" > /workspace/cleanup-playbook.yml
echo " tasks:" >> /workspace/cleanup-playbook.yml
echo " - ansible.builtin.include_tasks:" >> /workspace/cleanup-playbook.yml
echo " file: tools/cloud-build/daily-tests/ansible_playbooks/tasks/rescue_gcluster_failure.yml" >> /workspace/cleanup-playbook.yml

ansible-playbook /workspace/cleanup-playbook.yml -e deployment_name="\$$DEPLOYMENT_NAME" -e workspace="/workspace" || true

echo "Graceful cleanup finished."
exit \$$exit_code
}
source /workspace/tools/cloud-build/kueue_cleanup_pod.sh
trap cleanup_pod EXIT SIGTERM SIGINT

bash tools/get_binary.sh "${_TEST_PREFIX}"
Expand Down
45 changes: 7 additions & 38 deletions tools/cloud-build/daily-tests/builds/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,38 +102,7 @@ steps:
gsutil rm "gs://daily-tests-tf-state/*/\$$DEPLOYMENT_NAME/**.tflock" 2>/dev/null || true

RUN_CLEANUP=true
cleanup_pod() {
local exit_code=\$$?
trap - EXIT SIGTERM SIGINT ERR
set +e

if [ "\$$RUN_CLEANUP" = "false" ]; then
exit 0
fi
if [ \$$exit_code -eq 0 ]; then exit_code=1; fi

echo ""
echo "=========================================================================="
echo "CAUGHT SIGTERM OR SCRIPT ERROR!"
echo "Halting execution..."
echo "=========================================================================="
if [ -n "\$${CMD_PID:-}" ]; then
kill -TERM \$$CMD_PID 2>/dev/null || true
wait \$$CMD_PID 2>/dev/null || true
fi

echo ""
echo "INITIATING RESCUE PLAYBOOK: Destroying leaked infrastructure for \$$DEPLOYMENT_NAME..."
echo "- hosts: localhost" > /workspace/cleanup-playbook.yml
echo " tasks:" >> /workspace/cleanup-playbook.yml
echo " - ansible.builtin.include_tasks:" >> /workspace/cleanup-playbook.yml
echo " file: tools/cloud-build/daily-tests/ansible_playbooks/tasks/rescue_gcluster_failure.yml" >> /workspace/cleanup-playbook.yml

ansible-playbook /workspace/cleanup-playbook.yml -e deployment_name="\$$DEPLOYMENT_NAME" -e workspace="/workspace" || true

echo "Graceful cleanup finished."
exit \$$exit_code
}
source /workspace/tools/cloud-build/kueue_cleanup_pod.sh
Comment thread
sudheer-quad marked this conversation as resolved.
trap cleanup_pod EXIT SIGTERM SIGINT

region="us-central1"
Expand All @@ -145,17 +114,17 @@ steps:
bash tools/add_ttl_label.sh "\$$BLUEPRINT"

./gcluster deploy "\$$BLUEPRINT" --vars="\$$vars" --auto-approve &
CMD_PID=\$$!
wait \$$CMD_PID
ANSIBLE_PID=\$$!
wait \$$ANSIBLE_PID

# check instance was created
gcloud compute instances describe "\$${DEPLOYMENT_NAME}-0" --project="\$$PROJECT_ID" --zone="\$$zone" >/dev/null &
CMD_PID=\$$!
wait \$$CMD_PID
ANSIBLE_PID=\$$!
wait \$$ANSIBLE_PID

./gcluster destroy "\$$DEPLOYMENT_NAME" --auto-approve --robust &
CMD_PID=\$$!
wait \$$CMD_PID
ANSIBLE_PID=\$$!
wait \$$ANSIBLE_PID

RUN_CLEANUP=false
resources:
Expand Down
19 changes: 9 additions & 10 deletions tools/cloud-build/daily-tests/builds/gke-g4-onspot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -130,19 +130,10 @@ steps:
command: ["/bin/bash", "-c"]
args:
- |
set -e -u -o pipefail
echo "Sourcing find_available_zone.sh to determine zone."
source /workspace/tools/cloud-build/wait_for_available_zone.sh
if [ -z "\$${ZONE:-}" ]; then
echo "ERROR: ZONE not found" >&2
exit 1
fi
set -x -e
echo "\"test_file_path\": tools/cloud-build/daily-tests/builds/gke-g4-onspot.yaml"
cd /workspace

BUILD_ID_FULL=$$BUILD_ID
BUILD_ID_SHORT=\$${BUILD_ID_FULL:0:6}
DEPLOYMENT_NAME="gke-g4-spot-$$BUILD_ID_SHORT"

# Force clear any leaked Terraform state locks from previously preempted attempts of this test run.
Expand All @@ -153,6 +144,14 @@ steps:
source /workspace/tools/cloud-build/kueue_cleanup_pod.sh
trap cleanup_pod EXIT SIGTERM SIGINT

set -e -u -o pipefail
echo "Sourcing find_available_zone.sh to determine zone."
source /workspace/tools/cloud-build/wait_for_available_zone.sh
if [ -z "\$${ZONE:-}" ]; then
echo "ERROR: ZONE not found" >&2
exit 1
fi
set -x
bash tools/get_binary.sh "${_TEST_PREFIX}"
REGION="\$${ZONE%-*}"
EXAMPLE_BP=examples/gke-g4/gke-g4.yaml
Expand Down Expand Up @@ -183,7 +182,7 @@ steps:
cat \$$EXAMPLE_BP

ansible-playbook tools/cloud-build/daily-tests/ansible_playbooks/base-integration-test.yml \
--extra-vars="test_prefix=${_TEST_PREFIX}" \
--extra-vars="test_prefix=${_TEST_PREFIX}" \
--user="$$OSLOGIN_USER" \
--extra-vars="project=$PROJECT_ID build=$$BUILD_ID_SHORT full_build_id=$BUILD_ID" \
--extra-vars="region=\$$REGION zone=\$$ZONE" \
Expand Down
20 changes: 10 additions & 10 deletions tools/cloud-build/daily-tests/builds/gke-h4d-onspot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,7 @@ steps:
command: ["/bin/bash", "-c"]
args:
- |
set -e -u -o pipefail
echo "\"test_file_path\": tools/cloud-build/daily-tests/builds/gke-h4d-onspot.yaml"
echo "Sourcing find_available_zone.sh to determine zone."
source /workspace/tools/cloud-build/wait_for_available_zone.sh
if [ -z "\$${ZONE:-}" ]; then
echo "ERROR: ZONE not found" >&2
exit 1
fi
set -x
set -x -e
echo "\"test_file_path\": tools/cloud-build/daily-tests/builds/gke-h4d-onspot.yaml"
cd /workspace

Expand All @@ -153,8 +145,16 @@ steps:
source /workspace/tools/cloud-build/kueue_cleanup_pod.sh
trap cleanup_pod EXIT SIGTERM SIGINT

set -e -u -o pipefail
echo "\"test_file_path\": tools/cloud-build/daily-tests/builds/gke-h4d-onspot.yaml"
echo "Sourcing find_available_zone.sh to determine zone."
source /workspace/tools/cloud-build/wait_for_available_zone.sh
if [ -z "\$${ZONE:-}" ]; then
echo "ERROR: ZONE not found" >&2
exit 1
fi
set -x
bash tools/get_binary.sh "${_TEST_PREFIX}"

REGION="\$${ZONE%-*}"
EXAMPLE_BP="examples/gke-h4d/gke-h4d.yaml"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,42 +125,7 @@ steps:
gsutil rm "gs://daily-tests-tf-state/*/\$$DEPLOYMENT_NAME/**.tflock" 2>/dev/null || true

RUN_CLEANUP=true
# Trap function that runs the rescue playbook (terraform destroy)
# if the pod is terminated by Kueue, fails, or is cancelled.
cleanup_pod() {
local exit_code=\$$?
trap - EXIT SIGTERM SIGINT ERR
set +e

if [ "\$$RUN_CLEANUP" = "false" ]; then
exit 0
fi
if [ \$$exit_code -eq 0 ]; then exit_code=1; fi

echo ""
echo "=========================================================================="
echo "CAUGHT SIGTERM OR SCRIPT ERROR!"
echo "Halting primary Ansible execution..."
echo "=========================================================================="
if [ -n "\$${ANSIBLE_PID:-}" ]; then
kill -TERM \$$ANSIBLE_PID 2>/dev/null || true
wait \$$ANSIBLE_PID 2>/dev/null || true
echo "Waiting 15s for Terraform to release GCS backend state locks..."
sleep 15
fi

echo ""
echo "INITIATING RESCUE PLAYBOOK: Destroying leaked infrastructure for \$$DEPLOYMENT_NAME..."
echo "- hosts: localhost" > /workspace/cleanup-playbook.yml
echo " tasks:" >> /workspace/cleanup-playbook.yml
echo " - ansible.builtin.include_tasks:" >> /workspace/cleanup-playbook.yml
echo " file: tools/cloud-build/daily-tests/ansible_playbooks/tasks/rescue_gcluster_failure.yml" >> /workspace/cleanup-playbook.yml

ansible-playbook /workspace/cleanup-playbook.yml -e deployment_name="\$$DEPLOYMENT_NAME" -e workspace="/workspace" || true

echo "Graceful cleanup finished."
exit \$$exit_code
}
source /workspace/tools/cloud-build/kueue_cleanup_pod.sh
trap cleanup_pod EXIT SIGTERM SIGINT

bash tools/get_binary.sh "\$$_TEST_PREFIX"
Expand Down
Loading
Loading