Skip to content

Commit

Permalink
Block upgrade for openshift-sdn
Browse files Browse the repository at this point in the history
This commit updates network cluster operator status condition with Upgradable
to False when networking plugin is with openshift-sdn. This would help CVO to
block cluster upgrade into 4.17 when it sees Upgradable=False from Cluster
Operator.

Signed-off-by: Periyasamy Palanisamy <pepalani@redhat.com>
  • Loading branch information
pperiyasamy committed Apr 4, 2024
1 parent 395a36a commit 23f5822
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/controller/operconfig/operconfig_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,11 @@ func (r *ReconcileOperConfig) Reconcile(ctx context.Context, request reconcile.R
r.status.UnsetProgressing(statusmanager.OperatorRender)
}

if operConfig.Spec.DefaultNetwork.OpenShiftSDNConfig != nil {
r.status.SetNotUpgradable(statusmanager.OperatorConfig, "UpdateOperatorConfig",
"OpenShiftSDN Upgrade won't be supported, consider migrating into OVN-Kubernetes")
}

// The first object we create should be the record of our applied configuration. The last object we create is config.openshift.io/v1/Network.Status
app, err := AppliedConfiguration(operConfig)
if err != nil {
Expand Down
33 changes: 33 additions & 0 deletions pkg/controller/statusmanager/status_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,39 @@ func (status *StatusManager) UnsetProgressing(statusLevel StatusLevel) {
status.unsetProgressing(statusLevel)
}

// syncNotUpgradable syncs the current Upgradable status
func (status *StatusManager) syncNotUpgradable() {
for _, c := range status.failing {
if c != nil && c.Type == operv1.OperatorStatusTypeUpgradeable {
status.set(false, *c)
return
}
}
status.set(
false,
operv1.OperatorCondition{
Type: operv1.OperatorStatusTypeUpgradeable,
Status: operv1.ConditionFalse,
},
)
}

func (status *StatusManager) setNotUpgradable(statusLevel StatusLevel, reason, message string) {
status.failing[statusLevel] = &operv1.OperatorCondition{
Type: operv1.OperatorStatusTypeUpgradeable,
Status: operv1.ConditionFalse,
Reason: reason,
Message: message,
}
status.syncNotUpgradable()
}

func (status *StatusManager) SetNotUpgradable(statusLevel StatusLevel, reason, message string) {
status.Lock()
defer status.Unlock()
status.setNotUpgradable(statusLevel, reason, message)
}

func (status *StatusManager) SetRelatedObjects(relatedObjects []configv1.ObjectReference) {
status.Lock()
defer status.Unlock()
Expand Down

0 comments on commit 23f5822

Please sign in to comment.