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