Skip to content

Commit 0656eb0

Browse files
upgrade monitor: only set LastFailedGeneration when it is non-zero
1 parent 88b9bb6 commit 0656eb0

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

pkg/upgrademonitor/upgrade_monitor.go

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)