Skip to content

Commit 794e5ff

Browse files
committed
error handling e2e
Signed-off-by: Dmytro Rashko <dmitriy.rashko@amdocs.com>
1 parent 20e2e40 commit 794e5ff

4 files changed

Lines changed: 32 additions & 6 deletions

File tree

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,9 @@ run: docker-build
109109
@docker run --rm --net=host -p 8084:8084 -e OPENAI_API_KEY=$(OPENAI_API_KEY) -v $(HOME)/.kube:/home/nonroot/.kube -e KAGENT_TOOLS_PORT=8084 $(TOOLS_IMG) -- --kubeconfig /root/.kube/config
110110

111111
PHONY: retag
112-
retag: docker-build
112+
retag: docker-build helm-version
113+
@echo "Check Kind cluster $(KIND_CLUSTER_NAME) exists"
114+
kind get clusters | grep -q $(KIND_CLUSTER_NAME) || kind create cluster --name $(KIND_CLUSTER_NAME)
113115
@echo "Retagging tools image to $(RETAGGED_TOOLS_IMG)"
114116
docker tag $(TOOLS_IMG) $(RETAGGED_TOOLS_IMG)
115117
kind load docker-image --name $(KIND_CLUSTER_NAME) $(RETAGGED_TOOLS_IMG)
@@ -199,9 +201,7 @@ delete-kind-cluster:
199201
kind delete cluster --name $(KIND_CLUSTER_NAME)
200202

201203
.PHONY: kind-update-kagent
202-
kind-update-kagent: docker-build
203-
kind get clusters | grep -q $(KIND_CLUSTER_NAME) || kind create cluster --name $(KIND_CLUSTER_NAME)
204-
kind load docker-image --name $(KIND_CLUSTER_NAME) $(TOOLS_IMG)
204+
kind-update-kagent: retag
205205
kubectl patch --namespace kagent deployment/kagent --type='json' -p='[{"op": "replace", "path": "/spec/template/spec/containers/3/image", "value": "$(TOOLS_IMG)"}]'
206206

207207
.PHONY: otel-local

e2e/k8s/e2e_helper.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ func (c *MCPClient) k8sListResources(resourceType string) (interface{}, error) {
9494
if err != nil {
9595
return nil, err
9696
}
97+
if result.IsError {
98+
return nil, fmt.Errorf("tool call failed: %s", result.Content)
99+
}
97100
return result, nil
98101
}
99102

@@ -123,6 +126,9 @@ func (c *MCPClient) helmListReleases() (interface{}, error) {
123126
if err != nil {
124127
return nil, err
125128
}
129+
if result.IsError {
130+
return nil, fmt.Errorf("tool call failed: %s", result.Content)
131+
}
126132
return result, nil
127133
}
128134

@@ -151,7 +157,7 @@ func (c *MCPClient) istioInstall(profile string) (interface{}, error) {
151157
return nil, err
152158
}
153159
if result.IsError {
154-
return nil, fmt.Errorf("istio installation failed: %s", result.Content)
160+
return nil, fmt.Errorf("tool call failed: %s", result.Content)
155161
}
156162
return result, nil
157163
}
@@ -182,6 +188,9 @@ func (c *MCPClient) argoRolloutsList(namespace string) (interface{}, error) {
182188
if err != nil {
183189
return nil, err
184190
}
191+
if result.IsError {
192+
return nil, fmt.Errorf("tool call failed: %s", result.Content)
193+
}
185194
return result, nil
186195
}
187196

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
apiVersion: v2
2-
name: kagent
2+
name: kagent-tools
33
description: A Helm chart for kagent-tools,
44
type: application
55
version: ${VERSION}

helm/kagent-tools/templates/clusterrole.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,14 @@ rules:
7777
- get
7878
- list
7979
- watch
80+
- apiGroups:
81+
- "admissionregistration.k8s.io"
82+
resources:
83+
- "mutatingwebhookconfigurations"
84+
verbs:
85+
- get
86+
- list
87+
- watch
8088
---
8189

8290
apiVersion: rbac.authorization.k8s.io/v1
@@ -144,3 +152,12 @@ rules:
144152
- update
145153
- patch
146154
- delete
155+
- apiGroups:
156+
- "admissionregistration.k8s.io"
157+
resources:
158+
- "mutatingwebhookconfigurations"
159+
verbs:
160+
- create
161+
- update
162+
- patch
163+
- delete

0 commit comments

Comments
 (0)