Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: openshift/cluster-version-operator
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 79fee059469f417399701b1646954985c74fb737
Choose a base ref
..
head repository: openshift/cluster-version-operator
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 1f15ac9739f18999791d3fcae6f146f68746732b
Choose a head ref
Showing with 0 additions and 50 deletions.
  1. +0 −50 pkg/payload/precondition/clusterversion/upgradeable.go
50 changes: 0 additions & 50 deletions pkg/payload/precondition/clusterversion/upgradeable.go
Original file line number Diff line number Diff line change
@@ -2,7 +2,6 @@ package clusterversion

import (
"context"
"fmt"
"time"

"github.com/blang/semver/v4"
@@ -107,17 +106,6 @@ func (pf *Upgradeable) Run(ctx context.Context, releaseContext precondition.Rele
Name: pf.Name(),
}
} else {
if completedVersion := minorUpdateIsInProgress(cv.Status, currentVersion); completedVersion != "" &&
targetVersion.Major == currentVersion.Major &&
targetVersion.Minor == currentVersion.Minor {
// This is to generate an accepted risk for the accepting case 4.y.z -> 4.y+1.z' -> 4.y+1.z''
return &precondition.Error{
Reason: "MinorVersionClusterUpgradeInProgress",
Message: fmt.Sprintf("Retarget to %s while a minor level upgrade from %s to %s is in progress", targetVersion, completedVersion, targetVersion),
Name: pf.Name(),
NonBlockingWarning: true,
}
}
klog.V(2).Infof("Precondition %q passed on update to %s", pf.Name(), targetVersion.String())
return nil
}
@@ -131,43 +119,5 @@ func (pf *Upgradeable) Run(ctx context.Context, releaseContext precondition.Rele
}
}

// minorUpdateIsInProgress returns the version that was installed completed if a minor level upgrade is in progress
// and the empty string otherwise
func minorUpdateIsInProgress(status configv1.ClusterVersionStatus, currentVersion semver.Version) string {
completedVersionStr := GetCurrentVersion(status.History)
if completedVersionStr == "" {
return ""
}
v, err := semver.Parse(completedVersionStr)
if err != nil {
return ""
}
if cond := resourcemerge.FindOperatorStatusCondition(status.Conditions, configv1.OperatorProgressing); cond != nil &&
cond.Status == configv1.ConditionTrue &&
v.Major == currentVersion.Major &&
v.Minor < currentVersion.Minor {
return completedVersionStr
}
return ""
}

// Name returns Name for the precondition.
func (pf *Upgradeable) Name() string { return "ClusterVersionUpgradeable" }

// GetCurrentVersion determines and returns the cluster's current version by iterating through the
// provided update history until it finds the first version with update State of Completed. If a
// Completed version is not found the version of the oldest history entry, which is the originally
// installed version, is returned. If history is empty the empty string is returned.
func GetCurrentVersion(history []configv1.UpdateHistory) string {
for _, h := range history {
if h.State == configv1.CompletedUpdate {
klog.V(2).Infof("Cluster current version=%s", h.Version)
return h.Version
}
}
// Empty history should only occur if method is called early in startup before history is populated.
if len(history) != 0 {
return history[len(history)-1].Version
}
return ""
}