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, It 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 18, 2024
1 parent b5b41b9 commit cfb9804
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 29 deletions.
26 changes: 20 additions & 6 deletions pkg/controller/statusmanager/status_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,12 +369,26 @@ func (status *StatusManager) set(reachedAvailableLevel bool, conditions ...operv
)
}

v1helpers.SetOperatorCondition(&oc.Status.Conditions,
operv1.OperatorCondition{
Type: operv1.OperatorStatusTypeUpgradeable,
Status: operv1.ConditionTrue,
},
)
if oc.Spec.DefaultNetwork.Type == operv1.NetworkTypeOpenShiftSDN {
// OpenShiftSDN is removed in 4.17, so block the upgrade if we have OpenShiftSDN in the spec.
v1helpers.SetOperatorCondition(&oc.Status.Conditions,
operv1.OperatorCondition{
Type: string(configv1.OperatorUpgradeable),
Status: operv1.ConditionFalse,
Reason: "OpenShiftSDNConfigured",
Message: "Cluster is configured with OpenShiftSDN, which is not supported in the next version. Please " +
"follow the documented steps to migrate from OpenShiftSDN to OVN-Kubernetes in order to be able to upgrade. " +
"https://docs.openshift.com/container-platform/4.16/networking/ovn_kubernetes_network_provider/migrate-from-openshift-sdn.html",
},
)
} else {
v1helpers.SetOperatorCondition(&oc.Status.Conditions,
operv1.OperatorCondition{
Type: string(configv1.OperatorUpgradeable),
Status: operv1.ConditionTrue,
},
)
}

operStatus = &oc.Status

Expand Down
99 changes: 76 additions & 23 deletions pkg/controller/statusmanager/status_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func TestStatusManager_set(t *testing.T) {
set(t, client, no)

condUpdate := operv1.OperatorCondition{
Type: operv1.OperatorStatusTypeUpgradeable,
Type: string(configv1.OperatorUpgradeable),
Status: operv1.ConditionTrue,
}

Expand Down Expand Up @@ -253,6 +253,59 @@ func TestStatusManager_set(t *testing.T) {
}
}

func TestStatusManager_set_OpenShiftSDN(t *testing.T) {
client := fake.NewFakeClient()
status := New(client, "testing", "")

// make the network.operator object
log.Print("Creating Network Operator Config")
no := &operv1.Network{
ObjectMeta: metav1.ObjectMeta{Name: names.OPERATOR_CONFIG},
Spec: operv1.NetworkSpec{
DefaultNetwork: operv1.DefaultNetworkDefinition{
Type: operv1.NetworkTypeOpenShiftSDN,
},
},
}

set(t, client, no)

condNoProgress := operv1.OperatorCondition{
Type: operv1.OperatorStatusTypeProgressing,
Status: operv1.ConditionFalse,
}
condAvailable := operv1.OperatorCondition{
Type: operv1.OperatorStatusTypeAvailable,
Status: operv1.ConditionTrue,
}

// Check if OpenShiftSDN will make operator non-upgradable
no.Spec = operv1.NetworkSpec{
DefaultNetwork: operv1.DefaultNetworkDefinition{
Type: operv1.NetworkTypeOpenShiftSDN,
},
}
set(t, client, no)

condUpdateBlocked := operv1.OperatorCondition{
Type: string(configv1.OperatorUpgradeable),
Status: operv1.ConditionFalse,
Reason: "OpenShiftSDNConfigured",
Message: "Cluster is configured with OpenShiftSDN, which is not supported in the next version. Please " +
"follow the documented steps to migrate from OpenShiftSDN to OVN-Kubernetes in order to be able to upgrade. " +
"https://docs.openshift.com/container-platform/4.16/networking/ovn_kubernetes_network_provider/migrate-from-openshift-sdn.html",
}
status.set(true, condNoProgress, condAvailable)

oc, err := getOC(client)
if err != nil {
t.Fatalf("error getting network.operator: %v", err)
}
if !conditionsEqual(oc.Status.Conditions, []operv1.OperatorCondition{condAvailable, condUpdateBlocked, condNoProgress}) {
t.Fatalf("unexpected Status.Conditions: %#v", oc.Status.Conditions)
}
}

func TestStatusManagerSetDegraded(t *testing.T) {
client := fake.NewFakeClient()
status := New(client, "testing", "")
Expand All @@ -265,7 +318,7 @@ func TestStatusManagerSetDegraded(t *testing.T) {
set(t, client, no)

condUpdate := operv1.OperatorCondition{
Type: operv1.OperatorStatusTypeUpgradeable,
Type: string(configv1.OperatorUpgradeable),
Status: operv1.ConditionTrue,
}
condFailCluster := operv1.OperatorCondition{
Expand Down Expand Up @@ -409,7 +462,7 @@ func TestStatusManagerSetFromDaemonSets(t *testing.T) {
Reason: "Deploying",
},
{
Type: operv1.OperatorStatusTypeUpgradeable,
Type: string(configv1.OperatorUpgradeable),
Status: operv1.ConditionTrue,
},
{
Expand Down Expand Up @@ -459,7 +512,7 @@ func TestStatusManagerSetFromDaemonSets(t *testing.T) {
Status: operv1.ConditionTrue,
},
{
Type: operv1.OperatorStatusTypeUpgradeable,
Type: string(configv1.OperatorUpgradeable),
Status: operv1.ConditionTrue,
},
{
Expand Down Expand Up @@ -517,7 +570,7 @@ func TestStatusManagerSetFromDaemonSets(t *testing.T) {
Status: operv1.ConditionFalse,
},
{
Type: operv1.OperatorStatusTypeUpgradeable,
Type: string(configv1.OperatorUpgradeable),
Status: operv1.ConditionTrue,
},
{
Expand Down Expand Up @@ -561,7 +614,7 @@ func TestStatusManagerSetFromDaemonSets(t *testing.T) {
Status: operv1.ConditionTrue,
},
{
Type: operv1.OperatorStatusTypeUpgradeable,
Type: string(configv1.OperatorUpgradeable),
Status: operv1.ConditionTrue,
},
{
Expand Down Expand Up @@ -602,7 +655,7 @@ func TestStatusManagerSetFromDaemonSets(t *testing.T) {
Status: operv1.ConditionTrue,
},
{
Type: operv1.OperatorStatusTypeUpgradeable,
Type: string(configv1.OperatorUpgradeable),
Status: operv1.ConditionTrue,
},
{
Expand Down Expand Up @@ -642,7 +695,7 @@ func TestStatusManagerSetFromDaemonSets(t *testing.T) {
Status: operv1.ConditionTrue,
},
{
Type: operv1.OperatorStatusTypeUpgradeable,
Type: string(configv1.OperatorUpgradeable),
Status: operv1.ConditionTrue,
},
{
Expand Down Expand Up @@ -686,7 +739,7 @@ func TestStatusManagerSetFromDaemonSets(t *testing.T) {
Status: operv1.ConditionTrue,
},
{
Type: operv1.OperatorStatusTypeUpgradeable,
Type: string(configv1.OperatorUpgradeable),
Status: operv1.ConditionTrue,
},
{
Expand Down Expand Up @@ -747,7 +800,7 @@ func TestStatusManagerSetFromDaemonSets(t *testing.T) {
Status: operv1.ConditionTrue,
},
{
Type: operv1.OperatorStatusTypeUpgradeable,
Type: string(configv1.OperatorUpgradeable),
Status: operv1.ConditionTrue,
},
{
Expand Down Expand Up @@ -799,7 +852,7 @@ func TestStatusManagerSetFromDaemonSets(t *testing.T) {
Status: operv1.ConditionFalse,
},
{
Type: operv1.OperatorStatusTypeUpgradeable,
Type: string(configv1.OperatorUpgradeable),
Status: operv1.ConditionTrue,
},
{
Expand Down Expand Up @@ -856,7 +909,7 @@ func TestStatusManagerSetFromDaemonSets(t *testing.T) {
Status: operv1.ConditionTrue,
},
{
Type: operv1.OperatorStatusTypeUpgradeable,
Type: string(configv1.OperatorUpgradeable),
Status: operv1.ConditionTrue,
},
{
Expand Down Expand Up @@ -896,7 +949,7 @@ func TestStatusManagerSetFromDaemonSets(t *testing.T) {
Status: operv1.ConditionTrue,
},
{
Type: operv1.OperatorStatusTypeUpgradeable,
Type: string(configv1.OperatorUpgradeable),
Status: operv1.ConditionTrue,
},
{
Expand Down Expand Up @@ -932,7 +985,7 @@ func TestStatusManagerSetFromDaemonSets(t *testing.T) {
Status: operv1.ConditionFalse,
},
{
Type: operv1.OperatorStatusTypeUpgradeable,
Type: string(configv1.OperatorUpgradeable),
Status: operv1.ConditionTrue,
},
{
Expand Down Expand Up @@ -994,7 +1047,7 @@ func TestStatusManagerSetFromDeployments(t *testing.T) {
Reason: "Deploying",
},
{
Type: operv1.OperatorStatusTypeUpgradeable,
Type: string(configv1.OperatorUpgradeable),
Status: operv1.ConditionTrue,
},
{
Expand Down Expand Up @@ -1031,7 +1084,7 @@ func TestStatusManagerSetFromDeployments(t *testing.T) {
Status: operv1.ConditionFalse,
},
{
Type: operv1.OperatorStatusTypeUpgradeable,
Type: string(configv1.OperatorUpgradeable),
Status: operv1.ConditionTrue,
},
{
Expand Down Expand Up @@ -1090,7 +1143,7 @@ func TestStatusManagerSetFromDeployments(t *testing.T) {
Status: operv1.ConditionTrue,
},
{
Type: operv1.OperatorStatusTypeUpgradeable,
Type: string(configv1.OperatorUpgradeable),
Status: operv1.ConditionTrue,
},
{
Expand Down Expand Up @@ -1154,7 +1207,7 @@ func TestStatusManagerSetFromDeployments(t *testing.T) {
Status: operv1.ConditionTrue,
},
{
Type: operv1.OperatorStatusTypeUpgradeable,
Type: string(configv1.OperatorUpgradeable),
Status: operv1.ConditionTrue,
},
{
Expand Down Expand Up @@ -1196,7 +1249,7 @@ func TestStatusManagerSetFromDeployments(t *testing.T) {
Status: operv1.ConditionTrue,
},
{
Type: operv1.OperatorStatusTypeUpgradeable,
Type: string(configv1.OperatorUpgradeable),
Status: operv1.ConditionTrue,
},
{
Expand Down Expand Up @@ -1236,7 +1289,7 @@ func TestStatusManagerSetFromDeployments(t *testing.T) {
Status: operv1.ConditionFalse,
},
{
Type: operv1.OperatorStatusTypeUpgradeable,
Type: string(configv1.OperatorUpgradeable),
Status: operv1.ConditionTrue,
},
{
Expand Down Expand Up @@ -1431,7 +1484,7 @@ func TestStatusManagerCheckCrashLoopBackOffPods(t *testing.T) {
Status: operv1.ConditionTrue,
},
{
Type: operv1.OperatorStatusTypeUpgradeable,
Type: string(configv1.OperatorUpgradeable),
Status: operv1.ConditionTrue,
},
{
Expand Down Expand Up @@ -1523,7 +1576,7 @@ func TestStatusManagerHyperShift(t *testing.T) {
Status: operv1.ConditionFalse,
},
{
Type: operv1.OperatorStatusTypeUpgradeable,
Type: string(configv1.OperatorUpgradeable),
Status: operv1.ConditionTrue,
},
}
Expand Down Expand Up @@ -1576,7 +1629,7 @@ func TestStatusManagerHyperShift(t *testing.T) {
Status: operv1.ConditionFalse,
},
{
Type: operv1.OperatorStatusTypeUpgradeable,
Type: string(configv1.OperatorUpgradeable),
Status: operv1.ConditionTrue,
},
{
Expand Down

0 comments on commit cfb9804

Please sign in to comment.