Skip to content

Commit 1d963d8

Browse files
committed
Code review
1 parent 2dc7e03 commit 1d963d8

File tree

3 files changed

+17
-25
lines changed

3 files changed

+17
-25
lines changed

internal/controller/state/graph/httproute.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ func inferencePoolBackend(
343343
return true
344344
}
345345
}
346+
346347
return false
347348
}
348349

internal/controller/state/graph/httproute_test.go

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,17 @@ var expRouteBackendRef = RouteBackendRef{
118118
},
119119
}
120120

121+
func createInferencePoolBackend(name, namespace string) gatewayv1.BackendRef {
122+
return gatewayv1.BackendRef{
123+
BackendObjectReference: gatewayv1.BackendObjectReference{
124+
Group: helpers.GetPointer[gatewayv1.Group](inferenceAPIGroup),
125+
Kind: helpers.GetPointer[gatewayv1.Kind](kinds.InferencePool),
126+
Name: gatewayv1.ObjectName(name),
127+
Namespace: helpers.GetPointer(gatewayv1.Namespace(namespace)),
128+
},
129+
}
130+
}
131+
121132
func TestBuildHTTPRoutes(t *testing.T) {
122133
t.Parallel()
123134

@@ -383,28 +394,14 @@ func TestBuildHTTPRoute(t *testing.T) {
383394
hrInferencePool := createHTTPRoute("hr", gatewayNsName.Name, "example.com", "/")
384395
hrInferencePool.Spec.Rules[0].BackendRefs = []gatewayv1.HTTPBackendRef{
385396
{
386-
BackendRef: gatewayv1.BackendRef{
387-
BackendObjectReference: gatewayv1.BackendObjectReference{
388-
Group: helpers.GetPointer[gatewayv1.Group](inferenceAPIGroup),
389-
Kind: helpers.GetPointer[gatewayv1.Kind](kinds.InferencePool),
390-
Name: "ipool",
391-
Namespace: helpers.GetPointer(gatewayv1.Namespace(gatewayNsName.Namespace)),
392-
},
393-
},
397+
BackendRef: createInferencePoolBackend("ipool", gatewayNsName.Namespace),
394398
},
395399
}
396-
// route with an inference pool backend
400+
// route with an inference pool backend that does not exist
397401
hrInferencePoolDoesNotExist := createHTTPRoute("hr", gatewayNsName.Name, "example.com", "/")
398402
hrInferencePoolDoesNotExist.Spec.Rules[0].BackendRefs = []gatewayv1.HTTPBackendRef{
399403
{
400-
BackendRef: gatewayv1.BackendRef{
401-
BackendObjectReference: gatewayv1.BackendObjectReference{
402-
Group: helpers.GetPointer[gatewayv1.Group](inferenceAPIGroup),
403-
Kind: helpers.GetPointer[gatewayv1.Kind](kinds.InferencePool),
404-
Name: "ipool-does-not-exist",
405-
Namespace: helpers.GetPointer(gatewayv1.Namespace(gatewayNsName.Namespace)),
406-
},
407-
},
404+
BackendRef: createInferencePoolBackend("ipool-does-not-exist", gatewayNsName.Namespace),
408405
},
409406
}
410407

@@ -1045,14 +1042,7 @@ func TestBuildHTTPRoute(t *testing.T) {
10451042
Matches: hrInferencePoolDoesNotExist.Spec.Rules[0].Matches,
10461043
RouteBackendRefs: []RouteBackendRef{
10471044
{
1048-
BackendRef: gatewayv1.BackendRef{
1049-
BackendObjectReference: gatewayv1.BackendObjectReference{
1050-
Group: helpers.GetPointer[gatewayv1.Group](inferenceAPIGroup),
1051-
Kind: helpers.GetPointer[gatewayv1.Kind](kinds.InferencePool),
1052-
Name: "ipool-does-not-exist",
1053-
Namespace: helpers.GetPointer[gatewayv1.Namespace]("test"),
1054-
},
1055-
},
1045+
BackendRef: createInferencePoolBackend("ipool-does-not-exist", gatewayNsName.Namespace),
10561046
},
10571047
},
10581048
},

internal/framework/controller/resource.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ func CreateInferencePoolServiceName(name string) string {
2222
if len(svcName) > 253 {
2323
return name
2424
}
25+
2526
return svcName
2627
}
2728

0 commit comments

Comments
 (0)