@@ -267,21 +267,18 @@ func generateAndApplyMachineConfigNodes(
267267 if fg .Enabled (features .FeatureGatePinnedImages ) {
268268 if imageSetApplyConfig == nil {
269269 for _ , imageSet := range newMCNode .Status .PinnedImageSets {
270- if imageSet .LastFailedGeneration != 0 { // only set `LastFailedGeneration` value when it is a non-default (non-0) value
271- statusApplyConfig = statusApplyConfig .WithPinnedImageSets (& machineconfigurationalphav1.MachineConfigNodeStatusPinnedImageSetApplyConfiguration {
272- DesiredGeneration : ptr .To (imageSet .DesiredGeneration ),
273- CurrentGeneration : ptr .To (imageSet .CurrentGeneration ),
274- Name : ptr .To (imageSet .Name ),
275- LastFailedGeneration : ptr .To (imageSet .LastFailedGeneration ),
276- LastFailedGenerationError : ptr .To (imageSet .LastFailedGenerationError ),
277- })
278- } else {
279- statusApplyConfig = statusApplyConfig .WithPinnedImageSets (& machineconfigurationalphav1.MachineConfigNodeStatusPinnedImageSetApplyConfiguration {
280- DesiredGeneration : ptr .To (imageSet .DesiredGeneration ),
281- CurrentGeneration : ptr .To (imageSet .CurrentGeneration ),
282- Name : ptr .To (imageSet .Name ),
283- })
270+ pisApplyConfig := & machineconfigurationalphav1.MachineConfigNodeStatusPinnedImageSetApplyConfiguration {
271+ DesiredGeneration : ptr .To (imageSet .DesiredGeneration ),
272+ CurrentGeneration : ptr .To (imageSet .CurrentGeneration ),
273+ Name : ptr .To (imageSet .Name ),
284274 }
275+ // Only set `LastFailedGeneration` value when it is a non-default (non-0) value
276+ if imageSet .LastFailedGeneration != 0 {
277+ pisApplyConfig .LastFailedGeneration = ptr .To (imageSet .LastFailedGeneration )
278+ pisApplyConfig .LastFailedGenerationError = ptr .To (imageSet .LastFailedGenerationError )
279+ }
280+
281+ statusApplyConfig = statusApplyConfig .WithPinnedImageSets (pisApplyConfig )
285282 }
286283 } else if len (imageSetApplyConfig ) > 0 {
287284 statusApplyConfig = statusApplyConfig .WithPinnedImageSets (imageSetApplyConfig ... )
0 commit comments