@@ -937,7 +937,9 @@ func (r *ServerReconciler) patchServerURI(ctx context.Context, bmcClient bmc.BMC
937937 }
938938
939939 // Try to find system by UUID if one is provided
940- if len (server .Spec .SystemUUID ) > 0 {
940+ uuidProvided := len (server .Spec .SystemUUID ) > 0
941+ uuidMatched := false
942+ if uuidProvided {
941943 for _ , system := range systems {
942944 if strings .EqualFold (system .UUID , server .Spec .SystemUUID ) {
943945 serverBase := server .DeepCopy ()
@@ -948,11 +950,22 @@ func (r *ServerReconciler) patchServerURI(ctx context.Context, bmcClient bmc.BMC
948950 return true , nil
949951 }
950952 }
953+ // UUID was provided but didn't match any system
954+ uuidMatched = false
951955 }
952956
953957 // If no system found by UUID or UUID is empty, and we only have one system, use it
954958 // This handles cases where the Redfish implementation doesn't provide System.UUID
955959 if len (systems ) == 1 {
960+ // If a UUID was provided but didn't match the only available system, report an error
961+ if uuidProvided && ! uuidMatched {
962+ system := systems [0 ]
963+ log .V (1 ).Info ("Provided SystemUUID does not match the only available system" ,
964+ "requestedUUID" , server .Spec .SystemUUID , "systemUUID" , system .UUID , "systemSerialNumber" , system .SerialNumber )
965+ return false , fmt .Errorf ("provided SystemUUID %q does not match the only available system (UUID: %q, SerialNumber: %q); check your configuration" ,
966+ server .Spec .SystemUUID , system .UUID , system .SerialNumber )
967+ }
968+
956969 system := systems [0 ]
957970 serverBase := server .DeepCopy ()
958971 server .Spec .SystemURI = system .URI
0 commit comments