Skip to content

Commit 145dc1d

Browse files
committed
Make deprecated parameter optional
1 parent 3019421 commit 145dc1d

File tree

16 files changed

+113
-70
lines changed

16 files changed

+113
-70
lines changed

api/bases/nova.openstack.org_nova.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ spec:
5454
Service instance used for the Nova API DB.
5555
type: string
5656
apiMessageBusInstance:
57-
default: rabbitmq
5857
description: |-
5958
APIMessageBusInstance is the name of the RabbitMqCluster CR to select
6059
the Message Bus Service instance used by the Nova top level services to
6160
communicate.
61+
Deprecated: Use MessagingBus.Cluster instead
6262
type: string
6363
apiServiceTemplate:
6464
default:
@@ -388,11 +388,11 @@ spec:
388388
Service instance used as the DB of this cell.
389389
type: string
390390
cellMessageBusInstance:
391-
default: rabbitmq
392391
description: |-
393392
CellMessageBusInstance is the name of the RabbitMqCluster CR to select
394393
the Message Bus Service instance used by the nova services to
395394
communicate in this cell. For cell0 it is unused.
395+
Deprecated: Use MessagingBus.Cluster instead
396396
type: string
397397
conductorServiceTemplate:
398398
description: ConductorServiceTemplate - defines the cell conductor
@@ -1332,8 +1332,9 @@ spec:
13321332
cell1:
13331333
cellDatabaseAccount: nova-cell1
13341334
cellDatabaseInstance: openstack-cell1
1335-
cellMessageBusInstance: rabbitmq-cell1
13361335
hasAPIAccess: true
1336+
messagingBus:
1337+
cluster: rabbitmq-cell1
13371338
description: |-
13381339
Cells is a mapping of cell names to NovaCellTemplate objects defining
13391340
the cells in the deployment. The "cell0" cell is a mandatory cell in

api/v1beta1/nova_types.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,18 @@ type NovaSpecCore struct {
4444
APIDatabaseInstance string `json:"apiDatabaseInstance"`
4545

4646
// +kubebuilder:validation:Optional
47-
// +kubebuilder:default=rabbitmq
4847
// APIMessageBusInstance is the name of the RabbitMqCluster CR to select
4948
// the Message Bus Service instance used by the Nova top level services to
5049
// communicate.
51-
APIMessageBusInstance string `json:"apiMessageBusInstance" deprecated:"true" deprecatedNew:"messagingBus.cluster"`
50+
// Deprecated: Use MessagingBus.Cluster instead
51+
APIMessageBusInstance string `json:"apiMessageBusInstance,omitempty"`
5252

5353
// +kubebuilder:validation:Optional
5454
// MessagingBus configuration (username, vhost, and cluster)
5555
MessagingBus rabbitmqv1.RabbitMqConfig `json:"messagingBus,omitempty"`
5656

5757
// +kubebuilder:validation:Optional
58-
// +kubebuilder:default={cell0: {cellDatabaseAccount: nova-cell0, hasAPIAccess: true}, cell1: {cellDatabaseAccount: nova-cell1, cellDatabaseInstance: openstack-cell1, cellMessageBusInstance: rabbitmq-cell1, hasAPIAccess: true}}
58+
// +kubebuilder:default={cell0: {cellDatabaseAccount: nova-cell0, hasAPIAccess: true}, cell1: {cellDatabaseAccount: nova-cell1, cellDatabaseInstance: openstack-cell1, messagingBus: {cluster: rabbitmq-cell1}, hasAPIAccess: true}}
5959
// Cells is a mapping of cell names to NovaCellTemplate objects defining
6060
// the cells in the deployment. The "cell0" cell is a mandatory cell in
6161
// every deployment. Moreover any real deployment needs at least one

api/v1beta1/nova_webhook.go

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import (
2626
"fmt"
2727

2828
"github.com/google/go-cmp/cmp"
29-
rabbitmqv1 "github.com/openstack-k8s-operators/infra-operator/apis/rabbitmq/v1beta1"
3029
service "github.com/openstack-k8s-operators/lib-common/modules/common/service"
3130
"github.com/robfig/cron/v3"
3231

@@ -89,23 +88,14 @@ func (spec *NovaSpecCore) Default() {
8988
spec.APITimeout = novaDefaults.APITimeout
9089
}
9190

92-
// Default MessagingBus.Cluster from APIMessageBusInstance if not already set
91+
// Default MessagingBus.Cluster if not set
92+
// Migration from deprecated fields is handled by openstack-operator
9393
if spec.MessagingBus.Cluster == "" {
94-
spec.MessagingBus.Cluster = spec.APIMessageBusInstance
94+
spec.MessagingBus.Cluster = "rabbitmq"
9595
}
9696

97-
// Default NotificationsBus if NotificationsBusInstance is specified
98-
if spec.NotificationsBusInstance != nil && *spec.NotificationsBusInstance != "" {
99-
if spec.NotificationsBus == nil {
100-
// Initialize empty NotificationsBus - credentials will be created dynamically
101-
// to ensure separation from MessagingBus (RPC and notifications should never share credentials)
102-
spec.NotificationsBus = &rabbitmqv1.RabbitMqConfig{}
103-
}
104-
// Default cluster name if not already set
105-
if spec.NotificationsBus.Cluster == "" {
106-
spec.NotificationsBus.Cluster = *spec.NotificationsBusInstance
107-
}
108-
}
97+
// NotificationsBus.Cluster is not defaulted - it must be explicitly set if NotificationsBus is configured
98+
// This ensures users make a conscious choice about which cluster to use for notifications
10999

110100
for cellName, cellTemplate := range spec.CellTemplates {
111101

@@ -125,9 +115,14 @@ func (spec *NovaSpecCore) Default() {
125115
}
126116
}
127117

128-
// Default MessagingBus.Cluster from CellMessageBusInstance if not already set
118+
// Default MessagingBus.Cluster if not set
119+
// Migration from deprecated fields is handled by openstack-operator
129120
if cellTemplate.MessagingBus.Cluster == "" {
130-
cellTemplate.MessagingBus.Cluster = cellTemplate.CellMessageBusInstance
121+
if cellName == Cell0Name {
122+
cellTemplate.MessagingBus.Cluster = "rabbitmq"
123+
} else {
124+
cellTemplate.MessagingBus.Cluster = "rabbitmq-" + cellName
125+
}
131126
}
132127

133128
// "cellTemplate" is a by-value copy, so we need to re-inject the updated version of it into the map

api/v1beta1/novacell_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ type NovaCellTemplate struct {
4646
CellDatabaseAccount string `json:"cellDatabaseAccount"`
4747

4848
// +kubebuilder:validation:Optional
49-
// +kubebuilder:default=rabbitmq
5049
// CellMessageBusInstance is the name of the RabbitMqCluster CR to select
5150
// the Message Bus Service instance used by the nova services to
5251
// communicate in this cell. For cell0 it is unused.
53-
CellMessageBusInstance string `json:"cellMessageBusInstance" deprecated:"true" deprecatedNew:"messagingBus.cluster"`
52+
// Deprecated: Use MessagingBus.Cluster instead
53+
CellMessageBusInstance string `json:"cellMessageBusInstance,omitempty"`
5454

5555
// +kubebuilder:validation:Optional
5656
// MessagingBus configuration (username, vhost, and cluster)

config/crd/bases/nova.openstack.org_nova.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ spec:
5454
Service instance used for the Nova API DB.
5555
type: string
5656
apiMessageBusInstance:
57-
default: rabbitmq
5857
description: |-
5958
APIMessageBusInstance is the name of the RabbitMqCluster CR to select
6059
the Message Bus Service instance used by the Nova top level services to
6160
communicate.
61+
Deprecated: Use MessagingBus.Cluster instead
6262
type: string
6363
apiServiceTemplate:
6464
default:
@@ -388,11 +388,11 @@ spec:
388388
Service instance used as the DB of this cell.
389389
type: string
390390
cellMessageBusInstance:
391-
default: rabbitmq
392391
description: |-
393392
CellMessageBusInstance is the name of the RabbitMqCluster CR to select
394393
the Message Bus Service instance used by the nova services to
395394
communicate in this cell. For cell0 it is unused.
395+
Deprecated: Use MessagingBus.Cluster instead
396396
type: string
397397
conductorServiceTemplate:
398398
description: ConductorServiceTemplate - defines the cell conductor
@@ -1332,8 +1332,9 @@ spec:
13321332
cell1:
13331333
cellDatabaseAccount: nova-cell1
13341334
cellDatabaseInstance: openstack-cell1
1335-
cellMessageBusInstance: rabbitmq-cell1
13361335
hasAPIAccess: true
1336+
messagingBus:
1337+
cluster: rabbitmq-cell1
13371338
description: |-
13381339
Cells is a mapping of cell names to NovaCellTemplate objects defining
13391340
the cells in the deployment. The "cell0" cell is a mandatory cell in

config/samples/nova_v1beta1_nova-multi-cell.yaml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ spec:
1010
# This is the name of the single RabbitMqCluster CR we deploy today
1111
# The Service is labelled with
1212
# app.kubernetes.io/component=rabbitmq, app.kubernetes.io/name=<RabbitMqCluster.Name>
13-
apiMessageBusInstance: rabbitmq
13+
messagingBus:
14+
cluster: rabbitmq
1415
# This is the name of the KeystoneAPI CR we deploy today
1516
# The Service is labelled with service=keystone,internal=true
1617
keystoneInstance: keystone
@@ -49,7 +50,8 @@ spec:
4950
cell0:
5051
cellDatabaseInstance: openstack
5152
cellDatabaseAccount: nova-cell0
52-
cellMessageBusInstance: rabbitmq
53+
messagingBus:
54+
cluster: rabbitmq
5355
# cell0 always needs access to the API DB and MQ as it hosts the super
5456
# conductor. It will inherit the API DB and MQ access from the Nova CR
5557
# that creates it.
@@ -63,7 +65,8 @@ spec:
6365
cell1:
6466
cellDatabaseInstance: mariadb-cell1
6567
cellDatabaseAccount: nova-cell1
66-
cellMessageBusInstance: rabbitmq-cell1
68+
messagingBus:
69+
cluster: rabbitmq-cell1
6770
# cell1 will have upcalls support. It will inherit the API DB and MQ
6871
# access from the Nova CR that creates it.
6972
hasAPIAccess: true
@@ -82,7 +85,8 @@ spec:
8285
cell2:
8386
cellDatabaseInstance: mariadb-cell2
8487
cellDatabaseAccount: nova-cell2
85-
cellMessageBusInstance: rabbitmq-cell2
88+
messagingBus:
89+
cluster: rabbitmq-cell2
8690
# cell2 will not get the API DB and MQ connection info from the Nova CR
8791
hasAPIAccess: false
8892
conductorServiceTemplate:

test/functional/base_test.go

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,12 @@ func NovaSchedulerConditionGetter(name types.NamespacedName) condition.Condition
112112

113113
func GetDefaultNovaSpec() map[string]any {
114114
return map[string]any{
115-
"secret": SecretName,
116-
"cellTemplates": map[string]any{},
117-
"apiMessageBusInstance": cell0.TransportURLName.Name,
118-
"apiDatabaseAccount": novaNames.APIMariaDBDatabaseAccount.Name,
115+
"secret": SecretName,
116+
"cellTemplates": map[string]any{},
117+
"apiDatabaseAccount": novaNames.APIMariaDBDatabaseAccount.Name,
118+
"messagingBus": map[string]any{
119+
"cluster": cell0.TransportURLName.Name,
120+
},
119121
}
120122
}
121123

@@ -161,7 +163,9 @@ func CreateNovaWithCell0(name types.NamespacedName) client.Object {
161163
},
162164
},
163165
},
164-
"apiMessageBusInstance": cell0.TransportURLName.Name,
166+
"messagingBus": map[string]any{
167+
"cluster": cell0.TransportURLName.Name,
168+
},
165169
},
166170
}
167171

@@ -1025,7 +1029,9 @@ func CreateNovaWithNCellsAndEnsureReady(cellNumber int, novaNames *NovaNames) {
10251029
template["cellDatabaseAccount"] = account.Name
10261030
if i != 0 {
10271031
// cell0
1028-
template["cellMessageBusInstance"] = cell.TransportURLName.Name
1032+
template["messagingBus"] = map[string]any{
1033+
"cluster": cell.TransportURLName.Name,
1034+
}
10291035
}
10301036

10311037
if i == 1 {
@@ -1046,7 +1052,9 @@ func CreateNovaWithNCellsAndEnsureReady(cellNumber int, novaNames *NovaNames) {
10461052
spec := GetDefaultNovaSpec()
10471053
spec["cellTemplates"] = cellTemplates
10481054
spec["apiDatabaseInstance"] = novaNames.APIMariaDBDatabaseName.Name
1049-
spec["apiMessageBusInstance"] = novaNames.Cells["cell0"].TransportURLName.Name
1055+
spec["messagingBus"] = map[string]any{
1056+
"cluster": novaNames.Cells["cell0"].TransportURLName.Name,
1057+
}
10501058

10511059
// Deploy Nova and simulate its dependencies
10521060
DeferCleanup(th.DeleteInstance, CreateNova(novaNames.NovaName, spec))

test/functional/nova_controller_test.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,9 +1184,11 @@ var _ = Describe("Nova controller", func() {
11841184
},
11851185
)
11861186
rawSpec := map[string]any{
1187-
"secret": SecretName,
1188-
"apiDatabaseAccount": novaNames.APIMariaDBDatabaseAccount.Name,
1189-
"apiMessageBusInstance": cell0.TransportURLName.Name,
1187+
"secret": SecretName,
1188+
"apiDatabaseAccount": novaNames.APIMariaDBDatabaseAccount.Name,
1189+
"messagingBus": map[string]any{
1190+
"cluster": cell0.TransportURLName.Name,
1191+
},
11901192
"cellTemplates": map[string]any{
11911193
"cell0": map[string]any{
11921194
"apiDatabaseAccount": novaNames.APIMariaDBDatabaseAccount.Name,
@@ -1480,7 +1482,9 @@ var _ = Describe("Nova controller", func() {
14801482
cell1Template := GetDefaultNovaCellTemplate()
14811483
cell1Template["cellDatabaseInstance"] = cell1.MariaDBDatabaseName.Name
14821484
cell1Template["cellDatabaseAccount"] = cell1.MariaDBAccountName.Name
1483-
cell1Template["cellMessageBusInstance"] = cell1.TransportURLName.Name
1485+
cell1Template["messagingBus"] = map[string]any{
1486+
"cluster": cell1.TransportURLName.Name,
1487+
}
14841488
// We reference the cell1 topology that is inherited by the cell1 conductor,
14851489
// metadata, and novncproxy
14861490
cell1Template["topologyRef"] = map[string]any{"name": topologyRefCell.Name}
@@ -1496,7 +1500,9 @@ var _ = Describe("Nova controller", func() {
14961500
"enabled": false,
14971501
}
14981502
spec["apiDatabaseInstance"] = novaNames.APIMariaDBDatabaseName.Name
1499-
spec["apiMessageBusInstance"] = cell0.TransportURLName.Name
1503+
spec["messagingBus"] = map[string]any{
1504+
"cluster": cell0.TransportURLName.Name,
1505+
}
15001506
// We reference the global topology and is inherited by the sub components
15011507
// except cell1 that has an override
15021508
spec["topologyRef"] = map[string]any{"name": topologyRefTopLevel.Name}

test/functional/nova_multicell_test.go

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@ var _ = Describe("Nova multi cell", func() {
7979
cell1Template := GetDefaultNovaCellTemplate()
8080
cell1Template["cellDatabaseInstance"] = cell1.MariaDBDatabaseName.Name
8181
cell1Template["cellDatabaseAccount"] = cell1.MariaDBAccountName.Name
82-
cell1Template["cellMessageBusInstance"] = cell1.TransportURLName.Name
82+
cell1Template["messagingBus"] = map[string]any{
83+
"cluster": cell1.TransportURLName.Name,
84+
}
8385
cell1Template["passwordSelectors"] = map[string]any{
8486
"database": "NovaCell1DatabasePassword",
8587
}
@@ -92,7 +94,9 @@ var _ = Describe("Nova multi cell", func() {
9294
cell2Template := GetDefaultNovaCellTemplate()
9395
cell2Template["cellDatabaseInstance"] = cell2.MariaDBDatabaseName.Name
9496
cell2Template["cellDatabaseAccount"] = cell2.MariaDBAccountName.Name
95-
cell2Template["cellMessageBusInstance"] = cell2.TransportURLName.Name
97+
cell2Template["messagingBus"] = map[string]any{
98+
"cluster": cell2.TransportURLName.Name,
99+
}
96100
cell2Template["hasAPIAccess"] = false
97101
cell2Template["passwordSelectors"] = map[string]any{
98102
"database": "NovaCell2DatabasePassword",
@@ -104,7 +108,9 @@ var _ = Describe("Nova multi cell", func() {
104108
"cell2": cell2Template,
105109
}
106110
spec["apiDatabaseInstance"] = novaNames.APIMariaDBDatabaseName.Name
107-
spec["apiMessageBusInstance"] = cell0.TransportURLName.Name
111+
spec["messagingBus"] = map[string]any{
112+
"cluster": cell0.TransportURLName.Name,
113+
}
108114

109115
DeferCleanup(th.DeleteInstance, CreateNova(novaNames.NovaName, spec))
110116
DeferCleanup(keystone.DeleteKeystoneAPI, keystone.CreateKeystoneAPI(novaNames.NovaName.Namespace))
@@ -675,15 +681,19 @@ var _ = Describe("Nova multi cell", func() {
675681
// will act both as a super conductor and as cell1 conductor
676682
cell1Template["cellDatabaseInstance"] = novaNames.APIMariaDBDatabaseName.Name
677683
cell1Template["cellDatabaseAccount"] = cell1.MariaDBAccountName.Name
678-
cell1Template["cellMessageBusInstance"] = cell0.TransportURLName.Name
684+
cell1Template["messagingBus"] = map[string]any{
685+
"cluster": cell0.TransportURLName.Name,
686+
}
679687
cell1Template["hasAPIAccess"] = true
680688

681689
spec["cellTemplates"] = map[string]any{
682690
"cell0": cell0Template,
683691
"cell1": cell1Template,
684692
}
685693
spec["apiDatabaseInstance"] = novaNames.APIMariaDBDatabaseName.Name
686-
spec["apiMessageBusInstance"] = cell0.TransportURLName.Name
694+
spec["messagingBus"] = map[string]any{
695+
"cluster": cell0.TransportURLName.Name,
696+
}
687697

688698
DeferCleanup(th.DeleteInstance, CreateNova(novaNames.NovaName, spec))
689699
memcachedSpec := infra.GetDefaultMemcachedSpec()
@@ -790,14 +800,18 @@ var _ = Describe("Nova multi cell", func() {
790800
cell1Template := GetDefaultNovaCellTemplate()
791801
cell1Template["cellDatabaseInstance"] = cell1.MariaDBDatabaseName.Name
792802
cell1Template["cellDatabaseAccount"] = cell1.MariaDBAccountName.Name
793-
cell1Template["cellMessageBusInstance"] = cell1.TransportURLName.Name
803+
cell1Template["messagingBus"] = map[string]any{
804+
"cluster": cell1.TransportURLName.Name,
805+
}
794806

795807
spec["cellTemplates"] = map[string]any{
796808
"cell0": cell0Template,
797809
"cell1": cell1Template,
798810
}
799811
spec["apiDatabaseInstance"] = novaNames.APIMariaDBDatabaseName.Name
800-
spec["apiMessageBusInstance"] = cell0.TransportURLName.Name
812+
spec["messagingBus"] = map[string]any{
813+
"cluster": cell0.TransportURLName.Name,
814+
}
801815

802816
DeferCleanup(th.DeleteInstance, CreateNova(novaNames.NovaName, spec))
803817
memcachedSpec := infra.GetDefaultMemcachedSpec()
@@ -849,7 +863,9 @@ var _ = Describe("Nova multi cell", func() {
849863
cell1Template := GetDefaultNovaCellTemplate()
850864
cell1Template["cellDatabaseInstance"] = cell1.MariaDBDatabaseName.Name
851865
cell1Template["cellDatabaseAccount"] = cell1.MariaDBAccountName.Name
852-
cell1Template["cellMessageBusInstance"] = cell1.TransportURLName.Name
866+
cell1Template["messagingBus"] = map[string]any{
867+
"cluster": cell1.TransportURLName.Name,
868+
}
853869
cell1Template["metadataServiceTemplate"] = map[string]any{
854870
"enabled": true,
855871
}
@@ -862,7 +878,9 @@ var _ = Describe("Nova multi cell", func() {
862878
"enabled": false,
863879
}
864880
spec["apiDatabaseInstance"] = novaNames.APIMariaDBDatabaseName.Name
865-
spec["apiMessageBusInstance"] = cell0.TransportURLName.Name
881+
spec["messagingBus"] = map[string]any{
882+
"cluster": cell0.TransportURLName.Name,
883+
}
866884

867885
DeferCleanup(th.DeleteInstance, CreateNova(novaNames.NovaName, spec))
868886
memcachedSpec := infra.GetDefaultMemcachedSpec()

0 commit comments

Comments
 (0)