Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 55 additions & 6 deletions infra/scripts/deploy/java-on-amazon-eks/verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
# =============================================================================
# verify.sh — end-of-bootstrap checks for the java-on-amazon-eks environment.
#
# Each check names what a participant would hit if it failed. Waits for the two things
# Each check names what a participant would hit if it failed. Waits for the things
# that are legitimately still provisioning when the platform installs finish (the
# app's ALB, the sensor's first measurement); everything else must already be there.
# app's ALB, the sensor's first measurement, the Grafana dashboard); everything else
# must already be there.
# Exit 1 on the first hard failure so the bootstrap signals FAILURE, not a green stack
# with a broken session.
# =============================================================================
Expand Down Expand Up @@ -32,6 +33,20 @@ for _ in $(seq 1 60); do
done
[ -n "${URL}" ] && log_success "Application: ${URL}" || fail "Application not reachable through the ALB after 5 min"

# The workshop NodePool is pinned to one instance family (nodepool-pin.sh) and the app runs on it.
FAMILY="${INSTANCE_FAMILY:-m6a}"
kubectl get nodepool "${NODEPOOL:-workshop}" -o json 2>/dev/null \
| jq -e --arg fam "${FAMILY}" '.spec.template.spec.requirements[]
| select(.key == "eks.amazonaws.com/instance-family" and .values == [$fam])' >/dev/null 2>&1 \
&& log_success "NodePool ${NODEPOOL:-workshop} pinned to ${FAMILY}" \
|| fail "NodePool ${NODEPOOL:-workshop} not pinned to ${FAMILY} (nodepool-pin.sh)"
NODES="$(kubectl -n "${APP_NS}" get pods -l app="${APP_NS}" -o jsonpath='{.items[*].spec.nodeName}' 2>/dev/null || true)"
[ -n "${NODES}" ] || fail "no ${APP_NS} pod scheduled"
for n in $(echo "${NODES}" | tr ' ' '\n' | sort -u); do
f="$(kubectl get node "${n}" -o jsonpath='{.metadata.labels.eks\.amazonaws\.com/instance-family}' 2>/dev/null || true)"
[ "${f}" = "${FAMILY}" ] && log_success "App node ${n} is ${FAMILY}" || fail "App node ${n} is ${f:-unknown}, not ${FAMILY} (nodepool-pin.sh)"
done

# 2. Starting-point repo and files the pages rely on.
[ -d "${ENV_DIR}/${APP_NS}/.git" ] || fail "${ENV_DIR}/${APP_NS} is not a git repo"
git -C "${ENV_DIR}/${APP_NS}" log --format=%s -n 1 2>/dev/null | grep -q "^Starting point" \
Expand All @@ -48,8 +63,13 @@ for tag in aot-prebuilt crac-prebuilt; do
|| fail "ECR ${APP_NS}:${tag} missing"
done

# 4. Platform: profiler policy, boost controller, sensor.
# 4. Platform: profiler policy and its image, boost controller, sensor.
kubectl get mutatingpolicy inject-perf-profiler >/dev/null 2>&1 && log_success "Sidecar inject policy present" || fail "MutatingPolicy inject-perf-profiler missing"
PROFILER_IMAGE="$(kubectl get mutatingpolicy inject-perf-profiler -o json 2>/dev/null | grep -o '[^" ]*/perf-profiler@sha256:[0-9a-f]*' | head -1 || true)"
[ -n "${PROFILER_IMAGE}" ] \
&& aws ecr describe-images --repository-name perf-profiler --image-ids imageDigest="${PROFILER_IMAGE#*@}" >/dev/null 2>&1 \
&& log_success "Profiler image in ECR (${PROFILER_IMAGE#*@})" \
|| fail "Profiler image ${PROFILER_IMAGE:-of inject-perf-profiler} not found in ECR perf-profiler"
kubectl -n kube-startup-cpu-boost-system rollout status deploy/kube-startup-cpu-boost-controller-manager --timeout=180s >/dev/null 2>&1 \
&& log_success "Startup CPU Boost controller Ready" || fail "Startup CPU Boost controller not Ready"
kubectl -n monitoring rollout status deploy/perf-sensor --timeout=60s >/dev/null 2>&1 && log_success "perf-sensor Ready" || fail "perf-sensor not Ready"
Expand All @@ -64,12 +84,41 @@ echo "${M}" | jq -e '.workload.memLimitMi != null and .runtime.uptimeSeconds !=
&& log_success "perf-sensor measures ${APP_NS} (limit $(echo "${M}" | jq -r .workload.memLimitMi) Mi, uptime $(echo "${M}" | jq -r .runtime.uptimeSeconds) s)" \
|| fail "perf-sensor returned no workload/runtime facts for ${APP_NS}: $(echo "${M}" | head -c 300)"

# 6. Skills for the coding agents (skills.sh).
# 6. Grafana through its load balancer: sign-in, the Sensor dashboard, the Profiles
# Drilldown app and the two datasources the pages use.
G_HOST="$(kubectl -n monitoring get svc grafana -o jsonpath='{.status.loadBalancer.ingress[0].hostname}' 2>/dev/null || true)"
G_USER="$(kubectl -n monitoring get secret grafana-admin -o jsonpath='{.data.username}' 2>/dev/null | base64 -d 2>/dev/null || true)"
G_PASS="$(kubectl -n monitoring get secret grafana-admin -o jsonpath='{.data.password}' 2>/dev/null | base64 -d 2>/dev/null || true)"
gapi() { curl -s --connect-timeout 5 --max-time 15 -u "${G_USER}:${G_PASS}" "http://${G_HOST}$1" || true; }
if [ -n "${G_HOST}" ] && [ "$(curl -s -o /dev/null -w '%{http_code}' --connect-timeout 5 --max-time 15 \
-u "${G_USER}:${G_PASS}" "http://${G_HOST}/api/user" || true)" = "200" ]; then
log_success "Grafana sign-in works (http://${G_HOST})"
DASH=0
for _ in $(seq 1 12); do
gapi "/api/search?query=Java%20on%20EKS" \
| jq -e '.[] | select(.title == "Java on EKS — Sensor" and .folderTitle == "Workshop Dashboards")' >/dev/null 2>&1 \
&& { DASH=1; break; }
sleep 5
done
[ "${DASH}" -eq 1 ] && log_success "Dashboard 'Java on EKS — Sensor' in Workshop Dashboards" \
|| fail "Dashboard 'Java on EKS — Sensor' not in folder Workshop Dashboards (perf-sensor.sh install)"
gapi "/api/plugins/grafana-pyroscope-app/settings" | jq -e '.enabled == true' >/dev/null 2>&1 \
&& log_success "Profiles Drilldown app (grafana-pyroscope-app) enabled" \
|| fail "Grafana app grafana-pyroscope-app not installed or not enabled"
for ds in promds pyroscope; do
gapi "/api/datasources/uid/${ds}/health" | jq -e '.status == "OK"' >/dev/null 2>&1 \
&& log_success "Grafana datasource ${ds} OK" || fail "Grafana datasource ${ds} not healthy"
done
else
fail "Grafana sign-in failed through the load balancer (host ${G_HOST:-missing}, secret grafana-admin)"
fi

# 7. Skills for the coding agents (skills.sh).
for s in java-on-eks-checklist java-on-eks-optimization; do
[ -f "${ENV_DIR}/skills/${s}/SKILL.md" ] || fail "skill ${s} missing in ${ENV_DIR}/skills"
done

# 7. Claude Code wiring on the IDE.
# 8. Claude Code wiring on the IDE.
[ -f "${ENV_DIR}/.mcp.json" ] && jq -e '.mcpServers["perf-sensor"] and .mcpServers["eks-mcp"]' "${ENV_DIR}/.mcp.json" >/dev/null \
&& log_success ".mcp.json has perf-sensor + eks-mcp" || fail ".mcp.json missing or incomplete"
jq -e '.permissions.deny | index("Bash")' "${ENV_DIR}/.claude/settings.json" >/dev/null 2>&1 \
Expand All @@ -87,7 +136,7 @@ else
fail "eks-mcp does not start: uvx missing at ${UVX_BIN} or ${EKS_MCP_PKG:-the eks-mcp package} not runnable"
fi

# 8. Claude Code answers through Amazon Bedrock. Runs in an empty directory, so no MCP
# 9. Claude Code answers through Amazon Bedrock. Runs in an empty directory, so no MCP
# servers start and `claude -c` in ~/environment does not resume this session.
CLAUDE_BIN="$(command -v claude || echo "${HOME}/.local/bin/claude")"
CLAUDE_DIR="$(mktemp -d)"
Expand Down
Loading