@@ -193,6 +193,9 @@ func ValidateWorkersAgainstCloudProfileOnUpdate(
193193 fldPath * field.Path ,
194194) field.ErrorList {
195195 allErrs := field.ErrorList {}
196+ // Normalize capability definitions once at the entry point.
197+ // This ensures all downstream code can assume capabilities are always present.
198+ normalizedCapabilityDefinitions := apisawshelper .NormalizeCapabilityDefinitions (capabilityDefinitions )
196199
197200 // Validate the existence of the images the new/updated workers are to use. Validating the images used by old workers is not possible at this point, as they might
198201 // have been removed from the CloudProfile already.
@@ -211,8 +214,10 @@ func ValidateWorkersAgainstCloudProfileOnUpdate(
211214 allErrs = append (allErrs , field .Invalid (fldPath .Index (i ).Child ("machine" , "type" ), w .Machine .Type , " not found in cloud profile" ))
212215 continue
213216 }
217+ // Normalize machine type capabilities to include architecture
218+ machineTypeCapabilities := apisawshelper .NormalizeMachineTypeCapabilities (machineType .Capabilities , w .Machine .Architecture , normalizedCapabilityDefinitions )
214219
215- allErrs = append (allErrs , validateWorkerConfigAgainstCloudProfile (newWorker , region , awsCloudProfile , machineType . Capabilities , capabilityDefinitions , fldPath .Index (i ))... )
220+ allErrs = append (allErrs , validateWorkerConfigAgainstCloudProfile (newWorker , region , awsCloudProfile , machineTypeCapabilities , normalizedCapabilityDefinitions , fldPath .Index (i ))... )
216221 }
217222 }
218223
@@ -223,7 +228,7 @@ func validateWorkerConfigAgainstCloudProfile(
223228 worker core.Worker ,
224229 region string ,
225230 awsCloudProfile * apisaws.CloudProfileConfig ,
226- machineCapabilities v1beta1.Capabilities ,
231+ machineTypeCapabilities v1beta1.Capabilities ,
227232 capabilityDefinitions []v1beta1.CapabilityDefinition ,
228233 fldPath * field.Path ,
229234) field.ErrorList {
@@ -236,7 +241,7 @@ func validateWorkerConfigAgainstCloudProfile(
236241 return allErrs
237242 }
238243
239- if _ , err := apisawshelper .FindImageInCloudProfile (awsCloudProfile , image .Name , image .Version , region , machineCapabilities , capabilityDefinitions ); err != nil {
244+ if _ , err := apisawshelper .FindImageInCloudProfile (awsCloudProfile , image .Name , image .Version , region , machineTypeCapabilities , capabilityDefinitions ); err != nil {
240245 allErrs = append (allErrs , field .Invalid (fldPath .Child ("machine" , "image" ), image , fmt .Sprint (err )))
241246 }
242247 return allErrs
0 commit comments