Skip to content

Commit bfb07d3

Browse files
Merge pull request #661 from booxter/allow-disabling-ovn
Validate ready status is removed for ovn when it's disabled
2 parents 10230e3 + c13dcf8 commit bfb07d3

File tree

3 files changed

+33
-6
lines changed

3 files changed

+33
-6
lines changed

pkg/openstack/ovn.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ func ReconcileOVNDbClusters(ctx context.Context, instance *corev1beta1.OpenStack
7373
if _, err := EnsureDeleted(ctx, helper, OVNDBCluster); err != nil {
7474
return false, err
7575
}
76-
instance.Status.Conditions.Remove(corev1beta1.OpenStackControlPlaneOVNReadyCondition)
7776
continue
7877
}
7978

@@ -121,7 +120,6 @@ func ReconcileOVNNorthd(ctx context.Context, instance *corev1beta1.OpenStackCont
121120
if _, err := EnsureDeleted(ctx, helper, OVNNorthd); err != nil {
122121
return false, err
123122
}
124-
instance.Status.Conditions.Remove(corev1beta1.OpenStackControlPlaneOVNReadyCondition)
125123
return false, nil
126124
}
127125

@@ -170,7 +168,6 @@ func ReconcileOVNController(ctx context.Context, instance *corev1beta1.OpenStack
170168
if _, err := EnsureDeleted(ctx, helper, OVNController); err != nil {
171169
return false, err
172170
}
173-
instance.Status.Conditions.Remove(corev1beta1.OpenStackControlPlaneOVNReadyCondition)
174171
return false, nil
175172
}
176173

tests/functional/base_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,3 +269,8 @@ func GetOpenStackControlPlane(name types.NamespacedName) *corev1.OpenStackContro
269269
}, timeout, interval).Should(Succeed())
270270
return instance
271271
}
272+
273+
func OpenStackControlPlaneConditionGetter(name types.NamespacedName) condition.Conditions {
274+
instance := GetOpenStackControlPlane(name)
275+
return instance.Status.Conditions
276+
}

tests/functional/openstackoperator_controller_test.go

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222

2323
. "github.com/onsi/ginkgo/v2"
2424
. "github.com/onsi/gomega"
25-
corev1 "k8s.io/api/core/v1"
25+
k8s_corev1 "k8s.io/api/core/v1"
2626
k8s_errors "k8s.io/apimachinery/pkg/api/errors"
2727
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
2828
"k8s.io/apimachinery/pkg/types"
@@ -33,6 +33,7 @@ import (
3333
. "github.com/openstack-k8s-operators/lib-common/modules/common/test/helpers"
3434
"github.com/openstack-k8s-operators/lib-common/modules/common/tls"
3535
clientv1 "github.com/openstack-k8s-operators/openstack-operator/apis/client/v1beta1"
36+
corev1 "github.com/openstack-k8s-operators/openstack-operator/apis/core/v1beta1"
3637
ovnv1 "github.com/openstack-k8s-operators/ovn-operator/api/v1beta1"
3738
)
3839

@@ -162,10 +163,10 @@ var _ = Describe("OpenStackOperator controller", func() {
162163
names.OpenStackClientName,
163164
ConditionGetterFunc(OpenStackClientConditionGetter),
164165
clientv1.OpenStackClientReadyCondition,
165-
corev1.ConditionTrue,
166+
k8s_corev1.ConditionTrue,
166167
)
167168

168-
pod := &corev1.Pod{}
169+
pod := &k8s_corev1.Pod{}
169170
err := th.K8sClient.Get(ctx, names.OpenStackClientName, pod)
170171
g.Expect(pod).Should(Not(BeNil()))
171172
g.Expect(err).ToNot(HaveOccurred())
@@ -201,6 +202,8 @@ var _ = Describe("OpenStackOperator controller", func() {
201202
},
202203
},
203204
}
205+
// TODO: had to disable tls to allow control plane status to update
206+
spec["tls"] = map[string]interface{}{}
204207
DeferCleanup(
205208
th.DeleteInstance,
206209
CreateOpenStackControlPlane(names.OpenStackControlplaneName, spec),
@@ -231,6 +234,22 @@ var _ = Describe("OpenStackOperator controller", func() {
231234
ovnDbServerSB := ovn.GetOVNDBCluster(names.OVNDbServerSBName)
232235
g.Expect(ovnDbServerSB).Should(Not(BeNil()))
233236
}, timeout, interval).Should(Succeed())
237+
238+
// set ready states for each ovn component
239+
ovn.SimulateOVNNorthdReady(names.OVNNorthdName)
240+
ovn.SimulateOVNDBClusterReady(names.OVNDbServerNBName)
241+
ovn.SimulateOVNDBClusterReady(names.OVNDbServerSBName)
242+
ovn.SimulateOVNControllerReady(names.OVNControllerName)
243+
244+
// expect the ready status to propagate to control plane object
245+
Eventually(func(g Gomega) {
246+
th.ExpectCondition(
247+
names.OpenStackControlplaneName,
248+
ConditionGetterFunc(OpenStackControlPlaneConditionGetter),
249+
corev1.OpenStackControlPlaneOVNReadyCondition,
250+
k8s_corev1.ConditionTrue,
251+
)
252+
}, timeout, interval).Should(Succeed())
234253
})
235254

236255
It("should remove OVN resources on disable", func() {
@@ -265,6 +284,12 @@ var _ = Describe("OpenStackOperator controller", func() {
265284
instance := &ovnv1.OVNController{}
266285
g.Expect(th.K8sClient.Get(th.Ctx, names.OVNControllerName, instance)).Should(Not(Succeed()))
267286
}, timeout, interval).Should(Succeed())
287+
288+
// expect the ovn ready condition removed to not affect deployment success
289+
Eventually(func(g Gomega) {
290+
conditions := OpenStackControlPlaneConditionGetter(names.OpenStackControlplaneName)
291+
g.Expect(conditions.Has(corev1.OpenStackControlPlaneOVNReadyCondition)).To(BeFalse())
292+
}, timeout, interval).Should(Succeed())
268293
})
269294
})
270295
})

0 commit comments

Comments
 (0)