Skip to content

Commit

Permalink
Merge pull request #232 from karelyatin/OSPRH-2437
Browse files Browse the repository at this point in the history
[ovn-northd] Don't set DeployReady condition with replicas 0
  • Loading branch information
openshift-merge-bot[bot] committed Feb 21, 2024
2 parents 94285b3 + a26b9f4 commit e97a8e5
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
2 changes: 2 additions & 0 deletions controllers/ovnnorthd_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,8 @@ func (r *OVNNorthdReconciler) reconcileNormal(ctx context.Context, instance *ovn

if instance.Status.ReadyCount > 0 {
instance.Status.Conditions.MarkTrue(condition.DeploymentReadyCondition, condition.DeploymentReadyMessage)
} else if *instance.Spec.Replicas == 0 {
instance.Status.Conditions.Remove(condition.DeploymentReadyCondition)
}
// create Deployment - end

Expand Down
39 changes: 39 additions & 0 deletions tests/functional/ovnnorthd_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,45 @@ var _ = Describe("OVNNorthd controller", func() {

})

When("A OVNNorthd instance is created with 0 replicas", func() {
var ovnNorthdName types.NamespacedName
BeforeEach(func() {
dbs := CreateOVNDBClusters(namespace, map[string][]string{}, 1)
DeferCleanup(DeleteOVNDBClusters, dbs)
spec := GetDefaultOVNNorthdSpec()
replicas := int32(0)
spec.Replicas = &replicas
ovnNorthdName = ovn.CreateOVNNorthd(namespace, spec)
DeferCleanup(ovn.DeleteOVNNorthd, ovnNorthdName)
})

It("should create a Deployment with 0 replicas", func() {
deplName := types.NamespacedName{
Namespace: namespace,
Name: "ovn-northd",
}

depl := th.GetDeployment(deplName)
Expect(*(depl.Spec.Replicas)).Should(Equal(int32(0)))
})

It("should not have deploy ready condition", func() {
Eventually(func(g Gomega) {
ovnNorthd := GetOVNNorthd(ovnNorthdName)
g.Expect(ovnNorthd.Status.Conditions.Has(condition.DeploymentReadyCondition)).To(BeFalse())
}, timeout, interval).Should(Succeed())
})

It("should be in ready condition", func() {
th.ExpectCondition(
ovnNorthdName,
ConditionGetterFunc(OVNNorthdConditionGetter),
condition.ReadyCondition,
corev1.ConditionTrue,
)
})
})

When("OVNNorthd is created with networkAttachments", func() {
var ovnNorthdName types.NamespacedName

Expand Down

0 comments on commit e97a8e5

Please sign in to comment.