Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions apis/core/v1beta1/openstackcontrolplane_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -1068,22 +1068,6 @@ func (r *OpenStackControlPlane) DefaultServices() {
r.Spec.Designate.Template.Default()
}

// RabbitMQ
if r.Spec.Rabbitmq.Enabled || r.Spec.Rabbitmq.Templates != nil {
if r.Spec.Rabbitmq.Templates == nil {
r.Spec.Rabbitmq.Templates = ptr.To(map[string]rabbitmqv1.RabbitMqSpecCore{})
}

for key, template := range *r.Spec.Rabbitmq.Templates {
// Enforce queueType=Quorum for all new resources, preserve existing resources unchanged
if r.ObjectMeta.CreationTimestamp.IsZero() {
template.QueueType = "Quorum"
}
// By-value copy, need to update
(*r.Spec.Rabbitmq.Templates)[key] = template
}
}

// Redis
if r.Spec.Redis.Enabled || r.Spec.Redis.Templates != nil {
if r.Spec.Redis.Templates == nil {
Expand Down
48 changes: 0 additions & 48 deletions tests/functional/ctlplane/openstackoperator_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3145,54 +3145,6 @@ var _ = Describe("OpenStackOperator Webhook", func() {
Expect(OSCtlplane.Labels).Should(HaveKeyWithValue("core.openstack.org/openstackcontrolplane", "foo"))
})

It("Enforces queueType=Quorum for new resources", func() {
spec := GetDefaultOpenStackControlPlaneSpec()
spec["tls"] = GetTLSPublicSpec()

DeferCleanup(
th.DeleteInstance,
CreateOpenStackControlPlane(types.NamespacedName{Name: "test-new-quorum", Namespace: namespace}, spec),
)

OSCtlplane := GetOpenStackControlPlane(types.NamespacedName{Name: "test-new-quorum", Namespace: namespace})
Expect(OSCtlplane.Spec.Rabbitmq.Templates).Should(Not(BeNil()))

// Verify that all templates get queueType=Quorum for new resources
for templateName, template := range *OSCtlplane.Spec.Rabbitmq.Templates {
Expect(template.QueueType).Should(Equal("Quorum"), "RabbitMQ template %s should have queueType=Quorum", templateName)
}
})

It("Preserves existing queueType values on updates", func() {
spec := GetDefaultOpenStackControlPlaneSpec()
spec["tls"] = GetTLSPublicSpec()

// Create a resource first (will get Quorum by default)
ctlplane := CreateOpenStackControlPlane(types.NamespacedName{Name: "test-preserve-existing", Namespace: namespace}, spec)
DeferCleanup(th.DeleteInstance, ctlplane)

// Manually set it to Mirrored to simulate existing deployment
Eventually(func(g Gomega) {
existingCtlplane := GetOpenStackControlPlane(types.NamespacedName{Name: "test-preserve-existing", Namespace: namespace})
(*existingCtlplane.Spec.Rabbitmq.Templates)["rabbitmq"] = rabbitmqv1.RabbitMqSpecCore{
QueueType: "Mirrored", // Simulate existing value
}
g.Expect(k8sClient.Update(ctx, existingCtlplane)).Should(Succeed())
}).Should(Succeed())

// Verify it's preserved on subsequent updates
Eventually(func(g Gomega) {
updatedCtlplane := GetOpenStackControlPlane(types.NamespacedName{Name: "test-preserve-existing", Namespace: namespace})
updatedCtlplane.Spec.Secret = "updated-secret" // Trigger webhook
g.Expect(k8sClient.Update(ctx, updatedCtlplane)).Should(Succeed())

// Should still be Mirrored after update
finalCtlplane := GetOpenStackControlPlane(types.NamespacedName{Name: "test-preserve-existing", Namespace: namespace})
rabbitTemplate := (*finalCtlplane.Spec.Rabbitmq.Templates)["rabbitmq"]
g.Expect(rabbitTemplate.QueueType).Should(Equal("Mirrored"), "Existing queueType should be preserved")
}).Should(Succeed())
})

It("calls placement validation webhook", func() {
spec := GetDefaultOpenStackControlPlaneSpec()
spec["tls"] = GetTLSPublicSpec()
Expand Down
Loading