@@ -11,6 +11,7 @@ import (
1111 "net/http"
1212 "path"
1313 "path/filepath"
14+ "sort"
1415 "strings"
1516 "text/template"
1617
@@ -64,6 +65,36 @@ func RunBootServer(ipxeServerAddr string, ipxeServiceURL string, k8sClient clien
6465 }
6566 }
6667
68+ if len (ipxeBootConfigList .Items ) == 0 {
69+ // Fuzzy segment-based match
70+ requestSegments := normalizeAndSortUUIDSegments (uuid )
71+
72+ allConfigs := & bootv1alpha1.IPXEBootConfigList {}
73+ if err := k8sClient .List (r .Context (), allConfigs ); err != nil {
74+ http .Error (w , "Internal Server Error" , http .StatusInternalServerError )
75+ log .Info ("Failed to list IPXEBootConfigs for fuzzy match" , "error" , err .Error ())
76+ return
77+ }
78+
79+ for _ , cfg := range allConfigs .Items {
80+ cfgSegments := normalizeAndSortUUIDSegments (cfg .Spec .SystemUUID )
81+ if len (cfgSegments ) != len (requestSegments ) {
82+ continue
83+ }
84+ matched := true
85+ for i := range cfgSegments {
86+ if cfgSegments [i ] != requestSegments [i ] {
87+ matched = false
88+ break
89+ }
90+ }
91+ if matched {
92+ ipxeBootConfigList .Items = append (ipxeBootConfigList .Items , cfg )
93+ break
94+ }
95+ }
96+ }
97+
6798 if len (ipxeBootConfigList .Items ) == 0 {
6899 log .Info ("No IPXEBootConfig found with given UUID. Trying HTTPBootConfig" )
69100 handleIgnitionHTTPBoot (w , r , k8sClient , log , uuid )
@@ -98,6 +129,36 @@ func handleIPXE(w http.ResponseWriter, r *http.Request, k8sClient client.Client,
98129 return
99130 }
100131
132+ if len (ipxeBootConfigList .Items ) == 0 {
133+ // Fuzzy segment-based match
134+ requestSegments := normalizeAndSortUUIDSegments (uuid )
135+
136+ allConfigs := & bootv1alpha1.IPXEBootConfigList {}
137+ if err := k8sClient .List (ctx , allConfigs ); err != nil {
138+ http .Error (w , "Internal Server Error" , http .StatusInternalServerError )
139+ log .Info ("Failed to list IPXEBootConfigs for fuzzy match" , "error" , err .Error ())
140+ return
141+ }
142+
143+ for _ , cfg := range allConfigs .Items {
144+ cfgSegments := normalizeAndSortUUIDSegments (cfg .Spec .SystemUUID )
145+ if len (cfgSegments ) != len (requestSegments ) {
146+ continue
147+ }
148+ matched := true
149+ for i := range cfgSegments {
150+ if cfgSegments [i ] != requestSegments [i ] {
151+ matched = false
152+ break
153+ }
154+ }
155+ if matched {
156+ ipxeBootConfigList .Items = append (ipxeBootConfigList .Items , cfg )
157+ break
158+ }
159+ }
160+ }
161+
101162 if len (ipxeBootConfigList .Items ) == 0 {
102163 log .Info ("No IPXEBootConfig found for the given UUID" )
103164 http .Error (w , "Resource Not Found" , http .StatusNotFound )
@@ -136,6 +197,19 @@ func handleIPXE(w http.ResponseWriter, r *http.Request, k8sClient client.Client,
136197 })
137198}
138199
200+ // TODO: Remove later
201+ // Utility: normalize and sort each segment of UUID
202+ func normalizeAndSortUUIDSegments (uuid string ) []string {
203+ segments := strings .Split (strings .ToLower (uuid ), "-" )
204+ sortedSegments := make ([]string , len (segments ))
205+ for i , segment := range segments {
206+ chars := strings .Split (segment , "" )
207+ sort .Strings (chars )
208+ sortedSegments [i ] = strings .Join (chars , "" )
209+ }
210+ return sortedSegments
211+ }
212+
139213func handleIgnitionIPXEBoot (w http.ResponseWriter , r * http.Request , k8sClient client.Client , log logr.Logger , uuid string ) {
140214 log .Info ("Processing Ignition request" , "method" , r .Method , "path" , r .URL .Path , "clientIP" , r .RemoteAddr )
141215 ctx := r .Context ()
@@ -165,6 +239,36 @@ func handleIgnitionIPXEBoot(w http.ResponseWriter, r *http.Request, k8sClient cl
165239 }
166240 }
167241
242+ if len (ipxeBootConfigList .Items ) == 0 {
243+ // Fuzzy segment-based match
244+ requestSegments := normalizeAndSortUUIDSegments (uuid )
245+
246+ allConfigs := & bootv1alpha1.IPXEBootConfigList {}
247+ if err := k8sClient .List (ctx , allConfigs ); err != nil {
248+ http .Error (w , "Internal Server Error" , http .StatusInternalServerError )
249+ log .Info ("Failed to list IPXEBootConfigs for fuzzy match" , "error" , err .Error ())
250+ return
251+ }
252+
253+ for _ , cfg := range allConfigs .Items {
254+ cfgSegments := normalizeAndSortUUIDSegments (cfg .Spec .SystemUUID )
255+ if len (cfgSegments ) != len (requestSegments ) {
256+ continue
257+ }
258+ matched := true
259+ for i := range cfgSegments {
260+ if cfgSegments [i ] != requestSegments [i ] {
261+ matched = false
262+ break
263+ }
264+ }
265+ if matched {
266+ ipxeBootConfigList .Items = append (ipxeBootConfigList .Items , cfg )
267+ break
268+ }
269+ }
270+ }
271+
168272 if len (ipxeBootConfigList .Items ) == 0 {
169273 http .Error (w , "Resource Not Found" , http .StatusNotFound )
170274 log .Info ("No IPXEBootConfig found with given UUID" )
0 commit comments