|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# Cleanup script for test workers |
| 4 | +# This script attempts to delete workers with test-related names |
| 5 | + |
| 6 | +ACCOUNT_ID="1634a8e653b2ce7e0f7a23cca8cbd86a" |
| 7 | +DELETED_COUNT=0 |
| 8 | +FAILED_COUNT=0 |
| 9 | + |
| 10 | +echo "🧹 Cleaning up test workers..." |
| 11 | +echo "Account ID: $ACCOUNT_ID" |
| 12 | +echo "" |
| 13 | + |
| 14 | +# Common test worker name patterns based on the error message |
| 15 | +# Example: test-project-smoke-test-defeated-cat-c6cefbc2 |
| 16 | +test_patterns=( |
| 17 | + "test-project-smoke-test-" |
| 18 | + "smoke-test-" |
| 19 | + "e2e-test-" |
| 20 | + "playground-test-" |
| 21 | + "hello-world-" |
| 22 | + "minimal-" |
| 23 | + "standard-" |
| 24 | +) |
| 25 | + |
| 26 | +# Common animal names and random suffixes used in test worker names |
| 27 | +animals=( |
| 28 | + "defeated-cat" "happy-dog" "clever-fox" "swift-bird" "brave-lion" "wise-owl" |
| 29 | + "quick-rabbit" "strong-bear" "gentle-deer" "proud-eagle" "calm-turtle" |
| 30 | + "bright-fish" "wild-wolf" "kind-sheep" "fast-horse" "small-mouse" |
| 31 | + "tall-giraffe" "big-elephant" "cute-panda" "red-fox" "blue-whale" |
| 32 | +) |
| 33 | + |
| 34 | +# Common hex suffixes (8 characters) |
| 35 | +hex_suffixes=( |
| 36 | + "c6cefbc2" "a1b2c3d4" "e5f6g7h8" "i9j0k1l2" "m3n4o5p6" "q7r8s9t0" |
| 37 | + "1a2b3c4d" "5e6f7g8h" "9i0j1k2l" "3m4n5o6p" "7q8r9s0t" "1u2v3w4x" |
| 38 | + "5y6z7a8b" "9c0d1e2f" "3g4h5i6j" "7k8l9m0n" "1o2p3q4r" "5s6t7u8v" |
| 39 | + "9w0x1y2z" "3a4b5c6d" "7e8f9g0h" "1i2j3k4l" "5m6n7o8p" "9q0r1s2t" |
| 40 | +) |
| 41 | + |
| 42 | +echo "Attempting to delete workers with test patterns..." |
| 43 | +echo "This may take a few minutes..." |
| 44 | +echo "" |
| 45 | + |
| 46 | +# Try to delete workers with various patterns and suffixes |
| 47 | +for pattern in "${test_patterns[@]}"; do |
| 48 | + echo "🔍 Trying pattern: $pattern*" |
| 49 | + |
| 50 | + for animal in "${animals[@]}"; do |
| 51 | + for hex in "${hex_suffixes[@]}"; do |
| 52 | + worker_name="${pattern}${animal}-${hex}" |
| 53 | + |
| 54 | + # Try to delete the worker |
| 55 | + if CLOUDFLARE_ACCOUNT_ID="$ACCOUNT_ID" npx wrangler delete --name "$worker_name" --force >/dev/null 2>&1; then |
| 56 | + echo " ✅ Deleted: $worker_name" |
| 57 | + DELETED_COUNT=$((DELETED_COUNT + 1)) |
| 58 | + else |
| 59 | + FAILED_COUNT=$((FAILED_COUNT + 1)) |
| 60 | + fi |
| 61 | + |
| 62 | + # Show progress every 50 attempts |
| 63 | + if [ $((($DELETED_COUNT + $FAILED_COUNT) % 50)) -eq 0 ]; then |
| 64 | + echo " 📊 Progress: $DELETED_COUNT deleted, $FAILED_COUNT not found" |
| 65 | + fi |
| 66 | + done |
| 67 | + done |
| 68 | +done |
| 69 | + |
| 70 | +echo "" |
| 71 | +echo "🎯 Cleanup Summary:" |
| 72 | +echo " ✅ Workers deleted: $DELETED_COUNT" |
| 73 | +echo " ❌ Workers not found: $FAILED_COUNT" |
| 74 | +echo "" |
| 75 | + |
| 76 | +if [ $DELETED_COUNT -gt 0 ]; then |
| 77 | + echo "✨ Successfully cleaned up $DELETED_COUNT test workers!" |
| 78 | +else |
| 79 | + echo "ℹ️ No test workers found with the attempted patterns." |
| 80 | + echo " You may need to manually delete workers via the Cloudflare dashboard:" |
| 81 | + echo " https://dash.cloudflare.com/1634a8e653b2ce7e0f7a23cca8cbd86a/workers-and-pages" |
| 82 | +fi |
0 commit comments