Skip to content

Commit 8262eda

Browse files
upgrade monitor: only set LastFailedGeneration and LastFailedGenerationError on PIS failure
1 parent c7c2314 commit 8262eda

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

pkg/upgrademonitor/upgrade_monitor.go

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

Comments
 (0)