Skip to content

Commit cdb0187

Browse files
authored
Fix: don't use corev1.objectReference (#1156)
* change to objectreference * change to make type match * update generated code * change to parentgateway ref * remove unused change * remove unused code * change to copy instead of import
1 parent 1565f31 commit cdb0187

File tree

8 files changed

+180
-42
lines changed

8 files changed

+180
-42
lines changed

api/v1alpha2/inferencepool_types.go

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ limitations under the License.
1717
package v1alpha2
1818

1919
import (
20-
corev1 "k8s.io/api/core/v1"
2120
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2221
)
2322

@@ -182,7 +181,7 @@ type InferencePoolStatus struct {
182181
// PoolStatus defines the observed state of InferencePool from a Gateway.
183182
type PoolStatus struct {
184183
// GatewayRef indicates the gateway that observed state of InferencePool.
185-
GatewayRef corev1.ObjectReference `json:"parentRef"`
184+
GatewayRef ParentGatewayReference `json:"parentRef"`
186185

187186
// Conditions track the state of the InferencePool.
188187
//
@@ -270,3 +269,29 @@ const (
270269
// or API group, or a reference to a resource that can not be found.
271270
InferencePoolReasonInvalidExtensionRef InferencePoolReason = "InvalidExtensionRef"
272271
)
272+
273+
// ParentGatewayReference identifies an API object including its namespace,
274+
// defaulting to Gateway.
275+
type ParentGatewayReference struct {
276+
// Group is the group of the referent.
277+
//
278+
// +optional
279+
// +kubebuilder:default="gateway.networking.k8s.io"
280+
Group *Group `json:"group"`
281+
282+
// Kind is kind of the referent. For example "Gateway".
283+
//
284+
// +optional
285+
// +kubebuilder:default=Gateway
286+
Kind *Kind `json:"kind"`
287+
288+
// Name is the name of the referent.
289+
Name ObjectName `json:"name"`
290+
291+
// Namespace is the namespace of the referent. If not present,
292+
// the namespace of the referent is assumed to be the same as
293+
// the namespace of the referring object.
294+
//
295+
// +optional
296+
Namespace *Namespace `json:"namespace,omitempty"`
297+
}

api/v1alpha2/shared_types.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,24 @@ type LabelKey string
106106
// +kubebuilder:validation:MaxLength=63
107107
// +kubebuilder:validation:Pattern=`^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?$`
108108
type LabelValue string
109+
110+
// Namespace refers to a Kubernetes namespace. It must be a RFC 1123 label.
111+
//
112+
// This validation is based off of the corresponding Kubernetes validation:
113+
// https://github.com/kubernetes/apimachinery/blob/02cfb53916346d085a6c6c7c66f882e3c6b0eca6/pkg/util/validation/validation.go#L187
114+
//
115+
// This is used for Namespace name validation here:
116+
// https://github.com/kubernetes/apimachinery/blob/02cfb53916346d085a6c6c7c66f882e3c6b0eca6/pkg/api/validation/generic.go#L63
117+
//
118+
// Valid values include:
119+
//
120+
// * "example"
121+
//
122+
// Invalid values include:
123+
//
124+
// * "example.com" - "." is an invalid character
125+
//
126+
// +kubebuilder:validation:Pattern=`^[a-z0-9]([-a-z0-9]*[a-z0-9])?$`
127+
// +kubebuilder:validation:MinLength=1
128+
// +kubebuilder:validation:MaxLength=63
129+
type Namespace string

api/v1alpha2/zz_generated.deepcopy.go

Lines changed: 31 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client-go/applyconfiguration/api/v1alpha2/parentgatewayreference.go

Lines changed: 70 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client-go/applyconfiguration/api/v1alpha2/poolstatus.go

Lines changed: 6 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client-go/applyconfiguration/utils.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/inference.networking.x-k8s.io_inferencepools.yaml

Lines changed: 21 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -242,46 +242,36 @@ spec:
242242
description: GatewayRef indicates the gateway that observed
243243
state of InferencePool.
244244
properties:
245-
apiVersion:
246-
description: API version of the referent.
247-
type: string
248-
fieldPath:
249-
description: |-
250-
If referring to a piece of an object instead of an entire object, this string
251-
should contain a valid JSON/Go field access statement, such as desiredState.manifest.containers[2].
252-
For example, if the object reference is to a container within a pod, this would take on a value like:
253-
"spec.containers{name}" (where "name" refers to the name of the container that triggered
254-
the event) or if no container name is specified "spec.containers[2]" (container with
255-
index 2 in this pod). This syntax is chosen only to have some well-defined way of
256-
referencing a part of an object.
245+
group:
246+
default: gateway.networking.k8s.io
247+
description: Group is the group of the referent.
248+
maxLength: 253
249+
pattern: ^$|^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$
257250
type: string
258251
kind:
259-
description: |-
260-
Kind of the referent.
261-
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
252+
default: Gateway
253+
description: Kind is kind of the referent. For example "Gateway".
254+
maxLength: 63
255+
minLength: 1
256+
pattern: ^[a-zA-Z]([-a-zA-Z0-9]*[a-zA-Z0-9])?$
262257
type: string
263258
name:
264-
description: |-
265-
Name of the referent.
266-
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
259+
description: Name is the name of the referent.
260+
maxLength: 253
261+
minLength: 1
267262
type: string
268263
namespace:
269264
description: |-
270-
Namespace of the referent.
271-
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/
272-
type: string
273-
resourceVersion:
274-
description: |-
275-
Specific resourceVersion to which this reference is made, if any.
276-
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency
277-
type: string
278-
uid:
279-
description: |-
280-
UID of the referent.
281-
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids
265+
Namespace is the namespace of the referent. If not present,
266+
the namespace of the referent is assumed to be the same as
267+
the namespace of the referring object.
268+
maxLength: 63
269+
minLength: 1
270+
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
282271
type: string
272+
required:
273+
- name
283274
type: object
284-
x-kubernetes-map-type: atomic
285275
required:
286276
- parentRef
287277
type: object

conformance/utils/kubernetes/helpers.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,8 @@ func InferencePoolMustHaveCondition(t *testing.T, c client.Reader, poolNN types.
127127
debugMsg += " (No parent statuses reported)"
128128
}
129129
for i, parentStatus := range lastObservedPool.Status.Parents {
130-
debugMsg += fmt.Sprintf("\n Parent %d (Gateway: %s/%s):", i, parentStatus.GatewayRef.Namespace, parentStatus.GatewayRef.Name)
130+
namespace := parentStatus.GatewayRef.Namespace
131+
debugMsg += fmt.Sprintf("\n Parent %d (Gateway: %s/%s):", i, *namespace, parentStatus.GatewayRef.Name)
131132
if len(parentStatus.Conditions) == 0 {
132133
debugMsg += " (No conditions reported for this parent)"
133134
}

0 commit comments

Comments
 (0)