Skip to content

Commit

Permalink
Merge pull request #175 from kajinamit/replicas-type
Browse files Browse the repository at this point in the history
Fix defaulting of Replicas spec
  • Loading branch information
openshift-merge-robot authored Jul 17, 2023
2 parents 6a7c822 + 0b2fdbf commit ab698f1
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion api/v1beta1/horizon_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type HorizonSpec struct {
// +kubebuilder:validation:Maximum=32
// +kubebuilder:validation:Minimum=0
// Replicas of horizon API to run
Replicas int32 `json:"replicas"`
Replicas *int32 `json:"replicas"`

// +kubebuilder:validation:Required
// Secret containing OpenStack password information for Horizon Secret Key
Expand Down
5 changes: 5 additions & 0 deletions api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/horizon/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func Deployment(instance *horizonv1.Horizon, configHash string, labels map[strin
Selector: &metav1.LabelSelector{
MatchLabels: labels,
},
Replicas: &instance.Spec.Replicas,
Replicas: instance.Spec.Replicas,
Template: corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: labels,
Expand Down
8 changes: 5 additions & 3 deletions tests/functional/horizon_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ var _ = Describe("Horizon controller", func() {
It("should have the Spec and Status fields initialized", func() {
horizon := GetHorizon(horizonName)
Expect(horizon.Spec.Secret).Should(Equal("test-osp-secret"))
Expect(*(horizon.Spec.Replicas)).Should(Equal(int32(1)))
})

It("should have a finalizer", func() {
Expand Down Expand Up @@ -230,7 +231,7 @@ var _ = Describe("Horizon controller", func() {
})
keystoneAPI := th.CreateKeystoneAPI(namespace)
DeferCleanup(th.DeleteKeystoneAPI, keystoneAPI)
th.SimulateDeploymentReadyWithPods(deploymentName, map[string][]string{})
th.SimulateDeploymentReplicaReady(deploymentName)
})

It("should have deployment ready", func() {
Expand All @@ -248,8 +249,9 @@ var _ = Describe("Horizon controller", func() {
)
})
It("should have ReadyCount set", func() {
horizon := GetHorizon(horizonName)
Expect(horizon.Status.ReadyCount).Should(Equal(horizon.Spec.Replicas))
Eventually(func() int32 {
return GetHorizon(horizonName).Status.ReadyCount
}, timeout, interval).Should(Equal(int32(1)))
})
})
})

0 comments on commit ab698f1

Please sign in to comment.