Skip to content

Commit 22ad6b9

Browse files
kaovilaiclaude
andcommitted
Add automated Claude failure analysis for Prow CI
Integrates Claude Code via Vertex AI to automatically analyze E2E test failures in Prow CI and generate comprehensive failure reports. Changes: - build/ci-Dockerfile: Install Node.js 20.x and Claude CLI with multi-arch support - tests/e2e/scripts/analyze_failures.sh: New analysis script with: - Vertex AI integration via Claude Code CLI headless mode (--print flag) - Comprehensive secret redaction (AWS keys, GCP keys, tokens, passwords) - Graceful degradation when credentials unavailable - 10-minute timeout with partial analysis on timeout - Makefile: Set GOOGLE_APPLICATION_CREDENTIALS and ANTHROPIC_VERTEX_PROJECT_ID from vault files before running analysis script - docs/design/claude-prow-failure-analysis_design.md: Complete design document - tests/e2e/claude_test_failure_test.go: Simple failing test for verification - tests/e2e/backup_restore_suite_test.go: Realistic failing test that triggers must-gather collection The analysis runs post-suite and does not affect test execution or results. Output is saved to ${ARTIFACT_DIR}/claude-failure-analysis.md with automatic secret redaction to prevent credential leakage. Requires Vertex AI credentials in vault collection files: - /var/run/oadp-credentials/gcp-claude-code-credentials - /var/run/oadp-credentials/gcp-claude-code-project-id 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 5d074fc commit 22ad6b9

File tree

7 files changed

+1453
-3
lines changed

7 files changed

+1453
-3
lines changed

.claude/config.json

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"permissions": {
3+
"allow": [
4+
"Read",
5+
"Glob",
6+
"Grep",
7+
"Read(/go/src/**)",
8+
"Read(/logs/**)",
9+
"Read(/tmp/**)",
10+
"Bash(ls:*)",
11+
"Bash(cat:*)",
12+
"Bash(head:*)",
13+
"Bash(tail:*)",
14+
"Bash(grep:*)",
15+
"Bash(sed:*)",
16+
"Bash(awk:*)",
17+
"Bash(find:*)",
18+
"Bash(tree:*)",
19+
"Bash(wc:*)",
20+
"Bash(sort:*)",
21+
"Bash(uniq:*)",
22+
"Bash(cut:*)",
23+
"Bash(tr:*)",
24+
"Bash(jq:*)",
25+
"Bash(less:*)",
26+
"Bash(more:*)",
27+
"Bash(file:*)"
28+
],
29+
"deny": [
30+
"Write",
31+
"Edit",
32+
"Bash(rm:*)",
33+
"Bash(curl:*)",
34+
"Bash(wget:*)",
35+
"Bash(git:push*)",
36+
"Bash(docker:*)",
37+
"Bash(kubectl:delete*)",
38+
"Bash(kubectl:apply*)",
39+
"Bash(make:*)",
40+
"WebFetch",
41+
"WebSearch"
42+
]
43+
}
44+
}

Makefile

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,20 @@ test-e2e: test-e2e-setup install-ginkgo ## Run E2E tests against OADP operator i
865865
-kvm_emulation=$(KVM_EMULATION) \
866866
-hco_upstream=$(HCO_UPSTREAM) \
867867
-skipMustGather=$(SKIP_MUST_GATHER) \
868-
$(HCP_EXTERNAL_ARGS)
868+
$(HCP_EXTERNAL_ARGS) \
869+
|| EXIT_CODE=$$?; \
870+
if [ "$(OPENSHIFT_CI)" = "true" ]; then \
871+
if [ -f /var/run/oadp-credentials/gcp-claude-code-credentials ]; then \
872+
export GOOGLE_APPLICATION_CREDENTIALS=/var/run/oadp-credentials/gcp-claude-code-credentials; \
873+
export CLAUDE_CODE_USE_VERTEX=1; \
874+
export CLOUD_ML_REGION=global; \
875+
if [ -f /var/run/oadp-credentials/gcp-claude-code-project-id ]; then \
876+
export ANTHROPIC_VERTEX_PROJECT_ID=$$(cat /var/run/oadp-credentials/gcp-claude-code-project-id); \
877+
fi; \
878+
fi; \
879+
./tests/e2e/scripts/analyze_failures.sh $${EXIT_CODE:-0}; \
880+
fi; \
881+
exit $${EXIT_CODE:-0}
869882

870883
.PHONY: test-e2e-cleanup
871884
test-e2e-cleanup: login-required

build/ci-Dockerfile

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,22 @@ WORKDIR /go/src/github.com/openshift/oadp-operator
55

66
COPY ./ .
77

8-
# Install kubectl
9-
RUN curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" && \
8+
# Make analysis script executable for CI execution
9+
RUN chmod +x tests/e2e/scripts/analyze_failures.sh
10+
11+
# Install kubectl (multi-arch)
12+
ARG TARGETARCH
13+
RUN curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/${TARGETARCH}/kubectl" && \
1014
chmod +x kubectl && \
1115
mv kubectl /usr/local/bin/
1216

17+
# Install Node.js and Claude CLI
18+
# Using NodeSource setup script for RHEL-based images
19+
RUN curl -fsSL https://rpm.nodesource.com/setup_20.x | bash - && \
20+
dnf install -y nodejs && \
21+
npm install -g @anthropic-ai/claude-code && \
22+
dnf clean all
23+
1324
RUN go mod download && \
1425
mkdir -p $(go env GOCACHE) && \
1526
chmod -R 777 ./ $(go env GOCACHE) $(go env GOPATH)

0 commit comments

Comments
 (0)