Skip to content

Commit 4053d7c

Browse files
committed
Make deprecated parameter optional
1 parent 7e5a34a commit 4053d7c

14 files changed

Lines changed: 54 additions & 48 deletions

‎api/bases/cinder.openstack.org_cinders.yaml‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2089,7 +2089,6 @@ spec:
20892089
e.g. to check logs
20902090
type: boolean
20912091
rabbitMqClusterName:
2092-
default: rabbitmq
20932092
description: |-
20942093
RabbitMQ instance name
20952094
Needed to request a transportURL that is created and used in Cinder
@@ -2125,7 +2124,6 @@ spec:
21252124
- cinderScheduler
21262125
- databaseInstance
21272126
- memcachedInstance
2128-
- rabbitMqClusterName
21292127
- secret
21302128
type: object
21312129
status:

‎api/v1beta1/cinder_types.go‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,11 @@ type CinderSpecBase struct {
6565
// Might not be required in future
6666
DatabaseInstance string `json:"databaseInstance"`
6767

68-
// +kubebuilder:validation:Required
69-
// +kubebuilder:default=rabbitmq
68+
// +kubebuilder:validation:Optional
7069
// RabbitMQ instance name
7170
// Needed to request a transportURL that is created and used in Cinder
7271
// Deprecated: Use MessagingBus.Cluster instead
73-
RabbitMqClusterName string `json:"rabbitMqClusterName" deprecated:"messagingBus.cluster"`
72+
RabbitMqClusterName string `json:"rabbitMqClusterName,omitempty"`
7473

7574
// +kubebuilder:validation:Optional
7675
// MessagingBus configuration (username, vhost, and cluster)

‎api/v1beta1/cinder_webhook.go‎

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import (
2626

2727
"golang.org/x/exp/maps"
2828

29-
rabbitmqv1 "github.com/openstack-k8s-operators/infra-operator/apis/rabbitmq/v1beta1"
3029
topologyv1 "github.com/openstack-k8s-operators/infra-operator/apis/topology/v1beta1"
3130
"github.com/openstack-k8s-operators/lib-common/modules/common/service"
3231
"github.com/openstack-k8s-operators/lib-common/modules/common/util"
@@ -112,23 +111,14 @@ func (r *Cinder) Default() {
112111

113112
// Default - set defaults for this Cinder spec
114113
func (spec *CinderSpecBase) Default() {
115-
// Only migrate from deprecated field if the new field is not already set
114+
// Default MessagingBus.Cluster if not set
115+
// Migration from deprecated fields is handled by openstack-operator
116116
if spec.MessagingBus.Cluster == "" {
117-
rabbitmqv1.DefaultRabbitMqConfig(&spec.MessagingBus, spec.RabbitMqClusterName)
117+
spec.MessagingBus.Cluster = "rabbitmq"
118118
}
119119

120-
// Default NotificationsBus if NotificationsBusInstance is specified
121-
if spec.NotificationsBusInstance != nil && *spec.NotificationsBusInstance != "" {
122-
if spec.NotificationsBus == nil {
123-
// Initialize empty NotificationsBus - credentials will be created dynamically
124-
// to ensure separation from MessagingBus (RPC and notifications should never share credentials)
125-
spec.NotificationsBus = &rabbitmqv1.RabbitMqConfig{}
126-
}
127-
// Always default the Cluster field from NotificationsBusInstance if it's empty
128-
if spec.NotificationsBus.Cluster == "" {
129-
rabbitmqv1.DefaultRabbitMqConfig(spec.NotificationsBus, *spec.NotificationsBusInstance)
130-
}
131-
}
120+
// NotificationsBus.Cluster is not defaulted - it must be explicitly set if NotificationsBus is configured
121+
// This ensures users make a conscious choice about which cluster to use for notifications
132122

133123
if spec.DBPurge.Age == 0 {
134124
spec.DBPurge.Age = cinderDefaults.DBPurgeAge

‎config/crd/bases/cinder.openstack.org_cinders.yaml‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2089,7 +2089,6 @@ spec:
20892089
e.g. to check logs
20902090
type: boolean
20912091
rabbitMqClusterName:
2092-
default: rabbitmq
20932092
description: |-
20942093
RabbitMQ instance name
20952094
Needed to request a transportURL that is created and used in Cinder
@@ -2125,7 +2124,6 @@ spec:
21252124
- cinderScheduler
21262125
- databaseInstance
21272126
- memcachedInstance
2128-
- rabbitMqClusterName
21292127
- secret
21302128
type: object
21312129
status:

‎test/functional/cinder_controller_test.go‎

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ var _ = Describe("Cinder controller", func() {
8686
Expect(Cinder.Spec.DatabaseInstance).Should(Equal("openstack"))
8787
Expect(Cinder.Spec.DatabaseAccount).Should(Equal(cinderTest.CinderDataBaseAccount))
8888
Expect(Cinder.Spec.MemcachedInstance).Should(Equal(cinderTest.MemcachedInstance))
89-
Expect(Cinder.Spec.RabbitMqClusterName).Should(Equal(cinderTest.RabbitmqClusterName))
89+
Expect(Cinder.Spec.MessagingBus.Cluster).Should(Equal(cinderTest.RabbitmqClusterName))
9090
Expect(Cinder.Spec.ServiceUser).Should(Equal(cinderTest.CinderServiceUser))
9191
})
9292
It("should have the Status fields initialized", func() {
@@ -464,9 +464,11 @@ var _ = Describe("Cinder controller", func() {
464464
}
465465

466466
rawSpec := map[string]any{
467-
"secret": SecretName,
468-
"databaseInstance": "openstack",
469-
"rabbitMqClusterName": "rabbitmq",
467+
"secret": SecretName,
468+
"databaseInstance": "openstack",
469+
"messagingBus": map[string]any{
470+
"cluster": "rabbitmq",
471+
},
470472
"cinderAPI": map[string]any{
471473
"containerImage": cinderv1.CinderAPIContainerImage,
472474
"networkAttachments": []string{"internalapi"},
@@ -1229,10 +1231,12 @@ var _ = Describe("Cinder controller", func() {
12291231
When("Cinder CR instance is built with ExtraMounts", func() {
12301232
BeforeEach(func() {
12311233
rawSpec := map[string]any{
1232-
"secret": SecretName,
1233-
"databaseInstance": "openstack",
1234-
"rabbitMqClusterName": "rabbitmq",
1235-
"extraMounts": GetExtraMounts(),
1234+
"secret": SecretName,
1235+
"databaseInstance": "openstack",
1236+
"messagingBus": map[string]any{
1237+
"cluster": "rabbitmq",
1238+
},
1239+
"extraMounts": GetExtraMounts(),
12361240
"cinderAPI": map[string]any{
12371241
"containerImage": cinderv1.CinderAPIContainerImage,
12381242
},
@@ -1293,10 +1297,14 @@ var _ = Describe("Cinder controller", func() {
12931297
When("Cinder instance has notifications enabled", func() {
12941298
BeforeEach(func() {
12951299
rawSpec := map[string]any{
1296-
"secret": SecretName,
1297-
"databaseInstance": "openstack",
1298-
"rabbitMqClusterName": "rabbitmq",
1299-
"notificationsBusInstance": "rabbitmq",
1300+
"secret": SecretName,
1301+
"databaseInstance": "openstack",
1302+
"messagingBus": map[string]any{
1303+
"cluster": "rabbitmq",
1304+
},
1305+
"notificationsBus": map[string]any{
1306+
"cluster": "rabbitmq",
1307+
},
13001308
"cinderAPI": map[string]any{
13011309
"containerImage": cinderv1.CinderAPIContainerImage,
13021310
},
@@ -2049,10 +2057,10 @@ var _ = Describe("Cinder with RabbitMQ custom vhost and user", func() {
20492057
"vhost": "main-vhost",
20502058
}
20512059
spec["notificationsBus"] = map[string]any{
2052-
"user": "notifications-user",
2053-
"vhost": "notifications-vhost",
2060+
"cluster": "rabbitmq-notifications",
2061+
"user": "notifications-user",
2062+
"vhost": "notifications-vhost",
20542063
}
2055-
spec["notificationsBusInstance"] = "rabbitmq-notifications"
20562064
DeferCleanup(th.DeleteInstance, CreateCinder(cinderTest.Instance, spec))
20572065
DeferCleanup(k8sClient.Delete, ctx, CreateCinderMessageBusSecret(cinderTest.Instance.Namespace, cinderTest.RabbitmqSecretName))
20582066
DeferCleanup(k8sClient.Delete, ctx, CreateCinderMessageBusSecret(cinderTest.Instance.Namespace, "rabbitmq-notifications-secret"))
@@ -2102,7 +2110,9 @@ var _ = Describe("Cinder with RabbitMQ custom vhost and user", func() {
21022110
When("Cinder is created with notifications bus using default credentials", func() {
21032111
BeforeEach(func() {
21042112
spec := GetDefaultCinderSpec()
2105-
spec["notificationsBusInstance"] = "rabbitmq-notifications"
2113+
spec["notificationsBus"] = map[string]any{
2114+
"cluster": "rabbitmq-notifications",
2115+
}
21062116
DeferCleanup(th.DeleteInstance, CreateCinder(cinderTest.Instance, spec))
21072117
DeferCleanup(k8sClient.Delete, ctx, CreateCinderMessageBusSecret(cinderTest.Instance.Namespace, cinderTest.RabbitmqSecretName))
21082118
DeferCleanup(k8sClient.Delete, ctx, CreateCinderMessageBusSecret(cinderTest.Instance.Namespace, "rabbitmq-notifications-secret"))
@@ -2224,7 +2234,9 @@ var _ = Describe("Cinder with RabbitMQ custom vhost and user", func() {
22242234
BeforeEach(func() {
22252235
spec := GetDefaultCinderSpec()
22262236
// Start with notifications enabled
2227-
spec["notificationsBusInstance"] = "rabbitmq-notifications"
2237+
spec["notificationsBus"] = map[string]any{
2238+
"cluster": "rabbitmq-notifications",
2239+
}
22282240
DeferCleanup(th.DeleteInstance, CreateCinder(cinderTest.Instance, spec))
22292241
DeferCleanup(k8sClient.Delete, ctx, CreateCinderMessageBusSecret(cinderTest.Instance.Namespace, cinderTest.RabbitmqSecretName))
22302242
DeferCleanup(k8sClient.Delete, ctx, CreateCinderMessageBusSecret(cinderTest.Instance.Namespace, "rabbitmq-notifications-secret"))

‎test/kuttl/common/assert_sample_deployment.yaml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ spec:
99
debug = true
1010
databaseInstance: openstack
1111
databaseAccount: cinder
12-
rabbitMqClusterName: rabbitmq
12+
messagingBus:
13+
cluster: rabbitmq
1314
cinderAPI:
1415
replicas: 1
1516
cinderScheduler:

‎test/kuttl/common/assert_tls_sample_deployment.yaml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ spec:
99
debug = true
1010
databaseInstance: openstack
1111
databaseAccount: cinder
12-
rabbitMqClusterName: rabbitmq
12+
messagingBus:
13+
cluster: rabbitmq
1314
cinderAPI:
1415
replicas: 1
1516
tls:

‎test/kuttl/tests/cinder_scale/04-assert.yaml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ spec:
99
debug = true
1010
databaseInstance: openstack
1111
databaseAccount: cinder
12-
rabbitMqClusterName: rabbitmq
12+
messagingBus:
13+
cluster: rabbitmq
1314
cinderAPI:
1415
replicas: 1
1516
cinderScheduler:

‎test/kuttl/tests/cinder_scale/05-assert.yaml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ spec:
99
debug = true
1010
databaseInstance: openstack
1111
databaseAccount: cinder
12-
rabbitMqClusterName: rabbitmq
12+
messagingBus:
13+
cluster: rabbitmq
1314
cinderAPI:
1415
replicas: 1
1516
cinderScheduler:

‎test/kuttl/tests/cinder_scale/07-assert.yaml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ spec:
99
debug = true
1010
databaseInstance: openstack
1111
databaseAccount: cinder
12-
rabbitMqClusterName: rabbitmq
12+
messagingBus:
13+
cluster: rabbitmq
1314
cinderAPI:
1415
replicas: 1
1516
cinderScheduler:

0 commit comments

Comments
 (0)