Skip to content

Commit 047d403

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. 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 c96d36e commit 047d403

File tree

14 files changed

+867
-29
lines changed

14 files changed

+867
-29
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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/openstack-k8s-operators/manila-operator/api
33
go 1.24.4
44

55
require (
6-
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20251205192058-5cfbada0ab96
6+
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20251217131115-0f117a938d4e
77
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20251122131503-b76943960b6c
88
github.com/openstack-k8s-operators/lib-common/modules/storage v0.6.1-0.20251122131503-b76943960b6c
99
k8s.io/api v0.31.14
@@ -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
@@ -43,6 +42,7 @@ require (
4342
github.com/prometheus/client_model v0.6.2 // indirect
4443
github.com/prometheus/common v0.65.0 // indirect
4544
github.com/prometheus/procfs v0.16.1 // indirect
45+
github.com/rabbitmq/cluster-operator/v2 v2.16.0 // indirect
4646
github.com/spf13/pflag v1.0.7 // indirect
4747
github.com/x448/float16 v0.8.4 // indirect
4848
go.yaml.in/yaml/v2 v2.4.2 // indirect

api/go.sum

Lines changed: 5 additions & 2 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=
@@ -78,12 +79,14 @@ github.com/onsi/ginkgo/v2 v2.27.2 h1:LzwLj0b89qtIy6SSASkzlNvX6WktqurSHwkk2ipF/Ns
7879
github.com/onsi/ginkgo/v2 v2.27.2/go.mod h1:ArE1D/XhNXBXCBkKOLkbsb2c81dQHCRcF5zwn/ykDRo=
7980
github.com/onsi/gomega v1.38.2 h1:eZCjf2xjZAqe+LeWvKb5weQ+NcPwX84kqJ0cZNxok2A=
8081
github.com/onsi/gomega v1.38.2/go.mod h1:W2MJcYxRGV63b418Ai34Ud0hEdTVXq9NW9+Sx6uXf3k=
81-
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20251205192058-5cfbada0ab96 h1:hPgCcrbRHBPfngaEPe6coaCtcauMolI71lfcLdinrKI=
82-
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20251205192058-5cfbada0ab96/go.mod h1:ZuglN7IqXfIo75WcJwe0NLHhu82Fs3k/5IXptqnO1H4=
82+
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20251217131115-0f117a938d4e h1:PIjcXzMMwfvBRFgFpaq/W9tqy0t2cYvcWX+kq6uNtTM=
83+
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20251217131115-0f117a938d4e/go.mod h1:ex8ou6/3ms6ovR+CMXD6XhTlNakm1GhB6UZgagVRNW8=
8384
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20251122131503-b76943960b6c h1:wM8qXCB5mQwSosCvtaydzuXitWVVKBHTzH0A2znQ+Jg=
8485
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20251122131503-b76943960b6c/go.mod h1:+Me0raWPPdz8gRi9D4z1khmvUgS9vIKAVC8ckg1yJZU=
8586
github.com/openstack-k8s-operators/lib-common/modules/storage v0.6.1-0.20251122131503-b76943960b6c h1:dVIaDL5BeIdJjERGaN/XlcvZVplfkzh0uUfiVUHj/6Q=
8687
github.com/openstack-k8s-operators/lib-common/modules/storage v0.6.1-0.20251122131503-b76943960b6c/go.mod h1:fy1lvz3uuzzh01DKKdgroXvmJgMpJBsvl2r9eTtAll0=
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/conditions.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ const (
2727

2828
// ManilaShareReadyCondition Status=True condition which indicates if the ManilaShare is configured and operational
2929
ManilaShareReadyCondition condition.Type = "ManilaShareReady"
30+
31+
// ManilaNotificationBusReadyCondition Status=True condition which indicates if the NotificationBus is configured
32+
ManilaNotificationBusReadyCondition condition.Type = "ManilaNotificationBusReady"
3033
)
3134

3235
// Common Messages used by API objects.
@@ -60,4 +63,19 @@ const (
6063

6164
// ManilaShareReadyRunningMessage
6265
ManilaShareReadyRunningMessage = "ManilaShare deployments in progress"
66+
67+
//
68+
// ManilaNotificationBusReady condition messages
69+
//
70+
// ManilaNotificationBusReadyInitMessage
71+
ManilaNotificationBusReadyInitMessage = "ManilaNotificationBus not started"
72+
73+
// ManilaNotificationBusReadyRunningMessage
74+
ManilaNotificationBusReadyRunningMessage = "ManilaNotificationBus creation in progress"
75+
76+
// ManilaNotificationBusReadyMessage
77+
ManilaNotificationBusReadyMessage = "ManilaNotificationBus successfully created"
78+
79+
// ManilaNotificationBusReadyErrorMessage
80+
ManilaNotificationBusReadyErrorMessage = "ManilaNotificationBus error occured %s"
6381
)

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: 45 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,20 @@ 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 NotificationsBus with MessagingBus values to inherit user/vhost
112+
spec.NotificationsBus = &rabbitmqv1.RabbitMqConfig{
113+
User: spec.MessagingBus.User,
114+
Vhost: spec.MessagingBus.Vhost,
115+
}
116+
}
117+
rabbitmqv1.DefaultRabbitMqConfig(spec.NotificationsBus, *spec.NotificationsBusInstance)
118+
}
104119

105120
if spec.APITimeout == 0 {
106121
spec.APITimeout = manilaDefaults.APITimeout
@@ -200,6 +215,21 @@ func (r *Manila) ValidateUpdate(old runtime.Object) (admission.Warnings, error)
200215
func (spec *ManilaSpec) ValidateUpdate(old ManilaSpec, basePath *field.Path, namespace string) field.ErrorList {
201216
var allErrs field.ErrorList
202217

218+
// Reject changes to deprecated RabbitMqClusterName field - users should use the new messagingBus.cluster field instead
219+
if spec.RabbitMqClusterName != old.RabbitMqClusterName {
220+
allErrs = append(allErrs, field.Forbidden(
221+
basePath.Child("rabbitMqClusterName"),
222+
"rabbitMqClusterName is deprecated and cannot be changed. Please use messagingBus.cluster instead"))
223+
}
224+
225+
// Reject changes to deprecated NotificationsBusInstance field
226+
if spec.NotificationsBusInstance != nil && old.NotificationsBusInstance != nil &&
227+
*spec.NotificationsBusInstance != *old.NotificationsBusInstance {
228+
allErrs = append(allErrs, field.Forbidden(
229+
basePath.Child("notificationsBusInstance"),
230+
"notificationsBusInstance is deprecated and cannot be changed. Please use notificationsBus.cluster instead"))
231+
}
232+
203233
// validate the service base parameters
204234
allErrs = append(allErrs, spec.ValidateBaseParams(basePath)...)
205235

@@ -217,6 +247,21 @@ func (spec *ManilaSpec) ValidateUpdate(old ManilaSpec, basePath *field.Path, nam
217247
func (spec *ManilaSpecCore) ValidateUpdate(old ManilaSpecCore, basePath *field.Path, namespace string) field.ErrorList {
218248
var allErrs field.ErrorList
219249

250+
// Reject changes to deprecated RabbitMqClusterName field - users should use the new messagingBus.cluster field instead
251+
if spec.RabbitMqClusterName != old.RabbitMqClusterName {
252+
allErrs = append(allErrs, field.Forbidden(
253+
basePath.Child("rabbitMqClusterName"),
254+
"rabbitMqClusterName is deprecated and cannot be changed. Please use messagingBus.cluster instead"))
255+
}
256+
257+
// Reject changes to deprecated NotificationsBusInstance field
258+
if spec.NotificationsBusInstance != nil && old.NotificationsBusInstance != nil &&
259+
*spec.NotificationsBusInstance != *old.NotificationsBusInstance {
260+
allErrs = append(allErrs, field.Forbidden(
261+
basePath.Child("notificationsBusInstance"),
262+
"notificationsBusInstance is deprecated and cannot be changed. Please use notificationsBus.cluster instead"))
263+
}
264+
220265
// validate the service base parameters
221266
allErrs = append(allErrs, spec.ValidateBaseParams(basePath)...)
222267

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

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require (
66
github.com/go-logr/logr v1.4.3
77
github.com/onsi/ginkgo/v2 v2.27.2
88
github.com/onsi/gomega v1.38.2
9-
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20251205192058-5cfbada0ab96
9+
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20251217131115-0f117a938d4e
1010
github.com/openstack-k8s-operators/keystone-operator/api v0.6.1-0.20251128160419-8b3a77972a77
1111
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20251122131503-b76943960b6c
1212
github.com/openstack-k8s-operators/lib-common/modules/storage v0.6.1-0.20251122131503-b76943960b6c

0 commit comments

Comments
 (0)