Skip to content

Commit 031c50a

Browse files
committed
Move queueType default selection to infra-operator
This commit implements the following: - switches the default queueType value to None (instead of Mirrored) - adds logic to the webhook so that when queueType=None this is instead set to "Quorum" This would allow us to: - set a sane default for new clusters, unless the user decides otherwise - preserve existing clusters where queueType=Mirrored is configured - orchestrate migration from Mirrored to Quorum by adding logic that would react to the change of value Jira: https://issues.redhat.com/browse/OSPRH-21039
1 parent 7086a5e commit 031c50a

File tree

5 files changed

+32
-4
lines changed

5 files changed

+32
-4
lines changed

apis/bases/rabbitmq.openstack.org_rabbitmqs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1401,7 +1401,7 @@ spec:
14011401
type: string
14021402
type: object
14031403
queueType:
1404-
default: Mirrored
1404+
default: None
14051405
description: QueueType to eventually apply the ha-all policy or configure
14061406
default queue type for the cluster
14071407
enum:

apis/rabbitmq/v1beta1/rabbitmq_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ type RabbitMqSpecCore struct {
6767
TopologyRef *topologyv1.TopoRef `json:"topologyRef,omitempty"`
6868
// +kubebuilder:validation:Optional
6969
// +kubebuilder:validation:Enum=None;Mirrored;Quorum
70-
// +kubebuilder:default=Mirrored
70+
// +kubebuilder:default=None
7171
// QueueType to eventually apply the ha-all policy or configure default queue type for the cluster
7272
QueueType string `json:"queueType"`
7373
}

apis/rabbitmq/v1beta1/rabbitmq_webhook.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,10 @@ func (spec *RabbitMqSpec) Default() {
7272

7373
// Default - common validations go here (for the OpenStackControlplane which uses this one)
7474
func (spec *RabbitMqSpecCore) Default() {
75-
//nothing to validate yet
75+
// Set a sensible default for QueueType only when not explicitly provided
76+
if spec.QueueType == "None" {
77+
spec.QueueType = "Quorum"
78+
}
7679
}
7780

7881
// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation.

config/crd/bases/rabbitmq.openstack.org_rabbitmqs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1401,7 +1401,7 @@ spec:
14011401
type: string
14021402
type: object
14031403
queueType:
1404-
default: Mirrored
1404+
default: None
14051405
description: QueueType to eventually apply the ha-all policy or configure
14061406
default queue type for the cluster
14071407
enum:

tests/functional/rabbitmq_controller_test.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,31 @@ var _ = Describe("RabbitMQ Controller", func() {
5555
DeferCleanup(th.DeleteConfigMap, clusterCm)
5656
})
5757

58+
When("QueueType defaulting and explicit values", func() {
59+
It("defaults QueueType to Quorum when unspecified", func() {
60+
spec := GetDefaultRabbitMQSpec()
61+
rabbitmq := CreateRabbitMQ(rabbitmqName, spec)
62+
DeferCleanup(th.DeleteInstance, rabbitmq)
63+
64+
Eventually(func(g Gomega) {
65+
instance := GetRabbitMQ(rabbitmqName)
66+
g.Expect(instance.Spec.QueueType).To(Equal("Quorum"))
67+
}, timeout, interval).Should(Succeed())
68+
})
69+
70+
It("preserves explicitly set QueueType", func() {
71+
spec := GetDefaultRabbitMQSpec()
72+
spec["queueType"] = "Mirrored"
73+
rabbitmq := CreateRabbitMQ(rabbitmqName, spec)
74+
DeferCleanup(th.DeleteInstance, rabbitmq)
75+
76+
Eventually(func(g Gomega) {
77+
instance := GetRabbitMQ(rabbitmqName)
78+
g.Expect(instance.Spec.QueueType).To(Equal("Mirrored"))
79+
}, timeout, interval).Should(Succeed())
80+
})
81+
})
82+
5883
When("a default RabbitMQ gets created", func() {
5984
BeforeEach(func() {
6085
rabbitmq := CreateRabbitMQ(rabbitmqName, GetDefaultRabbitMQSpec())

0 commit comments

Comments
 (0)