Skip to content

Commit

Permalink
Merge pull request openstack-k8s-operators#661 from booxter/allow-dis…
Browse files Browse the repository at this point in the history
…abling-ovn

Validate ready status is removed for ovn when it's disabled
  • Loading branch information
openshift-merge-bot[bot] authored Feb 13, 2024
2 parents 10230e3 + c13dcf8 commit bfb07d3
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 6 deletions.
3 changes: 0 additions & 3 deletions pkg/openstack/ovn.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ func ReconcileOVNDbClusters(ctx context.Context, instance *corev1beta1.OpenStack
if _, err := EnsureDeleted(ctx, helper, OVNDBCluster); err != nil {
return false, err
}
instance.Status.Conditions.Remove(corev1beta1.OpenStackControlPlaneOVNReadyCondition)
continue
}

Expand Down Expand Up @@ -121,7 +120,6 @@ func ReconcileOVNNorthd(ctx context.Context, instance *corev1beta1.OpenStackCont
if _, err := EnsureDeleted(ctx, helper, OVNNorthd); err != nil {
return false, err
}
instance.Status.Conditions.Remove(corev1beta1.OpenStackControlPlaneOVNReadyCondition)
return false, nil
}

Expand Down Expand Up @@ -170,7 +168,6 @@ func ReconcileOVNController(ctx context.Context, instance *corev1beta1.OpenStack
if _, err := EnsureDeleted(ctx, helper, OVNController); err != nil {
return false, err
}
instance.Status.Conditions.Remove(corev1beta1.OpenStackControlPlaneOVNReadyCondition)
return false, nil
}

Expand Down
5 changes: 5 additions & 0 deletions tests/functional/base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,3 +269,8 @@ func GetOpenStackControlPlane(name types.NamespacedName) *corev1.OpenStackContro
}, timeout, interval).Should(Succeed())
return instance
}

func OpenStackControlPlaneConditionGetter(name types.NamespacedName) condition.Conditions {
instance := GetOpenStackControlPlane(name)
return instance.Status.Conditions
}
31 changes: 28 additions & 3 deletions tests/functional/openstackoperator_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
corev1 "k8s.io/api/core/v1"
k8s_corev1 "k8s.io/api/core/v1"
k8s_errors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/types"
Expand All @@ -33,6 +33,7 @@ import (
. "github.com/openstack-k8s-operators/lib-common/modules/common/test/helpers"
"github.com/openstack-k8s-operators/lib-common/modules/common/tls"
clientv1 "github.com/openstack-k8s-operators/openstack-operator/apis/client/v1beta1"
corev1 "github.com/openstack-k8s-operators/openstack-operator/apis/core/v1beta1"
ovnv1 "github.com/openstack-k8s-operators/ovn-operator/api/v1beta1"
)

Expand Down Expand Up @@ -162,10 +163,10 @@ var _ = Describe("OpenStackOperator controller", func() {
names.OpenStackClientName,
ConditionGetterFunc(OpenStackClientConditionGetter),
clientv1.OpenStackClientReadyCondition,
corev1.ConditionTrue,
k8s_corev1.ConditionTrue,
)

pod := &corev1.Pod{}
pod := &k8s_corev1.Pod{}
err := th.K8sClient.Get(ctx, names.OpenStackClientName, pod)
g.Expect(pod).Should(Not(BeNil()))
g.Expect(err).ToNot(HaveOccurred())
Expand Down Expand Up @@ -201,6 +202,8 @@ var _ = Describe("OpenStackOperator controller", func() {
},
},
}
// TODO: had to disable tls to allow control plane status to update
spec["tls"] = map[string]interface{}{}
DeferCleanup(
th.DeleteInstance,
CreateOpenStackControlPlane(names.OpenStackControlplaneName, spec),
Expand Down Expand Up @@ -231,6 +234,22 @@ var _ = Describe("OpenStackOperator controller", func() {
ovnDbServerSB := ovn.GetOVNDBCluster(names.OVNDbServerSBName)
g.Expect(ovnDbServerSB).Should(Not(BeNil()))
}, timeout, interval).Should(Succeed())

// set ready states for each ovn component
ovn.SimulateOVNNorthdReady(names.OVNNorthdName)
ovn.SimulateOVNDBClusterReady(names.OVNDbServerNBName)
ovn.SimulateOVNDBClusterReady(names.OVNDbServerSBName)
ovn.SimulateOVNControllerReady(names.OVNControllerName)

// expect the ready status to propagate to control plane object
Eventually(func(g Gomega) {
th.ExpectCondition(
names.OpenStackControlplaneName,
ConditionGetterFunc(OpenStackControlPlaneConditionGetter),
corev1.OpenStackControlPlaneOVNReadyCondition,
k8s_corev1.ConditionTrue,
)
}, timeout, interval).Should(Succeed())
})

It("should remove OVN resources on disable", func() {
Expand Down Expand Up @@ -265,6 +284,12 @@ var _ = Describe("OpenStackOperator controller", func() {
instance := &ovnv1.OVNController{}
g.Expect(th.K8sClient.Get(th.Ctx, names.OVNControllerName, instance)).Should(Not(Succeed()))
}, timeout, interval).Should(Succeed())

// expect the ovn ready condition removed to not affect deployment success
Eventually(func(g Gomega) {
conditions := OpenStackControlPlaneConditionGetter(names.OpenStackControlplaneName)
g.Expect(conditions.Has(corev1.OpenStackControlPlaneOVNReadyCondition)).To(BeFalse())
}, timeout, interval).Should(Succeed())
})
})
})
Expand Down

0 comments on commit bfb07d3

Please sign in to comment.