#!/usr/bin/env bash # T44 — istiod=컴파일러: CR 변경이 xDS로 전파되어 proxy-status가 SYNCED로 수렴하고 # 트래픽이 재시작 없이 바뀐다. # # Re-runnable verification script. Creates its own ephemeral namespace, # applies client/echo workloads + a VirtualService (adds a route timeout), # observes propagation via istioctl, and cleans up on exit. set -euo pipefail NS="istio-vt-t44" DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" cleanup() { echo ">>> cleanup: deleting namespace ${NS}" kubectl delete namespace "${NS}" --wait=false --ignore-not-found } trap cleanup EXIT echo ">>> creating namespace ${NS} (istio-injection=enabled)" kubectl create namespace "${NS}" kubectl label namespace "${NS}" istio-injection=enabled echo ">>> applying client + echo workloads" kubectl apply -f "${DIR}/client-echo.yaml" kubectl -n "${NS}" wait --for=condition=Ready pod/client --timeout=90s kubectl -n "${NS}" rollout status deploy/echo CLIENT_START=$(kubectl -n "${NS}" get pod client -o jsonpath='{.status.startTime}') echo "client_start=${CLIENT_START}" echo ">>> snapshotting route BEFORE VirtualService apply" istioctl proxy-config route "client.${NS}" -o json > /tmp/before-route.json grep -c '2.500s' /tmp/before-route.json || true echo ">>> applying VirtualService (adds timeout: 2.500s) with timestamps" ( date +%s.%N; kubectl apply -f "${DIR}/echo-verify-timeout.yaml"; date +%s.%N ) > /tmp/apply_ts.txt cat /tmp/apply_ts.txt echo ">>> polling for propagation (1s granularity, spec loop)" for i in $(seq 1 20); do R=$(istioctl proxy-config route "client.${NS}" -o json 2>/dev/null | grep -c '2.500s') echo "t+${i}s route_has_timeout_count=${R}" if [ "$R" != "0" ]; then break; fi sleep 1 done echo ">>> snapshotting route AFTER VirtualService apply" istioctl proxy-config route "client.${NS}" -o json > /tmp/after-route.json echo ">>> diff (timeout-related lines only)" diff -u /tmp/before-route.json /tmp/after-route.json | grep -i timeout || true echo ">>> proxy-status for client" istioctl proxy-status | awk -v ns="client.${NS}" 'NR==1 || $0 ~ ns' echo ">>> confirm no sidecar restart (startTime must equal ${CLIENT_START})" kubectl -n "${NS}" get pod client -o jsonpath='{.status.startTime}' echo echo "(compare to CLIENT_START=${CLIENT_START})" # --- Optional finer-grained (sub-second) propagation-window measurement --- # The 1s-granularity loop above is often too coarse to resolve propagation # on a lightly-loaded cluster (it may already show non-zero on the very # first check). This block deletes+reapplies the VS and polls immediately # (no pre-sleep) to bound the real window more precisely. echo ">>> supplementary: tight-timing re-measurement of propagation window" kubectl -n "${NS}" delete virtualservice echo-verify-timeout for i in $(seq 1 15); do R=$(istioctl proxy-config route "client.${NS}" -o json 2>/dev/null | grep -c '2.500s') echo "revert_poll i=$i count=$R" if [ "$R" -eq 0 ] 2>/dev/null; then break; fi sleep 1 done T0=$(date +%s.%N) kubectl apply -f "${DIR}/echo-verify-timeout.yaml" T1=$(date +%s.%N) echo "apply_start=$T0 apply_end=$T1" for i in $(seq 1 40); do TC=$(date +%s.%N) R=$(istioctl proxy-config route "client.${NS}" -o json 2>/dev/null | grep -c '2.500s') ELAPSED=$(python3 -c "print(round($TC-$T1,3))") echo "poll i=$i since_apply_end=${ELAPSED}s count=$R" if [ "$R" -gt 0 ] 2>/dev/null; then break; fi done echo ">>> done (namespace will be deleted by trap)"