Skip to content

Commit b47ec0c

Browse files
author
Theresa
authored
Troubleshooting guide for the validating webhook. (#332)
* Troubleshooting guide for the validating webhook. Signed-off-by: ichbinblau <theresa.shan@intel.com>
1 parent 3b5f62e commit b47ec0c

File tree

4 files changed

+58
-11
lines changed

4 files changed

+58
-11
lines changed

microservices-connector/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,3 +151,7 @@ make undeploy
151151
### Deploy using helm chart
152152

153153
Please refer to the [helm chart README](./helm/README.md) for deploying GMC using helm chart.
154+
155+
### Troubleshooting guide
156+
157+
Please refer to this [troubleshooting_guide](./troubleshooting_guide.md) for identifying GMC Custom Resource issues.

microservices-connector/api/v1alpha3/validating_webhook.go

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ var (
3434
"TeiReranking",
3535
"Tgi",
3636
"TgiGaudi",
37+
"TgiNvidia",
3738
"Llm",
3839
"DocSum",
3940
"Router",
@@ -110,12 +111,16 @@ func (r *GMConnector) checkfields() field.ErrorList {
110111
return allErrs
111112
}
112113

113-
func checkStepName(s Step, fldRoot *field.Path, nodeName string) *field.Error {
114+
func checkStepName(s Step, idx int, fldRoot *field.Path, nodeName string) *field.Error {
114115
if len(s.StepName) == 0 {
115-
return field.Invalid(fldRoot.Child(nodeName).Child("stepName"), s, fmt.Sprintf("the step name for node %v cannot be empty", nodeName))
116+
return field.Invalid(fldRoot.Child(nodeName).Child(fmt.Sprintf("steps[%d]", idx)).Child("name"),
117+
s,
118+
fmt.Sprintf("the step name for node %v cannot be empty", nodeName))
116119
}
117120
if !slices.Contains(stepNames, s.StepName) {
118-
return field.Invalid(fldRoot.Child(nodeName).Child("stepName"), s, fmt.Sprintf("invalid step name: %s for node %v", s.StepName, nodeName))
121+
return field.Invalid(fldRoot.Child(nodeName).Child(fmt.Sprintf("steps[%d]", idx)).Child("name"),
122+
s,
123+
fmt.Sprintf("invalid step name: %s for node %v", s.StepName, nodeName))
119124
}
120125
return nil
121126
}
@@ -143,20 +148,22 @@ func validateNames(nodes map[string]Router, fldPath *field.Path) field.ErrorList
143148
var errs field.ErrorList
144149

145150
for name, router := range nodes {
146-
for _, step := range router.Steps {
151+
for idx, step := range router.Steps {
147152
// validate step name
148-
if err := checkStepName(step, fldPath, name); err != nil {
153+
if err := checkStepName(step, idx, fldPath, name); err != nil {
149154
errs = append(errs, err)
150155
}
151156

152157
// check node name has been defined in the spec
153158
if !nodeNameExists(step.NodeName, nodeNames) {
154-
errs = append(errs, field.Invalid(fldPath.Child(name).Child("nodeName"), step, fmt.Sprintf("node name: %v in step %v does not exist", step.NodeName, step.StepName)))
159+
errs = append(errs, field.Invalid(fldPath.Child(name).Child(fmt.Sprintf("steps[%d]", idx)).Child("nodeName"),
160+
step,
161+
fmt.Sprintf("node name: %v in step %v does not exist", step.NodeName, step.StepName)))
155162
}
156163

157164
// check service name uniqueness
158165
if len(step.InternalService.ServiceName) != 0 && slices.Contains(serviceNames, step.InternalService.ServiceName) {
159-
errs = append(errs, field.Invalid(fldPath.Child(name).Child("internalService").Child("serviceName"),
166+
errs = append(errs, field.Invalid(fldPath.Child(name).Child(fmt.Sprintf("steps[%d]", idx)).Child("internalService").Child("serviceName"),
160167
step,
161168
fmt.Sprintf("service name: %v in node %v already exists", step.InternalService.ServiceName, name)))
162169
} else {

microservices-connector/api/v1alpha3/validating_webhook_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ func Test_checkStepName(t *testing.T) {
119119
nodeName: testNode,
120120
},
121121
want: field.Invalid(
122-
field.NewPath("spec").Child("nodes").Child("test-node").Child("stepName"),
122+
field.NewPath("spec").Child("nodes").Child(testNode).Child("steps[0]").Child("name"),
123123
Step{},
124124
fmt.Sprintf("the step name for node %v cannot be empty", testNode),
125125
),
@@ -135,7 +135,7 @@ func Test_checkStepName(t *testing.T) {
135135
nodeName: testNode,
136136
},
137137
want: field.Invalid(
138-
field.NewPath("spec").Child("nodes").Child("test-node").Child("stepName"),
138+
field.NewPath("spec").Child("nodes").Child(testNode).Child("steps[0]").Child("name"),
139139
Step{
140140
StepName: "invalid",
141141
Executor: Executor{},
@@ -158,7 +158,7 @@ func Test_checkStepName(t *testing.T) {
158158
}
159159
for _, tt := range tests {
160160
t.Run(tt.name, func(t *testing.T) {
161-
if got := checkStepName(tt.args.s, tt.args.fldRoot, tt.args.nodeName); !reflect.DeepEqual(got, tt.want) {
161+
if got := checkStepName(tt.args.s, 0, tt.args.fldRoot, tt.args.nodeName); !reflect.DeepEqual(got, tt.want) {
162162
t.Errorf("checkStepName() = %v, want %v", got, tt.want)
163163
}
164164
})
@@ -323,7 +323,7 @@ func Test_validateNames(t *testing.T) {
323323
fldPath: field.NewPath("spec").Child("nodes"),
324324
},
325325
want: append(errs, field.Invalid(
326-
field.NewPath("spec").Child("nodes").Child("root").Child("internalService").Child("serviceName"),
326+
field.NewPath("spec").Child("nodes").Child("root").Child("steps[1]").Child("internalService").Child("serviceName"),
327327
Step{
328328
StepName: "Embedding",
329329
Executor: Executor{
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Troubleshooting GMC Custom Resource(CR)
2+
3+
This doc is about identifying issues in GMC CR; A validating webhook has been configured to validate CR fields and it will report all detected errors.
4+
After the CR for GMC pipeline has been deployed, correct the CR if you encounter the following errors:
5+
6+
1. Root node existence
7+
8+
```
9+
The GMCConnector "chatqa" is invalid: spec.nodes: Invalid value: map[string]v1alpha3.Router{"node1":...}: a root node is required
10+
```
11+
12+
In the `spec.nodes` section of the CR, a node with the name ‘root’ is required.
13+
14+
2. StepName validation
15+
16+
```
17+
The GMCConnector "chatqa" is invalid: spec.nodes.root.steps[0].name: Invalid value: v1alpha3.Step{StepName:"Embedding123", Executor:v1alpha3.Executor{NodeName:"", InternalService:v1alpha3.GMCTarget{ServiceName:"embedding-svc", NameSpace:"", Config:map[string]string{"TEI_EMBEDDING_ENDPOINT":"tei-embedding-svc", "endpoint":"/v1/embeddings"}, IsDownstreamService:false}, ExternalService:""}, Data:"", Condition:"", Dependency:"", ServiceURL:""}: invalid step name: Embedding123 for node root
18+
```
19+
20+
In the CR, the value of StepName in the `spec.nodes.<nodeName>.steps[].name` field should be included in the predefined [list](./api/v1alpha3/validating_webhook.go).
21+
22+
3. nodeName existence
23+
24+
```
25+
The GMCConnector "switch" is invalid: spec.nodes.root.steps[0].nodeName: Invalid value: v1alpha3.Step{StepName:"Embedding", Executor:v1alpha3.Executor{NodeName:"node123", InternalService:v1alpha3.GMCTarget{ServiceName:"", NameSpace:"", Config:map[string]string(nil), IsDownstreamService:false}, ExternalService:""}, Data:"", Condition:"", Dependency:"", ServiceURL:""}: node name: node123 in step Embedding does not exist
26+
```
27+
28+
The nodename that is referenced within the `spec.nodes.<nodeName>.steps[].nodeName` field must already be defined in the `spec.nodes` section.
29+
30+
4. serviceName uniqueness
31+
32+
```
33+
The GMCConnector "chatqa" is invalid: spec.nodes.root.steps[1].internalService.serviceName: Invalid value: v1alpha3.Step{StepName:"TeiEmbedding", Executor:v1alpha3.Executor{NodeName:"", InternalService:v1alpha3.GMCTarget{ServiceName:"tei-embedding-svc", NameSpace:"", Config:map[string]string(nil), IsDownstreamService:true}, ExternalService:""}, Data:"", Condition:"", Dependency:"", ServiceURL:""}: service name: tei-embedding-svc in node root already exists
34+
```
35+
36+
The serviceName specified in the `spec.nodes.<nodeName>.steps[].internalService.serviceName` field must be unique and not duplicated with service names in other steps.

0 commit comments

Comments
 (0)