Skip to content

Commit d790da5

Browse files
Merge pull request #1324 from olliewalsh/rabbitmqtopo2
Switch to infra rabbitmq CR to support topology references
2 parents d62fe4a + d882809 commit d790da5

23 files changed

Lines changed: 10258 additions & 497 deletions

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ $(KUSTOMIZE): $(LOCALBIN)
319319
test -s $(LOCALBIN)/kustomize || { curl -Ss $(KUSTOMIZE_INSTALL_SCRIPT) | bash -s -- $(subst v,,$(KUSTOMIZE_VERSION)) $(LOCALBIN); }
320320

321321
.PHONY: controller-gen
322-
controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary. If wrong version is installed, it will be overwritten.
322+
controller-gen: gowork $(CONTROLLER_GEN) ## Download controller-gen locally if necessary. If wrong version is installed, it will be overwritten.
323323
$(CONTROLLER_GEN): $(LOCALBIN)
324324
test -s $(LOCALBIN)/controller-gen && $(LOCALBIN)/controller-gen --version | grep -q $(CONTROLLER_TOOLS_VERSION) || \
325325
GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION)

apis/bases/core.openstack.org_openstackcontrolplanes.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15489,6 +15489,13 @@ spec:
1548915489
type: string
1549015490
type: object
1549115491
type: array
15492+
topologyRef:
15493+
properties:
15494+
name:
15495+
type: string
15496+
namespace:
15497+
type: string
15498+
type: object
1549215499
type: object
1549315500
type: object
1549415501
type: object

apis/core/v1beta1/openstackcontrolplane_types.go

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ import (
2727
horizonv1 "github.com/openstack-k8s-operators/horizon-operator/api/v1beta1"
2828
memcachedv1 "github.com/openstack-k8s-operators/infra-operator/apis/memcached/v1beta1"
2929
networkv1 "github.com/openstack-k8s-operators/infra-operator/apis/network/v1beta1"
30+
rabbitmqv1 "github.com/openstack-k8s-operators/infra-operator/apis/rabbitmq/v1beta1"
3031
redisv1 "github.com/openstack-k8s-operators/infra-operator/apis/redis/v1beta1"
32+
topologyv1 "github.com/openstack-k8s-operators/infra-operator/apis/topology/v1beta1"
3133
ironicv1 "github.com/openstack-k8s-operators/ironic-operator/api/v1beta1"
3234
keystonev1 "github.com/openstack-k8s-operators/keystone-operator/api/v1beta1"
3335
condition "github.com/openstack-k8s-operators/lib-common/modules/common/condition"
@@ -45,17 +47,11 @@ import (
4547
placementv1 "github.com/openstack-k8s-operators/placement-operator/api/v1beta1"
4648
swiftv1 "github.com/openstack-k8s-operators/swift-operator/api/v1beta1"
4749
telemetryv1 "github.com/openstack-k8s-operators/telemetry-operator/api/v1beta1"
48-
rabbitmqv2 "github.com/rabbitmq/cluster-operator/v2/api/v1beta1"
49-
topologyv1 "github.com/openstack-k8s-operators/infra-operator/apis/topology/v1beta1"
50+
5051
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
5152
)
5253

5354
const (
54-
// Container image fall-back defaults
55-
56-
// RabbitMqContainerImage is the fall-back container image for RabbitMQ
57-
RabbitMqContainerImage = "quay.io/podified-antelope-centos9/openstack-rabbitmq:current-podified"
58-
5955
// IngressCaName -
6056
IngressCaName = tls.DefaultCAPrefix + string(service.EndpointPublic)
6157
// InternalCaName -
@@ -489,7 +485,7 @@ type RabbitmqSection struct {
489485
// +kubebuilder:validation:Optional
490486
// +operator-sdk:csv:customresourcedefinitions:type=spec
491487
// Templates - Overrides to use when creating the Rabbitmq clusters
492-
Templates *map[string]RabbitmqTemplate `json:"templates"`
488+
Templates *map[string]rabbitmqv1.RabbitMqSpecCore `json:"templates"`
493489
}
494490

495491
// MemcachedSection defines the desired state of Memcached services
@@ -506,18 +502,6 @@ type MemcachedSection struct {
506502
Templates *map[string]memcachedv1.MemcachedSpecCore `json:"templates,omitempty"`
507503
}
508504

509-
// RabbitmqTemplate definition
510-
type RabbitmqTemplate struct {
511-
// +kubebuilder:validation:Required
512-
// +operator-sdk:csv:customresourcedefinitions:type=spec
513-
// Overrides to use when creating the Rabbitmq clusters
514-
rabbitmqv2.RabbitmqClusterSpecCore `json:",inline"`
515-
// +kubebuilder:validation:Optional
516-
// +operator-sdk:csv:customresourcedefinitions:type=spec
517-
// NodeSelector to target subset of worker nodes running this service
518-
NodeSelector *map[string]string `json:"nodeSelector,omitempty"`
519-
}
520-
521505
// OvnSection defines the desired state of OVN services
522506
type OvnSection struct {
523507
// +kubebuilder:validation:Optional

apis/core/v1beta1/openstackcontrolplane_webhook.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ import (
4747
horizonv1 "github.com/openstack-k8s-operators/horizon-operator/api/v1beta1"
4848
memcachedv1 "github.com/openstack-k8s-operators/infra-operator/apis/memcached/v1beta1"
4949
networkv1 "github.com/openstack-k8s-operators/infra-operator/apis/network/v1beta1"
50+
rabbitmqv1 "github.com/openstack-k8s-operators/infra-operator/apis/rabbitmq/v1beta1"
5051
redisv1 "github.com/openstack-k8s-operators/infra-operator/apis/redis/v1beta1"
5152
ironicv1 "github.com/openstack-k8s-operators/ironic-operator/api/v1beta1"
5253
manilav1 "github.com/openstack-k8s-operators/manila-operator/api/v1beta1"
@@ -372,6 +373,10 @@ func (r *OpenStackControlPlane) ValidateCreateServices(basePath *field.Path) (ad
372373
maps.Keys(*r.Spec.Rabbitmq.Templates),
373374
memcachedv1.CrMaxLengthCorrection) // omit issue with statefulset pod label "controller-revision-hash": "<statefulset_name>-<hash>"
374375
errors = append(errors, err...)
376+
377+
for rabbitmqName, rabbitmqSpec := range *r.Spec.Rabbitmq.Templates {
378+
errors = append(errors, rabbitmqSpec.ValidateCreate(basePath.Child("rabbitmq").Child("template").Key(rabbitmqName), r.Namespace)...)
379+
}
375380
}
376381
}
377382

@@ -528,13 +533,23 @@ func (r *OpenStackControlPlane) ValidateUpdateServices(old OpenStackControlPlane
528533
}
529534

530535
if r.Spec.Rabbitmq.Enabled {
536+
if old.Rabbitmq.Templates == nil {
537+
old.Rabbitmq.Templates = &map[string]rabbitmqv1.RabbitMqSpecCore{}
538+
}
531539
if r.Spec.Rabbitmq.Templates != nil {
532540
err := common_webhook.ValidateDNS1123Label(
533541
basePath.Child("rabbitmq").Child("templates"),
534542
maps.Keys(*r.Spec.Rabbitmq.Templates),
535543
memcachedv1.CrMaxLengthCorrection) // omit issue with statefulset pod label "controller-revision-hash": "<statefulset_name>-<hash>"
536544
errors = append(errors, err...)
537545
}
546+
oldRabbitmqs := *old.Rabbitmq.Templates
547+
for rabbitmqName, rabbitmqSpec := range *r.Spec.Rabbitmq.Templates {
548+
549+
if oldRabbitmq, ok := oldRabbitmqs[rabbitmqName]; ok {
550+
errors = append(errors, rabbitmqSpec.ValidateUpdate(oldRabbitmq, basePath.Child("rabbitmq").Child("templates").Key(rabbitmqName), r.Namespace)...)
551+
}
552+
}
538553
}
539554

540555
if r.Spec.Galera.Enabled {

apis/core/v1beta1/zz_generated.deepcopy.go

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

apis/go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ require (
1313
github.com/openstack-k8s-operators/glance-operator/api v0.5.1-0.20250226112225-45778defabec
1414
github.com/openstack-k8s-operators/heat-operator/api v0.5.1-0.20250225210325-6edf12a1fbc7
1515
github.com/openstack-k8s-operators/horizon-operator/api v0.5.1-0.20250225210325-92d28ab9abbc
16-
github.com/openstack-k8s-operators/infra-operator/apis v0.5.1-0.20250226120707-ee102640a845
16+
github.com/openstack-k8s-operators/infra-operator/apis v0.5.1-0.20250228015408-e121baeaa3f3
1717
github.com/openstack-k8s-operators/ironic-operator/api v0.5.1-0.20250226144146-bbcbf072b002
1818
github.com/openstack-k8s-operators/keystone-operator/api v0.5.1-0.20250226154712-e1738aa3a9be
1919
github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.20250227100238-bf6216121556
@@ -28,7 +28,6 @@ require (
2828
github.com/openstack-k8s-operators/placement-operator/api v0.5.1-0.20250226151941-eb9a7af9d246
2929
github.com/openstack-k8s-operators/swift-operator/api v0.5.1-0.20250226122039-58e4ce79b373
3030
github.com/openstack-k8s-operators/telemetry-operator/api v0.5.1-0.20250226185300-1af61276d1b2
31-
github.com/rabbitmq/cluster-operator/v2 v2.11.0
3231
github.com/rhobs/obo-prometheus-operator/pkg/apis/monitoring v0.71.0-rhobs1 // indirect
3332
github.com/rhobs/observability-operator v0.3.1 // indirect
3433
go.uber.org/multierr v1.11.0 // indirect
@@ -84,6 +83,7 @@ require (
8483
github.com/prometheus/client_model v0.6.0 // indirect
8584
github.com/prometheus/common v0.53.0 // indirect
8685
github.com/prometheus/procfs v0.13.0 // indirect
86+
github.com/rabbitmq/cluster-operator/v2 v2.11.0 // indirect
8787
github.com/robfig/cron/v3 v3.0.1 // indirect
8888
github.com/spf13/pflag v1.0.5 // indirect
8989
golang.org/x/crypto v0.32.0 // indirect

apis/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ github.com/openstack-k8s-operators/heat-operator/api v0.5.1-0.20250225210325-6ed
106106
github.com/openstack-k8s-operators/heat-operator/api v0.5.1-0.20250225210325-6edf12a1fbc7/go.mod h1:yVcfYmV1vtruOm/lFjGnxX/4+w1AwNv+gEFUx1J6hH0=
107107
github.com/openstack-k8s-operators/horizon-operator/api v0.5.1-0.20250225210325-92d28ab9abbc h1:aTsZzRAjw9x4HG9OvwBHAlzWp6bMPQrr6E+ykAs4d5I=
108108
github.com/openstack-k8s-operators/horizon-operator/api v0.5.1-0.20250225210325-92d28ab9abbc/go.mod h1:HMCCmdEsVgCqSZxL6UWGHBJzSL+9GRfiZSGNjLj/X+g=
109-
github.com/openstack-k8s-operators/infra-operator/apis v0.5.1-0.20250226120707-ee102640a845 h1:18Si6z23Spv94fEkJZRC3Pzjk6UmkzzaiVdaqoAVc3o=
110-
github.com/openstack-k8s-operators/infra-operator/apis v0.5.1-0.20250226120707-ee102640a845/go.mod h1:jZ74v7V5JcKjSIgGWyrunPVMTuyw6SBBfp7f74RDrSo=
109+
github.com/openstack-k8s-operators/infra-operator/apis v0.5.1-0.20250228015408-e121baeaa3f3 h1:CZ6OlejaEzzPIRPiWxBqbEibtJDtQqVVwDG/bkRWEe0=
110+
github.com/openstack-k8s-operators/infra-operator/apis v0.5.1-0.20250228015408-e121baeaa3f3/go.mod h1:B5IqcyG8MfDPNwyOJLU/+5gKn7mQ4XtbEmwJ4VuSbNo=
111111
github.com/openstack-k8s-operators/ironic-operator/api v0.5.1-0.20250226144146-bbcbf072b002 h1:Hkw+FJ/ppotLQHubuF9JT86y8ZZaSNiEQL+jts7YtG4=
112112
github.com/openstack-k8s-operators/ironic-operator/api v0.5.1-0.20250226144146-bbcbf072b002/go.mod h1:85Y8UmLSIn0FC0Tl4l1KDztcaSPOkryPlGOecfZzXE8=
113113
github.com/openstack-k8s-operators/keystone-operator/api v0.5.1-0.20250226154712-e1738aa3a9be h1:+iiWzVhK68RgGEXHIEVYYXmnjEk0NLlm0EcljV2TcyY=

bindata/crds/crds.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15653,6 +15653,13 @@ spec:
1565315653
type: string
1565415654
type: object
1565515655
type: array
15656+
topologyRef:
15657+
properties:
15658+
name:
15659+
type: string
15660+
namespace:
15661+
type: string
15662+
type: object
1565615663
type: object
1565715664
type: object
1565815665
type: object

0 commit comments

Comments
 (0)