@@ -95,49 +95,51 @@ func convertStatusToV1(src *InferencePoolStatus) (*v1.InferencePoolStatus, error
95
95
if src == nil {
96
96
return nil , errors .New ("src cannot be nil" )
97
97
}
98
- if src .Parents == nil {
98
+ if len ( src .Parents ) == 0 {
99
99
return & v1.InferencePoolStatus {}, nil
100
100
}
101
101
out := & v1.InferencePoolStatus {
102
102
Parents : make ([]v1.ParentStatus , 0 , len (src .Parents )),
103
103
}
104
104
for _ , p := range src .Parents {
105
+ // Drop the synthetic "status/default" parent entirely.
106
+ if isV1Alpha2DefaultParent (p ) {
107
+ continue
108
+ }
105
109
ps := v1.ParentStatus {
106
110
ParentRef : toV1ParentRef (p .GatewayRef ),
107
- Conditions : make ([]metav1. Condition , 0 ),
111
+ Conditions : nil , // start nil; only allocate if we actually keep any
108
112
}
109
113
for _ , c := range p .Conditions {
110
- cc := c
111
- if isV1Alpha2DefaultConditon (c ) {
114
+ // Drop the synthetic default condition.
115
+ if isV1Alpha2DefaultCondition (c ) {
112
116
continue
113
117
}
114
- // v1alpha2: "Accepted" -> v1: "SupportedByParent"
115
- if cc .Type == string (v1 .InferencePoolConditionAccepted ) &&
116
- cc .Reason == string (InferencePoolReasonAccepted ) {
117
- cc .Reason = string (v1 .InferencePoolReasonAccepted )
118
+ cc := c
119
+ if cc .Type == string (v1 .InferencePoolConditionAccepted ) {
120
+ cc .Reason = mapAcceptedReasonToV1 (cc .Reason )
118
121
}
119
122
ps .Conditions = append (ps .Conditions , cc )
120
123
}
121
- if len (ps .Conditions ) == 0 && len (src .Parents ) == 1 {
122
- // Reset the conditions to nil since v1 version does not have default condition.
123
- // Default is only configured when length of src.Parents is 1.
124
- ps .Conditions = nil
125
- }
124
+
125
+ // If no real conditions remain, leave nil (omitted in JSON).
126
126
out .Parents = append (out .Parents , ps )
127
127
}
128
- return out , nil
129
- }
130
128
131
- func isV1Alpha2DefaultConditon (c metav1.Condition ) bool {
132
- return InferencePoolConditionType (c .Type ) == InferencePoolConditionAccepted &&
133
- c .Status == metav1 .ConditionUnknown && InferencePoolReason (c .Reason ) == InferencePoolReasonPending
129
+ // If all parents were synthetic and were dropped, normalize to empty status.
130
+ if len (out .Parents ) == 0 {
131
+ return & v1.InferencePoolStatus {}, nil
132
+ }
133
+ return out , nil
134
134
}
135
135
136
136
func convertStatusFromV1 (src * v1.InferencePoolStatus ) (* InferencePoolStatus , error ) {
137
137
if src == nil {
138
138
return nil , errors .New ("src cannot be nil" )
139
139
}
140
- if src .Parents == nil {
140
+ if len (src .Parents ) == 0 {
141
+ // Do not synthesize the default parent here; v1alpha2 CRD defaults cover creation-time,
142
+ // and conversion should reflect the true empty set.
141
143
return & InferencePoolStatus {}, nil
142
144
}
143
145
out := & InferencePoolStatus {
@@ -147,23 +149,60 @@ func convertStatusFromV1(src *v1.InferencePoolStatus) (*InferencePoolStatus, err
147
149
ps := PoolStatus {
148
150
GatewayRef : fromV1ParentRef (p .ParentRef ),
149
151
}
150
- if p .Conditions != nil {
151
- ps .Conditions = make ([]metav1.Condition , len (p .Conditions ))
152
- }
153
- for idx , c := range p .Conditions {
154
- cc := c
155
- // v1: "SupportedByParent" -> v1alpha2: "Accepted"
156
- if cc .Type == string (v1 .InferencePoolConditionAccepted ) &&
157
- cc .Reason == string (v1 .InferencePoolReasonAccepted ) {
158
- cc .Reason = string (InferencePoolReasonAccepted )
152
+ if n := len (p .Conditions ); n > 0 {
153
+ ps .Conditions = make ([]metav1.Condition , 0 , n )
154
+ for _ , c := range p .Conditions {
155
+ cc := c
156
+ if cc .Type == string (v1 .InferencePoolConditionAccepted ) {
157
+ cc .Reason = mapAcceptedReasonFromV1 (cc .Reason )
158
+ }
159
+ ps .Conditions = append (ps .Conditions , cc )
159
160
}
160
- ps .Conditions [idx ] = cc
161
161
}
162
162
out .Parents = append (out .Parents , ps )
163
163
}
164
164
return out , nil
165
165
}
166
166
167
+ // isV1Alpha2DefaultParent returns true for the synthetic "no parents yet" entry.
168
+ func isV1Alpha2DefaultParent (p PoolStatus ) bool {
169
+ if p .GatewayRef .Kind == nil || p .GatewayRef .Name == "" {
170
+ return false
171
+ }
172
+ return * p .GatewayRef .Kind == "Status" && p .GatewayRef .Name == "default"
173
+ }
174
+
175
+ // Map v1alpha2 -> v1 reasons for the "Accepted" condition.
176
+ func mapAcceptedReasonToV1 (r string ) string {
177
+ switch InferencePoolReason (r ) {
178
+ case InferencePoolReasonAccepted :
179
+ return string (v1 .InferencePoolReasonAccepted )
180
+ case InferencePoolReasonNotSupportedByGateway :
181
+ return string (v1 .InferencePoolReasonNotSupportedByParent )
182
+ default :
183
+ // Keep other reasons like "HTTPRouteNotAccepted" or "Pending" as-is.
184
+ return r
185
+ }
186
+ }
187
+
188
+ // Map v1 -> v1alpha2 reasons for the "Accepted" condition.
189
+ func mapAcceptedReasonFromV1 (r string ) string {
190
+ switch v1 .InferencePoolReason (r ) {
191
+ case v1 .InferencePoolReasonAccepted :
192
+ return string (InferencePoolReasonAccepted )
193
+ case v1 .InferencePoolReasonNotSupportedByParent :
194
+ return string (InferencePoolReasonNotSupportedByGateway )
195
+ default :
196
+ return r
197
+ }
198
+ }
199
+
200
+ func isV1Alpha2DefaultCondition (c metav1.Condition ) bool {
201
+ return InferencePoolConditionType (c .Type ) == InferencePoolConditionAccepted &&
202
+ c .Status == metav1 .ConditionUnknown &&
203
+ InferencePoolReason (c .Reason ) == InferencePoolReasonPending
204
+ }
205
+
167
206
func toV1ParentRef (in ParentGatewayReference ) v1.ParentReference {
168
207
out := v1.ParentReference {
169
208
Name : v1 .ObjectName (in .Name ),
0 commit comments