Skip to content

Commit 0ca20b7

Browse files
committed
check ClusterImagePolicy conflicts only on default clusters
Signed-off-by: Qi Wang <qiwan@redhat.com>
1 parent e2499c0 commit 0ca20b7

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

pkg/operator/status.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,24 @@ func (optr *Operator) syncUpgradeableStatus(co *configv1.ClusterOperator) error
280280
coStatusCondition.Reason = "ClusterOnCgroupV1"
281281
coStatusCondition.Message = "Cluster is using deprecated cgroup v1 and is not upgradable. Please update the `CgroupMode` in the `nodes.config.openshift.io` object to 'v2'. Once upgraded, the cluster cannot be changed back to cgroup v1"
282282
}
283+
284+
// Check for ClusterImagePolicy named "openshift" which conflicts with the cluster default ClusterImagePolicy object
285+
// Only check for Default featureSet clusters allowing 4.20 ci techpreview builds upgrades
286+
fg, err := optr.configClient.ConfigV1().FeatureGates().Get(context.TODO(), "cluster", metav1.GetOptions{})
287+
if err != nil && !apierrors.IsNotFound(err) {
288+
return err
289+
}
290+
if fg.Spec.FeatureSet == configv1.Default {
291+
// Check for ClusterImagePolicy named "openshift" which conflicts with the cluster default ClusterImagePolicy object
292+
if _, err = optr.configClient.ConfigV1().ClusterImagePolicies().Get(context.TODO(), "openshift", metav1.GetOptions{}); err == nil {
293+
coStatusCondition.Status = configv1.ConditionFalse
294+
coStatusCondition.Reason = "ConflictingClusterImagePolicy"
295+
coStatusCondition.Message = "ClusterImagePolicy resource named 'openshift' conflicts with the cluster default ClusterImagePolicy object and blocks upgrades. Please delete the 'openshift' ClusterImagePolicy resource and reapply it with a different name if needed"
296+
} else if !apierrors.IsNotFound(err) {
297+
return err
298+
}
299+
}
300+
283301
var degraded, interrupted bool
284302
for _, pool := range pools {
285303
interrupted = isPoolStatusConditionTrue(pool, mcfgv1.MachineConfigPoolBuildInterrupted)

0 commit comments

Comments
 (0)