Skip to content

Commit

Permalink
Update to skip cleanup of built-in resources in Long Running Tests (#…
Browse files Browse the repository at this point in the history
…8317)

# Description

Update to skip cleanup of built-in resources in Long Running Tests. 

## Type of change

- This pull request is a minor refactor, code cleanup, test improvement,
or other maintenance task and doesn't change the functionality of Radius
(issue link optional).

## Contributor checklist
Please verify that the PR meets the following requirements, where
applicable:

- An overview of proposed schema changes is included in a linked GitHub
issue.
    - [ ] Yes
    - [ ] Not applicable
- A design document PR is created in the [design-notes
repository](/~https://github.com/radius-project/design-notes/), if new
APIs are being introduced.
    - [ ] Yes
    - [ ] Not applicable
- The design document has been reviewed and approved by Radius
maintainers/approvers.
    - [ ] Yes
    - [ ] Not applicable
- A PR for the [samples
repository](/~https://github.com/radius-project/samples) is created, if
existing samples are affected by the changes in this PR.
    - [ ] Yes
    - [ ] Not applicable
- A PR for the [documentation
repository](/~https://github.com/radius-project/docs) is created, if the
changes in this PR affect the documentation or any user facing updates
are made.
    - [ ] Yes
    - [ ] Not applicable
- A PR for the [recipes
repository](/~https://github.com/radius-project/recipes) is created, if
existing recipes are affected by the changes in this PR.
    - [ ] Yes
    - [ ] Not applicable

Signed-off-by: lakshmimsft <ljavadekar@microsoft.com>
  • Loading branch information
lakshmimsft authored Jan 28, 2025
1 parent e4db991 commit 9c0a579
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .github/scripts/cleanup-long-running-cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@

set -e

SKIP_RESOURCE_FILE="${1:-}"
echo "cleaning up long-running cluster on Azure"
echo "Using skip-resource-list from: $SKIP_RESOURCE_FILE"

# Delete all test resources in queuemessages.
if kubectl get crd queuemessages.ucp.dev >/dev/null 2>&1; then
Expand All @@ -33,8 +35,11 @@ if kubectl get crd resources.ucp.dev >/dev/null 2>&1; then
echo "delete all resources in resources.ucp.dev"
resources=$(kubectl get resources.ucp.dev -n radius-system --no-headers -o custom-columns=":metadata.name")
for r in $resources; do
# Skip resources if they're either scope.* or listed in skip resource file
if [[ $r == scope.local.* || $r == scope.aws.* || -z "$r" ]]; then
echo "skip deletion: $r"
elif [ -n "$SKIP_RESOURCE_FILE" ] && [ -f "$SKIP_RESOURCE_FILE" ] && grep -q "$r" "$SKIP_RESOURCE_FILE"; then
echo "Skip deletion: $r (found in skip-resource-list $SKIP_RESOURCE_FILE)"
else
echo "delete resource: $r"
kubectl delete resources.ucp.dev $r -n radius-system --ignore-not-found=true
Expand Down
30 changes: 27 additions & 3 deletions .github/workflows/long-running-azure.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,9 @@ jobs:
rad install kubernetes --reinstall \
--chart ${{ env.RADIUS_CHART_LOCATION }} \
--set rp.image=${{ env.CONTAINER_REGISTRY }}/applications-rp,rp.tag=${{ env.REL_VERSION }},dynamicrp.image=${{ env.CONTAINER_REGISTRY }}/dynamic-rp,dynamicrp.tag=${{ env.REL_VERSION }},controller.image=${{ env.CONTAINER_REGISTRY }}/controller,controller.tag=${{ env.REL_VERSION }},ucp.image=${{ env.CONTAINER_REGISTRY }}/ucpd,ucp.tag=${{ env.REL_VERSION }}
echo "*** Verify manifests are registered ***"
- name: Verify manifests are registered
if: env.SKIP_BUILD != 'true'
run: |
rm -f registermanifest_logs.txt
# Find the pod with container "ucp"
POD_NAME=$(
Expand Down Expand Up @@ -448,6 +449,16 @@ jobs:
echo "Manifests not registered after 3 minutes."
exit 1
fi
- name: Create a list of resources not to be deleted
if: env.SKIP_BUILD != 'true'
run: |
kubectl get resources.ucp.dev -n radius-system --no-headers -o custom-columns=":metadata.name" > skip-delete-resources-list.txt
- name: Save list of resources not to be deleted
if: env.SKIP_BUILD != 'true'
uses: actions/cache/save@v4
with:
path: skip-delete-resources-list.txt
key: skip-delete-resources-list-file
- name: Configure Radius test workspace
run: |
set -x
Expand Down Expand Up @@ -553,10 +564,23 @@ jobs:
--subscription ${{ secrets.AZURE_SUBSCRIPTIONID_TESTS }} \
--name ${{ env.AZURE_TEST_RESOURCE_GROUP }} \
--yes --verbose
- name: Restore skip-delete-resources-list
if: always()
uses: actions/cache/restore@v4
with:
path: skip-delete-resources-list.txt
key: skip-delete-resources-list-file
- name: Clean up cluster
if: always()
timeout-minutes: 60
run: ./.github/scripts/cleanup-long-running-cluster.sh
run: |
# Report if skip-delete-resources-list.txt is missing or empty
if [ ! -s skip-delete-resources-list.txt ]; then
echo "skip-delete-resources-list.txt does not exist or is empty. Proceeding without skip list..."
else
echo "Found skip-delete-resources-list.txt. Cleaning up resources..."
fi
./.github/scripts/cleanup-long-running-cluster.sh skip-delete-resources-list.txt
report-failure:
name: Report test failure
needs: [build, tests]
Expand Down

0 comments on commit 9c0a579

Please sign in to comment.