@@ -95,49 +95,51 @@ func convertStatusToV1(src *InferencePoolStatus) (*v1.InferencePoolStatus, error
9595 if src == nil {
9696 return nil , errors .New ("src cannot be nil" )
9797 }
98- if src .Parents == nil {
98+ if len ( src .Parents ) == 0 {
9999 return & v1.InferencePoolStatus {}, nil
100100 }
101101 out := & v1.InferencePoolStatus {
102102 Parents : make ([]v1.ParentStatus , 0 , len (src .Parents )),
103103 }
104104 for _ , p := range src .Parents {
105+ // Drop the synthetic "status/default" parent entirely.
106+ if isV1Alpha2DefaultParent (p ) {
107+ continue
108+ }
105109 ps := v1.ParentStatus {
106110 ParentRef : toV1ParentRef (p .GatewayRef ),
107- Conditions : make ([]metav1. Condition , 0 ),
111+ Conditions : nil , // start nil; only allocate if we actually keep any
108112 }
109113 for _ , c := range p .Conditions {
110- cc := c
111- if isV1Alpha2DefaultConditon (c ) {
114+ // Drop the synthetic default condition.
115+ if isV1Alpha2DefaultCondition (c ) {
112116 continue
113117 }
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 )
118121 }
119122 ps .Conditions = append (ps .Conditions , cc )
120123 }
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).
126126 out .Parents = append (out .Parents , ps )
127127 }
128- return out , nil
129- }
130128
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
134134}
135135
136136func convertStatusFromV1 (src * v1.InferencePoolStatus ) (* InferencePoolStatus , error ) {
137137 if src == nil {
138138 return nil , errors .New ("src cannot be nil" )
139139 }
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.
141143 return & InferencePoolStatus {}, nil
142144 }
143145 out := & InferencePoolStatus {
@@ -147,23 +149,60 @@ func convertStatusFromV1(src *v1.InferencePoolStatus) (*InferencePoolStatus, err
147149 ps := PoolStatus {
148150 GatewayRef : fromV1ParentRef (p .ParentRef ),
149151 }
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 )
159160 }
160- ps .Conditions [idx ] = cc
161161 }
162162 out .Parents = append (out .Parents , ps )
163163 }
164164 return out , nil
165165}
166166
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+
167206func toV1ParentRef (in ParentGatewayReference ) v1.ParentReference {
168207 out := v1.ParentReference {
169208 Name : v1 .ObjectName (in .Name ),
0 commit comments