Skip to content

Commit 7dcedb5

Browse files
committed
Rabbitmq vhost and user support
Add new messagingBus and notificationsBus interfaces to hold cluster, user and vhost names for optional usage. The controller adds these values to the TransportURL create request when present. Additionally, we migrate RabbitMQ cluster name to RabbitMq config struct using DefaultRabbitMqConfig from infra-operator to automatically populate the new Cluster field from legacy RabbitMqClusterName. Finally, we use the cinder-operator pattern to fetch the latest statefulset copy and not rely on the cached copy (should help with flaky ci). Example usage: spec: messagingBus: cluster: rpc-rabbitmq user: rpc-user vhost: rpc-vhost notificationsBus: cluster: notifications-rabbitmq user: notifications-user vhost: notifications-vhost Jira: https://issues.redhat.com/browse/OSPRH-23748
1 parent 45f2982 commit 7dcedb5

13 files changed

+993
-31
lines changed

api/bases/manila.openstack.org_manilas.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1788,6 +1788,22 @@ spec:
17881788
default: memcached
17891789
description: Memcached instance name.
17901790
type: string
1791+
messagingBus:
1792+
description: MessagingBus configuration (username, vhost, and cluster)
1793+
properties:
1794+
cluster:
1795+
description: Name of the cluster
1796+
minLength: 1
1797+
type: string
1798+
user:
1799+
description: User - RabbitMQ username
1800+
type: string
1801+
vhost:
1802+
description: Vhost - RabbitMQ vhost name
1803+
type: string
1804+
required:
1805+
- cluster
1806+
type: object
17911807
nodeSelector:
17921808
additionalProperties:
17931809
type: string
@@ -1796,6 +1812,23 @@ spec:
17961812
NodeSelector here acts as a default value and can be overridden by service
17971813
specific NodeSelector Settings.
17981814
type: object
1815+
notificationsBus:
1816+
description: NotificationsBus configuration (username, vhost, and
1817+
cluster) for notifications
1818+
properties:
1819+
cluster:
1820+
description: Name of the cluster
1821+
minLength: 1
1822+
type: string
1823+
user:
1824+
description: User - RabbitMQ username
1825+
type: string
1826+
vhost:
1827+
description: Vhost - RabbitMQ vhost name
1828+
type: string
1829+
required:
1830+
- cluster
1831+
type: object
17991832
notificationsBusInstance:
18001833
description: |-
18011834
RabbitMQ instance name used to request a transportURL that is used for

api/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ require (
1616
github.com/cespare/xxhash/v2 v2.3.0 // indirect
1717
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
1818
github.com/emicklei/go-restful/v3 v3.12.2 // indirect
19-
github.com/evanphx/json-patch v5.9.11+incompatible // indirect
2019
github.com/evanphx/json-patch/v5 v5.9.11 // indirect
2120
github.com/fsnotify/fsnotify v1.9.0 // indirect
2221
github.com/fxamacker/cbor/v2 v2.9.0 // indirect
@@ -45,6 +44,7 @@ require (
4544
github.com/prometheus/client_model v0.6.2 // indirect
4645
github.com/prometheus/common v0.65.0 // indirect
4746
github.com/prometheus/procfs v0.16.1 // indirect
47+
github.com/rabbitmq/cluster-operator/v2 v2.16.0 // indirect
4848
github.com/spf13/pflag v1.0.7 // indirect
4949
github.com/stretchr/testify v1.11.1 // indirect
5050
github.com/x448/float16 v0.8.4 // indirect

api/go.sum

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww=
12
github.com/Masterminds/semver/v3 v3.4.0 h1:Zog+i5UMtVoCU8oKka5P7i9q9HgrJeGzI9SA1Xbatp0=
23
github.com/Masterminds/semver/v3 v3.4.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
34
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
@@ -84,6 +85,8 @@ github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.2025123021
8485
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20251230215914-6ba873b49a35/go.mod h1:kycZyoe7OZdW1HUghr2nI3N7wSJtNahXf6b/ypD14f4=
8586
github.com/openstack-k8s-operators/lib-common/modules/storage v0.6.1-0.20251230215914-6ba873b49a35 h1:8WZYfCt1VJHa5sJRX0UhpmoXud/fn8LHQhXsakdYXuQ=
8687
github.com/openstack-k8s-operators/lib-common/modules/storage v0.6.1-0.20251230215914-6ba873b49a35/go.mod h1:H0aQANk8iJPRhS2Bg9n6cYb/IHF0Cks9g7+uZG04Rhk=
88+
github.com/openstack-k8s-operators/rabbitmq-cluster-operator/v2 v2.6.1-0.20250929174222-a0d328fa4dec h1:saovr368HPAKHN0aRPh8h8n9s9dn3d8Frmfua0UYRlc=
89+
github.com/openstack-k8s-operators/rabbitmq-cluster-operator/v2 v2.6.1-0.20250929174222-a0d328fa4dec/go.mod h1:Nh2NEePLjovUQof2krTAg4JaAoLacqtPTZQXK6izNfg=
8790
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
8891
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
8992
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=

api/v1beta1/manila_types.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
package v1beta1
1818

1919
import (
20+
rabbitmqv1 "github.com/openstack-k8s-operators/infra-operator/apis/rabbitmq/v1beta1"
2021
topologyv1 "github.com/openstack-k8s-operators/infra-operator/apis/topology/v1beta1"
2122
"github.com/openstack-k8s-operators/lib-common/modules/common/condition"
2223
"github.com/openstack-k8s-operators/lib-common/modules/storage"
@@ -82,6 +83,14 @@ type ManilaSpecBase struct {
8283
// Needed to request a transportURL that is created and used in Manila
8384
RabbitMqClusterName string `json:"rabbitMqClusterName"`
8485

86+
// +kubebuilder:validation:Optional
87+
// MessagingBus configuration (username, vhost, and cluster)
88+
MessagingBus rabbitmqv1.RabbitMqConfig `json:"messagingBus,omitempty"`
89+
90+
// +kubebuilder:validation:Optional
91+
// NotificationsBus configuration (username, vhost, and cluster) for notifications
92+
NotificationsBus *rabbitmqv1.RabbitMqConfig `json:"notificationsBus,omitempty"`
93+
8594
// +kubebuilder:validation:Required
8695
// +kubebuilder:default=memcached
8796
// Memcached instance name.

api/v1beta1/manila_webhook.go

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ package v1beta1
2525
import (
2626
"fmt"
2727

28+
rabbitmqv1 "github.com/openstack-k8s-operators/infra-operator/apis/rabbitmq/v1beta1"
2829
topologyv1 "github.com/openstack-k8s-operators/infra-operator/apis/topology/v1beta1"
2930
"github.com/openstack-k8s-operators/lib-common/modules/common/service"
3031
"github.com/openstack-k8s-operators/lib-common/modules/common/util"
@@ -101,6 +102,18 @@ func (spec *ManilaSpec) Default() {
101102

102103
// Default - set defaults for this Manila spec base
103104
func (spec *ManilaSpecBase) Default() {
105+
// Default MessagingBus with cluster name from RabbitMqClusterName
106+
rabbitmqv1.DefaultRabbitMqConfig(&spec.MessagingBus, spec.RabbitMqClusterName)
107+
108+
// Default NotificationsBus if NotificationsBusInstance is specified
109+
if spec.NotificationsBusInstance != nil && *spec.NotificationsBusInstance != "" {
110+
if spec.NotificationsBus == nil {
111+
// Initialize empty NotificationsBus - credentials will be created dynamically
112+
// to ensure separation from MessagingBus (RPC and notifications should never share credentials)
113+
spec.NotificationsBus = &rabbitmqv1.RabbitMqConfig{}
114+
}
115+
rabbitmqv1.DefaultRabbitMqConfig(spec.NotificationsBus, *spec.NotificationsBusInstance)
116+
}
104117

105118
if spec.APITimeout == 0 {
106119
spec.APITimeout = manilaDefaults.APITimeout
@@ -200,6 +213,48 @@ func (r *Manila) ValidateUpdate(old runtime.Object) (admission.Warnings, error)
200213
func (spec *ManilaSpec) ValidateUpdate(old ManilaSpec, basePath *field.Path, namespace string) field.ErrorList {
201214
var allErrs field.ErrorList
202215

216+
// Validate deprecated fields and their new equivalents
217+
// Don't allow setting both old and new fields with different values
218+
// Users can either set both to the same value, or null out the old field and set the new one
219+
if spec.RabbitMqClusterName != "" && spec.MessagingBus.Cluster != "" &&
220+
spec.RabbitMqClusterName != spec.MessagingBus.Cluster {
221+
allErrs = append(allErrs, field.Invalid(
222+
basePath.Child("messagingBus").Child("cluster"),
223+
spec.MessagingBus.Cluster,
224+
fmt.Sprintf("messagingBus.cluster cannot differ from deprecated rabbitMqClusterName (%s). "+
225+
"Either use the new messagingBus.cluster field or the deprecated rabbitMqClusterName, but not both with different values",
226+
spec.RabbitMqClusterName)))
227+
}
228+
229+
// Similar validation for NotificationsBusInstance
230+
// Don't allow setting both old and new fields with different values
231+
if spec.NotificationsBusInstance != nil && *spec.NotificationsBusInstance != "" &&
232+
spec.NotificationsBus != nil && spec.NotificationsBus.Cluster != "" &&
233+
*spec.NotificationsBusInstance != spec.NotificationsBus.Cluster {
234+
allErrs = append(allErrs, field.Invalid(
235+
basePath.Child("notificationsBus").Child("cluster"),
236+
spec.NotificationsBus.Cluster,
237+
fmt.Sprintf("notificationsBus.cluster cannot differ from deprecated notificationsBusInstance (%s). "+
238+
"Either use the new notificationsBus.cluster field or the deprecated notificationsBusInstance, but not both with different values",
239+
*spec.NotificationsBusInstance)))
240+
}
241+
242+
// Reject changes to deprecated field unless nulling it out
243+
if spec.RabbitMqClusterName != old.RabbitMqClusterName && spec.RabbitMqClusterName != "" {
244+
allErrs = append(allErrs, field.Forbidden(
245+
basePath.Child("rabbitMqClusterName"),
246+
"rabbitMqClusterName is deprecated and cannot be changed. Please use messagingBus.cluster instead"))
247+
}
248+
249+
// Reject changes to deprecated field unless nulling it out
250+
if spec.NotificationsBusInstance != nil && old.NotificationsBusInstance != nil &&
251+
*spec.NotificationsBusInstance != *old.NotificationsBusInstance &&
252+
*spec.NotificationsBusInstance != "" {
253+
allErrs = append(allErrs, field.Forbidden(
254+
basePath.Child("notificationsBusInstance"),
255+
"notificationsBusInstance is deprecated and cannot be changed. Please use notificationsBus.cluster instead"))
256+
}
257+
203258
// validate the service base parameters
204259
allErrs = append(allErrs, spec.ValidateBaseParams(basePath)...)
205260

@@ -217,6 +272,48 @@ func (spec *ManilaSpec) ValidateUpdate(old ManilaSpec, basePath *field.Path, nam
217272
func (spec *ManilaSpecCore) ValidateUpdate(old ManilaSpecCore, basePath *field.Path, namespace string) field.ErrorList {
218273
var allErrs field.ErrorList
219274

275+
// Validate deprecated fields and their new equivalents
276+
// Don't allow setting both old and new fields with different values
277+
// Users can either set both to the same value, or null out the old field and set the new one
278+
if spec.RabbitMqClusterName != "" && spec.MessagingBus.Cluster != "" &&
279+
spec.RabbitMqClusterName != spec.MessagingBus.Cluster {
280+
allErrs = append(allErrs, field.Invalid(
281+
basePath.Child("messagingBus").Child("cluster"),
282+
spec.MessagingBus.Cluster,
283+
fmt.Sprintf("messagingBus.cluster cannot differ from deprecated rabbitMqClusterName (%s). "+
284+
"Either use the new messagingBus.cluster field or the deprecated rabbitMqClusterName, but not both with different values",
285+
spec.RabbitMqClusterName)))
286+
}
287+
288+
// Similar validation for NotificationsBusInstance
289+
// Don't allow setting both old and new fields with different values
290+
if spec.NotificationsBusInstance != nil && *spec.NotificationsBusInstance != "" &&
291+
spec.NotificationsBus != nil && spec.NotificationsBus.Cluster != "" &&
292+
*spec.NotificationsBusInstance != spec.NotificationsBus.Cluster {
293+
allErrs = append(allErrs, field.Invalid(
294+
basePath.Child("notificationsBus").Child("cluster"),
295+
spec.NotificationsBus.Cluster,
296+
fmt.Sprintf("notificationsBus.cluster cannot differ from deprecated notificationsBusInstance (%s). "+
297+
"Either use the new notificationsBus.cluster field or the deprecated notificationsBusInstance, but not both with different values",
298+
*spec.NotificationsBusInstance)))
299+
}
300+
301+
// Reject changes to deprecated field unless nulling it out
302+
if spec.RabbitMqClusterName != old.RabbitMqClusterName && spec.RabbitMqClusterName != "" {
303+
allErrs = append(allErrs, field.Forbidden(
304+
basePath.Child("rabbitMqClusterName"),
305+
"rabbitMqClusterName is deprecated and cannot be changed. Please use messagingBus.cluster instead"))
306+
}
307+
308+
// Reject changes to deprecated field unless nulling it out
309+
if spec.NotificationsBusInstance != nil && old.NotificationsBusInstance != nil &&
310+
*spec.NotificationsBusInstance != *old.NotificationsBusInstance &&
311+
*spec.NotificationsBusInstance != "" {
312+
allErrs = append(allErrs, field.Forbidden(
313+
basePath.Child("notificationsBusInstance"),
314+
"notificationsBusInstance is deprecated and cannot be changed. Please use notificationsBus.cluster instead"))
315+
}
316+
220317
// validate the service base parameters
221318
allErrs = append(allErrs, spec.ValidateBaseParams(basePath)...)
222319

api/v1beta1/zz_generated.deepcopy.go

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/manila.openstack.org_manilas.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1788,6 +1788,22 @@ spec:
17881788
default: memcached
17891789
description: Memcached instance name.
17901790
type: string
1791+
messagingBus:
1792+
description: MessagingBus configuration (username, vhost, and cluster)
1793+
properties:
1794+
cluster:
1795+
description: Name of the cluster
1796+
minLength: 1
1797+
type: string
1798+
user:
1799+
description: User - RabbitMQ username
1800+
type: string
1801+
vhost:
1802+
description: Vhost - RabbitMQ vhost name
1803+
type: string
1804+
required:
1805+
- cluster
1806+
type: object
17911807
nodeSelector:
17921808
additionalProperties:
17931809
type: string
@@ -1796,6 +1812,23 @@ spec:
17961812
NodeSelector here acts as a default value and can be overridden by service
17971813
specific NodeSelector Settings.
17981814
type: object
1815+
notificationsBus:
1816+
description: NotificationsBus configuration (username, vhost, and
1817+
cluster) for notifications
1818+
properties:
1819+
cluster:
1820+
description: Name of the cluster
1821+
minLength: 1
1822+
type: string
1823+
user:
1824+
description: User - RabbitMQ username
1825+
type: string
1826+
vhost:
1827+
description: Vhost - RabbitMQ vhost name
1828+
type: string
1829+
required:
1830+
- cluster
1831+
type: object
17991832
notificationsBusInstance:
18001833
description: |-
18011834
RabbitMQ instance name used to request a transportURL that is used for
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
apiVersion: manila.openstack.org/v1beta1
2+
kind: Manila
3+
metadata:
4+
name: manila-rabbitmq-custom
5+
namespace: openstack
6+
spec:
7+
secret: osp-secret
8+
databaseInstance: openstack
9+
databaseAccount: manila
10+
rabbitMqClusterName: rabbitmq
11+
# Custom RabbitMQ configuration for the main messaging bus
12+
rabbitmq:
13+
user: main-user
14+
vhost: main-vhost
15+
# Optional: Separate RabbitMQ configuration for notifications
16+
notificationsBusInstance: rabbitmq-notification
17+
notificationsRabbitmq:
18+
user: notifications-user
19+
vhost: notifications-vhost
20+
memcachedInstance: memcached
21+
serviceUser: manila
22+
customServiceConfig: |
23+
[DEFAULT]
24+
debug = true
25+
manilaAPI:
26+
replicas: 1
27+
containerImage: quay.io/podified-antelope-centos9/openstack-manila-api:current-podified
28+
manilaScheduler:
29+
replicas: 1
30+
containerImage: quay.io/podified-antelope-centos9/openstack-manila-scheduler:current-podified
31+
manilaShares:
32+
share0:
33+
replicas: 1
34+
containerImage: quay.io/podified-antelope-centos9/openstack-manila-share:current-podified

internal/controller/manila_common.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import (
4242
// Static errors for manila controllers
4343
var (
4444
ErrNetworkAttachmentConfig = errors.New("not all pods have interfaces with ips as configured in NetworkAttachments")
45+
ErrStatefulSetWaiting = errors.New("waiting for StatefulSet to start reconciling")
4546
)
4647

4748
type conditionUpdater interface {

0 commit comments

Comments
 (0)