Skip to content

Commit 91b11e2

Browse files
Merge pull request #1314 from harche/OTA-1860-allow-signature-policy-override
OTA-1860: Stop blocking patch updates when cluster version overrides are set
2 parents c4fb92f + 6f8f984 commit 91b11e2

4 files changed

Lines changed: 41 additions & 11 deletions

File tree

pkg/cvo/cvo_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2876,7 +2876,7 @@ func TestOperator_upgradeableSync(t *testing.T) {
28762876
Type: configv1.OperatorUpgradeable,
28772877
Status: configv1.ConditionFalse,
28782878
Reason: "ClusterVersionOverridesSet",
2879-
Message: "Disabling ownership via cluster version overrides prevents upgrades. Please remove overrides before continuing.",
2879+
Message: "Disabling ownership via cluster version overrides prevents upgrades between minor or major versions. Please remove overrides before requesting a minor or major version update.",
28802880
}},
28812881
},
28822882
},
@@ -3189,7 +3189,7 @@ func TestOperator_upgradeableSync(t *testing.T) {
31893189
Type: configv1.OperatorUpgradeable,
31903190
Status: configv1.ConditionFalse,
31913191
Reason: "MultipleReasons",
3192-
Message: "Cluster should not be upgraded between minor or major versions for multiple reasons: ClusterVersionOverridesSet,ClusterOperatorsNotUpgradeable\n* Disabling ownership via cluster version overrides prevents upgrades. Please remove overrides before continuing.\n* Multiple cluster operators should not be upgraded between minor or major versions:\n* Cluster operator default-operator-1 should not be upgraded between minor or major versions: RandomReason: some random reason why upgrades are not safe.\n* Cluster operator default-operator-2 should not be upgraded between minor or major versions: RandomReason2: some random reason 2 why upgrades are not safe.",
3192+
Message: "Cluster should not be upgraded between minor or major versions for multiple reasons: ClusterVersionOverridesSet,ClusterOperatorsNotUpgradeable\n* Disabling ownership via cluster version overrides prevents upgrades between minor or major versions. Please remove overrides before requesting a minor or major version update.\n* Multiple cluster operators should not be upgraded between minor or major versions:\n* Cluster operator default-operator-1 should not be upgraded between minor or major versions: RandomReason: some random reason why upgrades are not safe.\n* Cluster operator default-operator-2 should not be upgraded between minor or major versions: RandomReason2: some random reason 2 why upgrades are not safe.",
31933193
}, {
31943194
Type: "UpgradeableClusterOperators",
31953195
Status: configv1.ConditionFalse,
@@ -3199,7 +3199,7 @@ func TestOperator_upgradeableSync(t *testing.T) {
31993199
Type: "UpgradeableClusterVersionOverrides",
32003200
Status: configv1.ConditionFalse,
32013201
Reason: "ClusterVersionOverridesSet",
3202-
Message: "Disabling ownership via cluster version overrides prevents upgrades. Please remove overrides before continuing.",
3202+
Message: "Disabling ownership via cluster version overrides prevents upgrades between minor or major versions. Please remove overrides before requesting a minor or major version update.",
32033203
}},
32043204
},
32053205
},

pkg/cvo/upgradeable.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ func (check *clusterVersionOverridesUpgradeable) Check() *configv1.ClusterOperat
260260
}
261261

262262
cond.Reason = "ClusterVersionOverridesSet"
263-
cond.Message = "Disabling ownership via cluster version overrides prevents upgrades. Please remove overrides before continuing."
263+
cond.Message = "Disabling ownership via cluster version overrides prevents upgrades between minor or major versions. Please remove overrides before requesting a minor or major version update."
264264
return cond
265265
}
266266

pkg/payload/precondition/clusterversion/upgradeable.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func ClusterVersionOverridesCondition(cv *configv1.ClusterVersion) *configv1.Clu
4040
Type: internal.UpgradeableClusterVersionOverrides,
4141
Status: configv1.ConditionFalse,
4242
Reason: "ClusterVersionOverridesSet",
43-
Message: "Disabling ownership via cluster version overrides prevents upgrades. Please remove overrides before continuing.",
43+
Message: "Disabling ownership via cluster version overrides prevents upgrades between minor or major versions. Please remove overrides before requesting a minor or major version update.",
4444
}
4545
return &condition
4646
}
@@ -100,15 +100,17 @@ func (pf *Upgradeable) Run(ctx context.Context, releaseContext precondition.Rele
100100
klog.V(4).Infof("The current version is %s parsed from %s and the target version is %s parsed from %s", currentVersion.String(), cv.Status.Desired.Version, targetVersion.String(), releaseContext.DesiredVersion)
101101
patchOnly := targetVersion.Major == currentVersion.Major && targetVersion.Minor == currentVersion.Minor
102102
if targetVersion.LTE(currentVersion) || patchOnly {
103-
// When Upgradeable==False, a patch level update with the same minor version is allowed unless overrides are set.
103+
// When Upgradeable==False, a patch level update with the same minor version is allowed.
104104
// However, minor or major version updates are blocked when Upgradeable==False.
105105
// This Upgradeable precondition is only concerned about moving forward, i.e., do not care about downgrade which is taken care of by the Rollback precondition
106106
if condition := ClusterVersionOverridesCondition(cv); condition != nil {
107-
klog.V(2).Infof("Retarget from %s to %s is blocked by %s: %s", currentVersion.String(), targetVersion.String(), condition.Reason, condition.Message)
107+
message := fmt.Sprintf("Retarget from %s to %s is not blocked by %s. But the cluster-version operator is not managing these resources; they are currently the responsibility of the agent that set the overrides: %s", currentVersion.String(), targetVersion.String(), condition.Reason, condition.Message)
108+
klog.V(2).Info(message)
108109
return &precondition.Error{
109-
Reason: condition.Reason,
110-
Message: condition.Message,
111-
Name: pf.Name(),
110+
Reason: condition.Reason,
111+
Message: message,
112+
Name: pf.Name(),
113+
NonBlockingWarning: true,
112114
}
113115
} else {
114116
if completedVersion, majorOrMinor := majorOrMinorUpdateFrom(cv.Status, currentVersion); completedVersion != "" && patchOnly {

pkg/payload/precondition/clusterversion/upgradeable_test.go

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ func TestUpgradeableRun(t *testing.T) {
2727
tests := []struct {
2828
name string
2929
upgradeable *configv1.ConditionStatus
30+
overrides []configv1.ComponentOverride
3031
completedVersion string
3132
currVersion string
3233
desiredVersion string
@@ -80,6 +81,31 @@ func TestUpgradeableRun(t *testing.T) {
8081
currVersion: "4.1.3",
8182
desiredVersion: "4.1.4",
8283
},
84+
{
85+
name: "move-z, with false condition and overrides, is non-blocking warning",
86+
upgradeable: ptr(configv1.ConditionFalse),
87+
currVersion: "4.1.3",
88+
desiredVersion: "4.1.4",
89+
overrides: []configv1.ComponentOverride{
90+
{Kind: "Deployment", Group: "apps", Namespace: "openshift-monitoring", Name: "prometheus", Unmanaged: true},
91+
},
92+
expected: &precondition.Error{
93+
NonBlockingWarning: true,
94+
Name: "ClusterVersionUpgradeable",
95+
Message: "Retarget from 4.1.3 to 4.1.4 is not blocked by ClusterVersionOverridesSet. But the cluster-version operator is not managing these resources; they are currently the responsibility of the agent that set the overrides: Disabling ownership via cluster version overrides prevents upgrades between minor or major versions. Please remove overrides before requesting a minor or major version update.",
96+
Reason: "ClusterVersionOverridesSet",
97+
},
98+
},
99+
{
100+
name: "move-y, with false condition and overrides, is still blocking",
101+
upgradeable: ptr(configv1.ConditionFalse),
102+
currVersion: "4.1.1",
103+
desiredVersion: "4.2.1",
104+
overrides: []configv1.ComponentOverride{
105+
{Kind: "Deployment", Group: "apps", Namespace: "openshift-monitoring", Name: "prometheus", Unmanaged: true},
106+
},
107+
expected: &precondition.Error{Name: "ClusterVersionUpgradeable", Message: "set to False", Reason: "bla"},
108+
},
83109
{
84110
name: "empty target",
85111
},
@@ -167,7 +193,9 @@ func TestUpgradeableRun(t *testing.T) {
167193
t.Run(tc.name, func(t *testing.T) {
168194
clusterVersion := &configv1.ClusterVersion{
169195
ObjectMeta: metav1.ObjectMeta{Name: "version"},
170-
Spec: configv1.ClusterVersionSpec{},
196+
Spec: configv1.ClusterVersionSpec{
197+
Overrides: tc.overrides,
198+
},
171199
Status: configv1.ClusterVersionStatus{
172200
Desired: configv1.Release{Version: tc.currVersion},
173201
History: []configv1.UpdateHistory{{State: configv1.CompletedUpdate, Version: tc.completedVersion}},

0 commit comments

Comments
 (0)