diff --git a/ci-operator/step-registry/redhat-developer/rhdh/aks/mapt/orphaned/destroy/redhat-developer-rhdh-aks-mapt-orphaned-destroy-ref.yaml b/ci-operator/step-registry/redhat-developer/rhdh/aks/mapt/orphaned/destroy/redhat-developer-rhdh-aks-mapt-orphaned-destroy-ref.yaml index 1de95cd17e8f2..2fcc9bebf9a22 100644 --- a/ci-operator/step-registry/redhat-developer/rhdh/aks/mapt/orphaned/destroy/redhat-developer-rhdh-aks-mapt-orphaned-destroy-ref.yaml +++ b/ci-operator/step-registry/redhat-developer/rhdh/aks/mapt/orphaned/destroy/redhat-developer-rhdh-aks-mapt-orphaned-destroy-ref.yaml @@ -9,7 +9,7 @@ ref: name: mapt namespace: ci tag: v0.9.6 - grace_period: 15m + grace_period: 2h resources: limits: cpu: "2" diff --git a/ci-operator/step-registry/redhat-developer/rhdh/aks/mapt/orphaned/get/redhat-developer-rhdh-aks-mapt-orphaned-get-commands.sh b/ci-operator/step-registry/redhat-developer/rhdh/aks/mapt/orphaned/get/redhat-developer-rhdh-aks-mapt-orphaned-get-commands.sh index e330f048ff643..d5953f35eeeb6 100644 --- a/ci-operator/step-registry/redhat-developer/rhdh/aks/mapt/orphaned/get/redhat-developer-rhdh-aks-mapt-orphaned-get-commands.sh +++ b/ci-operator/step-registry/redhat-developer/rhdh/aks/mapt/orphaned/get/redhat-developer-rhdh-aks-mapt-orphaned-get-commands.sh @@ -36,4 +36,34 @@ if [ -f "${SHARED_DIR}/blob_top_level_folders.txt" ]; then else echo "Error: Failed to create blob list file" exit 1 -fi \ No newline at end of file +fi + +echo "Finding all .pulumi/locks/ blobs in container ${AZURE_STORAGE_BLOB}..." + +# Get unique top-level folders that have .pulumi/locks/ +az storage blob list \ + --container-name "${AZURE_STORAGE_BLOB}" \ + --account-name "${AZURE_STORAGE_ACCOUNT}" \ + --account-key "${AZURE_STORAGE_KEY}" \ + --output json | \ + jq -r '.[].name | select(contains("/.pulumi/locks/")) | split("/.pulumi/locks/")[0]' | \ + sort -u > "${SHARED_DIR}/folders_with_locks.txt" + +if [ ! -s "${SHARED_DIR}/folders_with_locks.txt" ]; then + echo "No .pulumi/locks/ directories found in container" + exit 0 +fi + +folder_count=$(wc -l < "${SHARED_DIR}/folders_with_locks.txt") +echo "Found ${folder_count} folders with .pulumi/locks/ to clean" + +# Delete all lock blobs in one efficient command +echo "Deleting all .pulumi/locks/ blobs across all folders..." +az storage blob delete-batch \ + --source "${AZURE_STORAGE_BLOB}" \ + --account-name "${AZURE_STORAGE_ACCOUNT}" \ + --account-key "${AZURE_STORAGE_KEY}" \ + --pattern "*/.pulumi/locks/*" +cp "${SHARED_DIR}/folders_with_locks.txt" "${ARTIFACT_DIR}/folders_cleaned.txt" + +echo "Successfully deleted .pulumi/locks/ from ${folder_count} folders" diff --git a/ci-operator/step-registry/redhat-developer/rhdh/eks/mapt/orphaned/destroy/redhat-developer-rhdh-eks-mapt-orphaned-destroy-ref.yaml b/ci-operator/step-registry/redhat-developer/rhdh/eks/mapt/orphaned/destroy/redhat-developer-rhdh-eks-mapt-orphaned-destroy-ref.yaml index f601d89a0ac3a..babfdb56f4efe 100644 --- a/ci-operator/step-registry/redhat-developer/rhdh/eks/mapt/orphaned/destroy/redhat-developer-rhdh-eks-mapt-orphaned-destroy-ref.yaml +++ b/ci-operator/step-registry/redhat-developer/rhdh/eks/mapt/orphaned/destroy/redhat-developer-rhdh-eks-mapt-orphaned-destroy-ref.yaml @@ -9,7 +9,7 @@ ref: name: mapt namespace: ci tag: v0.9.6 - grace_period: 15m + grace_period: 2h resources: limits: cpu: "2" diff --git a/ci-operator/step-registry/redhat-developer/rhdh/eks/mapt/orphaned/get/redhat-developer-rhdh-eks-mapt-orphaned-get-commands.sh b/ci-operator/step-registry/redhat-developer/rhdh/eks/mapt/orphaned/get/redhat-developer-rhdh-eks-mapt-orphaned-get-commands.sh old mode 100644 new mode 100755 index 081c0345ab4bf..6549588532f35 --- a/ci-operator/step-registry/redhat-developer/rhdh/eks/mapt/orphaned/get/redhat-developer-rhdh-eks-mapt-orphaned-get-commands.sh +++ b/ci-operator/step-registry/redhat-developer/rhdh/eks/mapt/orphaned/get/redhat-developer-rhdh-eks-mapt-orphaned-get-commands.sh @@ -25,4 +25,33 @@ if [ -f "${SHARED_DIR}/s3_top_level_folders.txt" ]; then else echo "Error: Failed to create S3 object list file" exit 1 -fi \ No newline at end of file +fi + +echo "Finding all .pulumi/locks/ directories in S3 bucket ${AWS_S3_BUCKET}..." + +# Get unique top-level folders that have .pulumi/locks/ +aws s3api list-objects-v2 \ + --bucket "${AWS_S3_BUCKET}" \ + --output json \ + --query 'Contents[?contains(Key, `.pulumi/locks/`)].Key' \ + | jq -r '.[]?' \ + | sed 's|/\.pulumi/locks/.*||' \ + | sort -u > "${SHARED_DIR}/folders_with_locks.txt" + +if [ ! -s "${SHARED_DIR}/folders_with_locks.txt" ]; then + echo "No .pulumi/locks/ directories found in bucket" + exit 0 +fi + +folder_count=$(wc -l < "${SHARED_DIR}/folders_with_locks.txt") +echo "Found ${folder_count} folders with .pulumi/locks/ to clean" + +# Delete all lock files in one efficient command +echo "Deleting all .pulumi/locks/ files across all folders..." +aws s3 rm "s3://${AWS_S3_BUCKET}/" \ + --recursive \ + --exclude "*" \ + --include "*/.pulumi/locks/*" +cp "${SHARED_DIR}/folders_with_locks.txt" "${ARTIFACT_DIR}/folders_cleaned.txt" + +echo "Successfully deleted .pulumi/locks/ from ${folder_count} folders"