@@ -62,8 +62,10 @@ func (pf *Upgradeable) Run(ctx context.Context, releaseContext precondition.Rele
62
62
return nil
63
63
}
64
64
65
- currentMinor := getEffectiveMinor (cv .Status .History [0 ].Version )
65
+ currentVersion := getCurrentVersion (cv .Status .History )
66
+ currentMinor := getEffectiveMinor (currentVersion )
66
67
desiredMinor := getEffectiveMinor (releaseContext .DesiredVersion )
68
+ klog .V (5 ).Infof ("currentMinor %s releaseContext.DesiredVersion %s desiredMinor %s" , currentMinor , releaseContext .DesiredVersion , desiredMinor )
67
69
68
70
// if there is no difference in the minor version (4.y.z where 4.y is the same for current and desired), then we can still upgrade
69
71
if currentMinor == desiredMinor {
@@ -82,6 +84,20 @@ func (pf *Upgradeable) Run(ctx context.Context, releaseContext precondition.Rele
82
84
// Name returns Name for the precondition.
83
85
func (pf * Upgradeable ) Name () string { return "ClusterVersionUpgradeable" }
84
86
87
+ // getCurrentVersion determines and returns the cluster's current version by iterating through the
88
+ // provided update history until it finds the first version with update State of Completed. If a
89
+ // Completed version is not found the version of the oldest history entry, which is the originally
90
+ // installed version, is returned.
91
+ func getCurrentVersion (history []configv1.UpdateHistory ) string {
92
+ for _ , h := range history {
93
+ if h .State == configv1 .CompletedUpdate {
94
+ klog .V (5 ).Infof ("Cluster current version=%s" , h .Version )
95
+ return h .Version
96
+ }
97
+ }
98
+ return history [len (history )- 1 ].Version
99
+ }
100
+
85
101
// getEffectiveMinor attempts to do a simple parse of the version provided. If it does not parse, the value is considered
86
102
// empty string, which works for the comparison done here for equivalence.
87
103
func getEffectiveMinor (version string ) string {
0 commit comments