@@ -266,13 +266,21 @@ func generateAndApplyMachineConfigNodes(
266266 if fg .Enabled (features .FeatureGatePinnedImages ) {
267267 if imageSetApplyConfig == nil {
268268 for _ , imageSet := range newMCNode .Status .PinnedImageSets {
269- statusApplyConfig = statusApplyConfig .WithPinnedImageSets (& machineconfigurationalphav1.MachineConfigNodeStatusPinnedImageSetApplyConfiguration {
270- DesiredGeneration : ptr .To (imageSet .DesiredGeneration ),
271- CurrentGeneration : ptr .To (imageSet .CurrentGeneration ),
272- Name : ptr .To (imageSet .Name ),
273- LastFailedGeneration : ptr .To (imageSet .LastFailedGeneration ),
274- LastFailedGenerationError : ptr .To (imageSet .LastFailedGenerationError ),
275- })
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+ })
283+ }
276284 }
277285 } else if len (imageSetApplyConfig ) > 0 {
278286 statusApplyConfig = statusApplyConfig .WithPinnedImageSets (imageSetApplyConfig ... )
0 commit comments