Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
14 changes: 5 additions & 9 deletions api/v1/inferencepool_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,7 @@ type EndpointPickerRef struct {
//
// +optional
// +kubebuilder:default=Service
//nolint:kubeapilinter // ignore kubeapilinter here as we want to use pointer for optional struct.
Kind *Kind `json:"kind,omitempty"`
Kind Kind `json:"kind,omitempty"`

// Name is the name of the referent API object.
//
Expand All @@ -131,16 +130,15 @@ type EndpointPickerRef struct {
// unspecified (defaults to "Service").
//
// +optional
//nolint:kubeapilinter // ignore kubeapilinter here as we want to use pointer for optional struct.
//nolint:kubeapilinter // ignore kubeapilinter here as we want to use pointer as zero means all ports
PortNumber *PortNumber `json:"portNumber,omitempty"`

// FailureMode configures how the parent handles the case when the Endpoint Picker extension
// is non-responsive. When unspecified, defaults to "FailClose".
//
// +optional
// +kubebuilder:default="FailClose"
//nolint:kubeapilinter // ignore kubeapilinter here as we want to use pointer for optional struct.
FailureMode *EndpointPickerFailureMode `json:"failureMode,omitempty"`
FailureMode EndpointPickerFailureMode `json:"failureMode,omitempty"`
}

// EndpointPickerFailureMode defines the options for how the parent handles the case when the
Expand Down Expand Up @@ -286,8 +284,7 @@ type ParentReference struct {
//
// +optional
// +kubebuilder:default=Gateway
//nolint:kubeapilinter // ignore kubeapilinter here as we want to use pointer for optional struct.
Kind *Kind `json:"kind,omitempty"`
Kind Kind `json:"kind,omitempty"`

// Name is the name of the referent API object.
//
Expand All @@ -303,6 +300,5 @@ type ParentReference struct {
// documentation for details: https://gateway-api.sigs.k8s.io/api-types/referencegrant/
//
// +optional
//nolint:kubeapilinter // ignore kubeapilinter here as we want to use pointer for optional struct.
Namespace *Namespace `json:"namespace,omitempty"`
Namespace Namespace `json:"namespace,omitempty"`
}
20 changes: 0 additions & 20 deletions api/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 12 additions & 12 deletions apix/v1alpha2/inferencepool_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,11 @@ func toV1ParentRef(in ParentGatewayReference) v1.ParentReference {
}
if in.Kind != nil {
k := v1.Kind(*in.Kind)
out.Kind = &k
out.Kind = k
}
if in.Namespace != nil {
ns := v1.Namespace(*in.Namespace)
out.Namespace = &ns
out.Namespace = ns
}
return out
}
Expand All @@ -176,12 +176,12 @@ func fromV1ParentRef(in v1.ParentReference) ParentGatewayReference {
g := Group(*in.Group)
out.Group = &g
}
if in.Kind != nil {
k := Kind(*in.Kind)
if in.Kind != "" {
k := Kind(in.Kind)
out.Kind = &k
}
if in.Namespace != nil {
ns := Namespace(*in.Namespace)
if in.Namespace != "" {
ns := Namespace(in.Namespace)
out.Namespace = &ns
}
return out
Expand All @@ -196,14 +196,14 @@ func convertExtensionRefToV1(src *Extension) (v1.EndpointPickerRef, error) {
endpointPickerRef.Group = ptr.To(v1.Group(*src.Group))
}
if src.Kind != nil {
endpointPickerRef.Kind = ptr.To(v1.Kind(*src.Kind))
endpointPickerRef.Kind = v1.Kind(*src.Kind)
}
endpointPickerRef.Name = v1.ObjectName(src.Name)
if src.PortNumber != nil {
endpointPickerRef.PortNumber = ptr.To(v1.PortNumber(*src.PortNumber))
}
if src.FailureMode != nil {
endpointPickerRef.FailureMode = ptr.To(v1.EndpointPickerFailureMode(*src.FailureMode))
endpointPickerRef.FailureMode = v1.EndpointPickerFailureMode(*src.FailureMode)
}

return endpointPickerRef, nil
Expand All @@ -217,15 +217,15 @@ func convertEndpointPickerRefFromV1(src *v1.EndpointPickerRef) (Extension, error
if src.Group != nil {
extension.Group = ptr.To(Group(*src.Group))
}
if src.Kind != nil {
extension.Kind = ptr.To(Kind(*src.Kind))
if src.Kind != "" {
extension.Kind = ptr.To(Kind(src.Kind))
}
extension.Name = ObjectName(src.Name)
if src.PortNumber != nil {
extension.PortNumber = ptr.To(PortNumber(*src.PortNumber))
}
if src.FailureMode != nil {
extension.FailureMode = ptr.To(ExtensionFailureMode(*src.FailureMode))
if src.FailureMode != "" {
extension.FailureMode = ptr.To(ExtensionFailureMode(src.FailureMode))
}
return extension, nil
}
8 changes: 4 additions & 4 deletions apix/v1alpha2/inferencepool_conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ func TestInferencePoolConvertTo(t *testing.T) {
TargetPorts: []v1.Port{{Number: v1.PortNumber(int32(8080))}},
EndpointPickerRef: v1.EndpointPickerRef{
Group: &v1Group,
Kind: &v1Kind,
Kind: v1Kind,
Name: "my-epp-service",
PortNumber: &v1PortNumber,
FailureMode: &v1FailureMode,
FailureMode: v1FailureMode,
},
},
Status: v1.InferencePoolStatus{
Expand Down Expand Up @@ -237,10 +237,10 @@ func TestInferencePoolConvertFrom(t *testing.T) {
TargetPorts: []v1.Port{{Number: v1.PortNumber(int32(8080))}},
EndpointPickerRef: v1.EndpointPickerRef{
Group: &v1Group,
Kind: &v1Kind,
Kind: v1Kind,
Name: "my-epp-service",
PortNumber: &v1PortNumber,
FailureMode: &v1FailureMode,
FailureMode: v1FailureMode,
},
},
Status: v1.InferencePoolStatus{
Expand Down
11 changes: 5 additions & 6 deletions conformance/utils/kubernetes/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/utils/ptr"
"sigs.k8s.io/controller-runtime/pkg/client"
gatewayv1 "sigs.k8s.io/gateway-api/apis/v1"
gatewayapiconfig "sigs.k8s.io/gateway-api/conformance/utils/config"
Expand Down Expand Up @@ -106,8 +105,8 @@ func InferencePoolMustHaveCondition(t *testing.T, c client.Reader, poolNN types.
}

for _, parentStatus := range pool.Status.Parents {
if parentStatus.ParentRef.Namespace != nil &&
string(*parentStatus.ParentRef.Namespace) == gateway.Namespace &&
if parentStatus.ParentRef.Namespace != "" &&
string(parentStatus.ParentRef.Namespace) == gateway.Namespace &&
string(parentStatus.ParentRef.Name) == gateway.Name {
if checkCondition(t, parentStatus.Conditions, expectedCondition) {
conditionFound = true
Expand All @@ -134,10 +133,10 @@ func InferencePoolMustHaveCondition(t *testing.T, c client.Reader, poolNN types.
}
for i, parentStatus := range lastObservedPool.Status.Parents {
namespace := parentStatus.ParentRef.Namespace
if namespace == nil {
namespace = ptr.To(inferenceapi.Namespace(poolNN.Namespace)) // Fallback to the pool's namespace
if namespace == "" {
namespace = inferenceapi.Namespace(poolNN.Namespace) // Fallback to the pool's namespace
}
debugMsg += fmt.Sprintf("\n Parent %d (Gateway: %s/%s):", i, *namespace, parentStatus.ParentRef.Name)
debugMsg += fmt.Sprintf("\n Parent %d (Gateway: %s/%s):", i, namespace, parentStatus.ParentRef.Name)
if len(parentStatus.Conditions) == 0 {
debugMsg += " (No conditions reported for this parent)"
}
Expand Down
2 changes: 1 addition & 1 deletion site-src/reference/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ _Appears in:_
| Field | Description | Default | Validation |
| --- | --- | --- | --- |
| `group` _[Group](#group)_ | Group is the group of the referent API object. When unspecified, the default value<br />is "", representing the Core API group. | | MaxLength: 253 <br />MinLength: 0 <br />Pattern: `^$\|^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$` <br /> |
| `kind` _[Kind](#kind)_ | Kind is the Kubernetes resource kind of the referent API object. When unspecified,<br />the referent is assumed to be a "Service" kind.<br />ExternalName services can refer to CNAME DNS records that may live<br />outside of the cluster and as such are difficult to reason about in<br />terms of conformance. They also may not be safe to forward to (see<br />CVE-2021-25740 for more information). Implementations MUST NOT<br />support ExternalName Services. | Service | MaxLength: 63 <br />MinLength: 1 <br />Pattern: `^[a-zA-Z]([-a-zA-Z0-9]*[a-zA-Z0-9])?$` <br /> |
| `kind` _[Kind](#kind)_ | Kind is the Kubernetes resource kind of the referent.<br />Required if the referent is ambiguous, e.g. service with multiple ports.<br />Defaults to "Service" when not specified.<br />ExternalName services can refer to CNAME DNS records that may live<br />outside of the cluster and as such are difficult to reason about in<br />terms of conformance. They also may not be safe to forward to (see<br />CVE-2021-25740 for more information). Implementations MUST NOT<br />support ExternalName Services. | Service | MaxLength: 63 <br />MinLength: 1 <br />Pattern: `^[a-zA-Z]([-a-zA-Z0-9]*[a-zA-Z0-9])?$` <br /> |
| `name` _[ObjectName](#objectname)_ | Name is the name of the referent API object. | | MaxLength: 253 <br />MinLength: 1 <br /> |
| `portNumber` _[PortNumber](#portnumber)_ | PortNumber is the port number of the Endpoint Picker extension service. When unspecified,<br />implementations SHOULD infer a default value of 9002 when the kind field is "Service" or<br />unspecified (defaults to "Service"). | | Maximum: 65535 <br />Minimum: 1 <br /> |
| `failureMode` _[EndpointPickerFailureMode](#endpointpickerfailuremode)_ | FailureMode configures how the parent handles the case when the Endpoint Picker extension<br />is non-responsive. When unspecified, defaults to "FailClose". | FailClose | Enum: [FailOpen FailClose] <br /> |
Expand Down