1+ #! /bin/bash
2+
3+ # List of namespaces to skip (already processed)
4+ SKIP_NS=" "
5+
6+ for ns in $( kubectl get namespaces -o name | grep ' namespace/lambda-' | cut -d' /' -f2) ; do
7+ # Skip if namespace is in the skip list
8+ if echo " $SKIP_NS " | grep -qw " $ns " ; then
9+ echo " === Skipping namespace: $ns (already processed) ==="
10+ continue
11+ fi
12+
13+ echo " === Processing namespace: $ns ==="
14+ for pod in $( kubectl get pods -n $ns -o name | grep looper | cut -d' /' -f2) ; do
15+ echo " --- Checking pod: $pod ---"
16+
17+ # Health check: verify pod is Running and Ready
18+ POD_STATUS=$( kubectl get pod -n $ns $pod -o jsonpath=' {.status.phase}' 2> /dev/null)
19+ POD_READY=$( kubectl get pod -n $ns $pod -o jsonpath=' {.status.conditions[?(@.type=="Ready")].status}' 2> /dev/null)
20+
21+ if [ " $POD_STATUS " != " Running" ]; then
22+ echo " !!! Pod $pod is not Running (status: $POD_STATUS ), skipping..."
23+ echo " "
24+ continue
25+ fi
26+
27+ if [ " $POD_READY " != " True" ]; then
28+ echo " !!! Pod $pod is not Ready, skipping..."
29+ echo " "
30+ continue
31+ fi
32+
33+ # Check if port 8080 is listening
34+ kubectl exec -n $ns $pod -- sh -c " command -v nc >/dev/null 2>&1 && nc -zv localhost 8080" 2> /dev/null
35+ if [ $? -ne 0 ]; then
36+ echo " ⚠ Port 8080 might not be listening, but continuing anyway..."
37+ fi
38+
39+ echo " ✓ Pod is healthy, executing commands..."
40+
41+ # Run with error handling
42+ kubectl exec -n $ns $pod -- bash -c "
43+ apt update && \
44+ apt install curl -y && \
45+ curl -sSL 'https://github.com/fullstorydev/grpcurl/releases/download/v1.8.7/grpcurl_1.8.7_linux_arm64.tar.gz' | tar -xz -C /usr/local/bin && \
46+ grpcurl -plaintext -d '{\" wet_run\" : true}' localhost:8080 proto.ai.runloop.server.api.looper.scanner.ScannerService/triggerDiscoDeletionVerificationScan
47+ " || echo " !!! Failed for pod: $pod in namespace: $ns "
48+
49+ echo " "
50+ done
51+ done
52+
53+ echo " === All namespaces processed ==="
0 commit comments