@@ -11,6 +11,7 @@ import (
1111 "net/http"
1212 "path"
1313 "path/filepath"
14+ "sort"
1415 "strings"
1516 "text/template"
1617
@@ -136,6 +137,19 @@ func handleIPXE(w http.ResponseWriter, r *http.Request, k8sClient client.Client,
136137 })
137138}
138139
140+ // TODO: Remove later
141+ // Utility: normalize and sort each segment of UUID
142+ func normalizeAndSortUUIDSegments (uuid string ) []string {
143+ segments := strings .Split (strings .ToLower (uuid ), "-" )
144+ sortedSegments := make ([]string , len (segments ))
145+ for i , segment := range segments {
146+ chars := strings .Split (segment , "" )
147+ sort .Strings (chars )
148+ sortedSegments [i ] = strings .Join (chars , "" )
149+ }
150+ return sortedSegments
151+ }
152+
139153func handleIgnitionIPXEBoot (w http.ResponseWriter , r * http.Request , k8sClient client.Client , log logr.Logger , uuid string ) {
140154 log .Info ("Processing Ignition request" , "method" , r .Method , "path" , r .URL .Path , "clientIP" , r .RemoteAddr )
141155 ctx := r .Context ()
@@ -165,6 +179,36 @@ func handleIgnitionIPXEBoot(w http.ResponseWriter, r *http.Request, k8sClient cl
165179 }
166180 }
167181
182+ if len (ipxeBootConfigList .Items ) == 0 {
183+ // Fuzzy segment-based match
184+ requestSegments := normalizeAndSortUUIDSegments (uuid )
185+
186+ allConfigs := & bootv1alpha1.IPXEBootConfigList {}
187+ if err := k8sClient .List (ctx , allConfigs ); err != nil {
188+ http .Error (w , "Internal Server Error" , http .StatusInternalServerError )
189+ log .Info ("Failed to list IPXEBootConfigs for fuzzy match" , "error" , err .Error ())
190+ return
191+ }
192+
193+ for _ , cfg := range allConfigs .Items {
194+ cfgSegments := normalizeAndSortUUIDSegments (cfg .Spec .SystemUUID )
195+ if len (cfgSegments ) != len (requestSegments ) {
196+ continue
197+ }
198+ matched := true
199+ for i := range cfgSegments {
200+ if cfgSegments [i ] != requestSegments [i ] {
201+ matched = false
202+ break
203+ }
204+ }
205+ if matched {
206+ ipxeBootConfigList .Items = append (ipxeBootConfigList .Items , cfg )
207+ break
208+ }
209+ }
210+ }
211+
168212 if len (ipxeBootConfigList .Items ) == 0 {
169213 http .Error (w , "Resource Not Found" , http .StatusNotFound )
170214 log .Info ("No IPXEBootConfig found with given UUID" )
0 commit comments