Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 35 additions & 2 deletions api/bases/cinder.openstack.org_cinders.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2032,6 +2032,22 @@ spec:
default: memcached
description: Memcached instance name.
type: string
messagingBus:
description: MessagingBus configuration (username, vhost, and cluster)
properties:
cluster:
description: Name of the cluster
minLength: 1
type: string
user:
description: User - RabbitMQ username
type: string
vhost:
description: Vhost - RabbitMQ vhost name
type: string
required:
- cluster
type: object
nodeSelector:
additionalProperties:
type: string
Expand All @@ -2040,10 +2056,28 @@ spec:
NodeSelector here acts as a default value and can be overridden by service
specific NodeSelector Settings.
type: object
notificationsBus:
description: NotificationsBus configuration (username, vhost, and
cluster) for notifications
properties:
cluster:
description: Name of the cluster
minLength: 1
type: string
user:
description: User - RabbitMQ username
type: string
vhost:
description: Vhost - RabbitMQ vhost name
type: string
required:
- cluster
type: object
notificationsBusInstance:
description: |-
RabbitMQ instance name used to request a transportURL that is used for
notification purposes
Deprecated: Use NotificationsBus.Cluster instead
type: string
passwordSelectors:
default:
Expand All @@ -2063,10 +2097,10 @@ spec:
e.g. to check logs
type: boolean
rabbitMqClusterName:
default: rabbitmq
description: |-
RabbitMQ instance name
Needed to request a transportURL that is created and used in Cinder
Deprecated: Use MessagingBus.Cluster instead
type: string
secret:
description: Secret containing OpenStack password information
Expand Down Expand Up @@ -2098,7 +2132,6 @@ spec:
- cinderScheduler
- databaseInstance
- memcachedInstance
- rabbitMqClusterName
- secret
type: object
status:
Expand Down
2 changes: 1 addition & 1 deletion api/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ require (
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/emicklei/go-restful/v3 v3.12.2 // indirect
github.com/evanphx/json-patch v5.9.11+incompatible // indirect
github.com/evanphx/json-patch/v5 v5.9.11 // indirect
github.com/fsnotify/fsnotify v1.9.0 // indirect
github.com/fxamacker/cbor/v2 v2.9.0 // indirect
Expand Down Expand Up @@ -46,6 +45,7 @@ require (
github.com/prometheus/client_model v0.6.2 // indirect
github.com/prometheus/common v0.65.0 // indirect
github.com/prometheus/procfs v0.16.1 // indirect
github.com/rabbitmq/cluster-operator/v2 v2.16.0 // indirect
github.com/spf13/pflag v1.0.7 // indirect
github.com/stretchr/testify v1.11.1 // indirect
github.com/x448/float16 v0.8.4 // indirect
Expand Down
3 changes: 3 additions & 0 deletions api/go.sum
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww=
github.com/Masterminds/semver/v3 v3.4.0 h1:Zog+i5UMtVoCU8oKka5P7i9q9HgrJeGzI9SA1Xbatp0=
github.com/Masterminds/semver/v3 v3.4.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
Expand Down Expand Up @@ -84,6 +85,8 @@ github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.2026012814
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20260128142552-e2c25eccae5a/go.mod h1:ndqfy1KbVorHH6+zlUFPIrCRhMSxO3ImYJUGaooE0x0=
github.com/openstack-k8s-operators/lib-common/modules/storage v0.6.1-0.20260128142552-e2c25eccae5a h1:teKxfVLDxJD9ahjeh29GlKHiXNUFDkVRmkpJdeKAvGE=
github.com/openstack-k8s-operators/lib-common/modules/storage v0.6.1-0.20260128142552-e2c25eccae5a/go.mod h1:jofj+VqDszxLCZSBYo794KGkCjMo01xzhQ/gffYzf3I=
github.com/openstack-k8s-operators/rabbitmq-cluster-operator/v2 v2.6.1-0.20250929174222-a0d328fa4dec h1:saovr368HPAKHN0aRPh8h8n9s9dn3d8Frmfua0UYRlc=
github.com/openstack-k8s-operators/rabbitmq-cluster-operator/v2 v2.6.1-0.20250929174222-a0d328fa4dec/go.mod h1:Nh2NEePLjovUQof2krTAg4JaAoLacqtPTZQXK6izNfg=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
Expand Down
18 changes: 14 additions & 4 deletions api/v1beta1/cinder_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package v1beta1

import (
rabbitmqv1 "github.com/openstack-k8s-operators/infra-operator/apis/rabbitmq/v1beta1"
topologyv1 "github.com/openstack-k8s-operators/infra-operator/apis/topology/v1beta1"
"github.com/openstack-k8s-operators/lib-common/modules/common/condition"
"github.com/openstack-k8s-operators/lib-common/modules/storage"
Expand Down Expand Up @@ -64,11 +65,19 @@ type CinderSpecBase struct {
// Might not be required in future
DatabaseInstance string `json:"databaseInstance"`

// +kubebuilder:validation:Required
// +kubebuilder:default=rabbitmq
// +kubebuilder:validation:Optional
// RabbitMQ instance name
// Needed to request a transportURL that is created and used in Cinder
RabbitMqClusterName string `json:"rabbitMqClusterName"`
// Deprecated: Use MessagingBus.Cluster instead
RabbitMqClusterName string `json:"rabbitMqClusterName,omitempty"`

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

// +kubebuilder:validation:Optional
// NotificationsBus configuration (username, vhost, and cluster) for notifications
NotificationsBus *rabbitmqv1.RabbitMqConfig `json:"notificationsBus,omitempty"`

// +kubebuilder:validation:Required
// +kubebuilder:default=memcached
Expand Down Expand Up @@ -114,7 +123,8 @@ type CinderSpecBase struct {
// +kubebuilder:validation:Optional
// RabbitMQ instance name used to request a transportURL that is used for
// notification purposes
NotificationsBusInstance *string `json:"notificationsBusInstance,omitempty"`
// Deprecated: Use NotificationsBus.Cluster instead
NotificationsBusInstance *string `json:"notificationsBusInstance,omitempty" deprecated:"notificationsBus.cluster"`

// +kubebuilder:validation:Optional
// +operator-sdk:csv:customresourcedefinitions:type=spec
Expand Down
86 changes: 86 additions & 0 deletions api/v1beta1/cinder_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@ func (r *Cinder) Default() {

// Default - set defaults for this Cinder spec
func (spec *CinderSpecBase) Default() {
// Default MessagingBus.Cluster if not set
// Migration from deprecated fields is handled by openstack-operator
if spec.MessagingBus.Cluster == "" {
spec.MessagingBus.Cluster = "rabbitmq"
}

// NotificationsBus.Cluster is not defaulted - it must be explicitly set if NotificationsBus is configured
// This ensures users make a conscious choice about which cluster to use for notifications

if spec.DBPurge.Age == 0 {
spec.DBPurge.Age = cinderDefaults.DBPurgeAge
Expand All @@ -128,6 +136,64 @@ func (spec *CinderSpecCore) Default() {
spec.CinderSpecBase.Default()
}

// getDeprecatedFields returns the centralized list of deprecated fields for CinderSpecBase
func (spec *CinderSpecBase) getDeprecatedFields(old *CinderSpecBase) []common_webhook.DeprecatedFieldUpdate {
// Get new field value (handle nil NotificationsBus)
var newNotifBusCluster *string
if spec.NotificationsBus != nil {
newNotifBusCluster = &spec.NotificationsBus.Cluster
}

deprecatedFields := []common_webhook.DeprecatedFieldUpdate{
{
DeprecatedFieldName: "rabbitMqClusterName",
NewFieldPath: []string{"messagingBus", "cluster"},
NewDeprecatedValue: &spec.RabbitMqClusterName,
NewValue: &spec.MessagingBus.Cluster,
},
{
DeprecatedFieldName: "notificationsBusInstance",
NewFieldPath: []string{"notificationsBus", "cluster"},
NewDeprecatedValue: spec.NotificationsBusInstance,
NewValue: newNotifBusCluster,
},
}

// If old spec is provided (UPDATE operation), add old values
if old != nil {
deprecatedFields[0].OldDeprecatedValue = &old.RabbitMqClusterName
deprecatedFields[1].OldDeprecatedValue = old.NotificationsBusInstance
}

return deprecatedFields
}

// validateDeprecatedFieldsCreate validates deprecated fields during CREATE operations
func (spec *CinderSpecBase) validateDeprecatedFieldsCreate(basePath *field.Path) ([]string, field.ErrorList) {
// Get deprecated fields list (without old values for CREATE)
deprecatedFieldsUpdate := spec.getDeprecatedFields(nil)

// Convert to DeprecatedField list for CREATE validation
deprecatedFields := make([]common_webhook.DeprecatedField, len(deprecatedFieldsUpdate))
for i, df := range deprecatedFieldsUpdate {
deprecatedFields[i] = common_webhook.DeprecatedField{
DeprecatedFieldName: df.DeprecatedFieldName,
NewFieldPath: df.NewFieldPath,
DeprecatedValue: df.NewDeprecatedValue,
NewValue: df.NewValue,
}
}

return common_webhook.ValidateDeprecatedFieldsCreate(deprecatedFields, basePath), nil
}

// validateDeprecatedFieldsUpdate validates deprecated fields during UPDATE operations
func (spec *CinderSpecBase) validateDeprecatedFieldsUpdate(old CinderSpecBase, basePath *field.Path) ([]string, field.ErrorList) {
// Get deprecated fields list with old values
deprecatedFields := spec.getDeprecatedFields(&old)
return common_webhook.ValidateDeprecatedFieldsUpdate(deprecatedFields, basePath)
}

var _ webhook.Validator = &Cinder{}

// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
Expand Down Expand Up @@ -179,6 +245,11 @@ func (spec *CinderSpec) ValidateCreate(
var allErrs field.ErrorList
var allWarns admission.Warnings

// Validate deprecated fields using shared helper
warns, errs := spec.CinderSpecBase.validateDeprecatedFieldsCreate(basePath)
allWarns = append(allWarns, warns...)
allErrs = append(allErrs, errs...)

// validate the service override key is valid
allErrs = append(allErrs, service.ValidateRoutedOverrides(
basePath.Child("cinderAPI").Child("override").Child("service"),
Expand All @@ -202,6 +273,11 @@ func (spec *CinderSpecCore) ValidateCreate(
var allErrs field.ErrorList
var allWarns admission.Warnings

// Validate deprecated fields using shared helper
warns, errs := spec.CinderSpecBase.validateDeprecatedFieldsCreate(basePath)
allWarns = append(allWarns, warns...)
allErrs = append(allErrs, errs...)

// validate the service override key is valid
allErrs = append(allErrs, service.ValidateRoutedOverrides(
basePath.Child("cinderAPI").Child("override").Child("service"),
Expand Down Expand Up @@ -275,6 +351,11 @@ func (spec *CinderSpec) ValidateUpdate(
var allErrs field.ErrorList
var allWarns []string

// Validate deprecated fields using shared helper
warns, errs := spec.CinderSpecBase.validateDeprecatedFieldsUpdate(old.CinderSpecBase, basePath)
allWarns = append(allWarns, warns...)
allErrs = append(allErrs, errs...)

// validate the service override key is valid
allErrs = append(allErrs, service.ValidateRoutedOverrides(
basePath.Child("cinderAPI").Child("override").Child("service"),
Expand All @@ -301,6 +382,11 @@ func (spec *CinderSpecCore) ValidateUpdate(
var allErrs field.ErrorList
var allWarns []string

// Validate deprecated fields using shared helper
warns, errs := spec.CinderSpecBase.validateDeprecatedFieldsUpdate(old.CinderSpecBase, basePath)
allWarns = append(allWarns, warns...)
allErrs = append(allErrs, errs...)

// validate the service override key is valid
allErrs = append(allErrs, service.ValidateRoutedOverrides(
basePath.Child("cinderAPI").Child("override").Child("service"),
Expand Down
7 changes: 7 additions & 0 deletions api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 35 additions & 2 deletions config/crd/bases/cinder.openstack.org_cinders.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2032,6 +2032,22 @@ spec:
default: memcached
description: Memcached instance name.
type: string
messagingBus:
description: MessagingBus configuration (username, vhost, and cluster)
properties:
cluster:
description: Name of the cluster
minLength: 1
type: string
user:
description: User - RabbitMQ username
type: string
vhost:
description: Vhost - RabbitMQ vhost name
type: string
required:
- cluster
type: object
nodeSelector:
additionalProperties:
type: string
Expand All @@ -2040,10 +2056,28 @@ spec:
NodeSelector here acts as a default value and can be overridden by service
specific NodeSelector Settings.
type: object
notificationsBus:
description: NotificationsBus configuration (username, vhost, and
cluster) for notifications
properties:
cluster:
description: Name of the cluster
minLength: 1
type: string
user:
description: User - RabbitMQ username
type: string
vhost:
description: Vhost - RabbitMQ vhost name
type: string
required:
- cluster
type: object
notificationsBusInstance:
description: |-
RabbitMQ instance name used to request a transportURL that is used for
notification purposes
Deprecated: Use NotificationsBus.Cluster instead
type: string
passwordSelectors:
default:
Expand All @@ -2063,10 +2097,10 @@ spec:
e.g. to check logs
type: boolean
rabbitMqClusterName:
default: rabbitmq
description: |-
RabbitMQ instance name
Needed to request a transportURL that is created and used in Cinder
Deprecated: Use MessagingBus.Cluster instead
type: string
secret:
description: Secret containing OpenStack password information
Expand Down Expand Up @@ -2098,7 +2132,6 @@ spec:
- cinderScheduler
- databaseInstance
- memcachedInstance
- rabbitMqClusterName
- secret
type: object
status:
Expand Down
Loading