Skip to content
Open
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
35 changes: 35 additions & 0 deletions api/bases/watcher.openstack.org_watchers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -608,13 +608,46 @@ spec:
description: MemcachedInstance is the name of the Memcached CR that
all watcher service will use.
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
description: |-
NodeSelector to target subset of worker nodes running this component. Setting here overrides
any global NodeSelector settings within the Watcher CR.
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: |-
NotificationsBusInstance is the name of the RabbitMqCluster CR to select
Expand All @@ -623,6 +656,7 @@ spec:
If undefined, the value will be inherited from OpenStackControlPlane.
An empty value "" leaves the notification drivers unconfigured and emitting no notifications at all.
Avoid colocating it with RabbitMqClusterName or other message bus instances used for RPC.
Deprecated: Use NotificationsBus.Cluster instead
type: string
passwordSelectors:
default:
Expand Down Expand Up @@ -650,6 +684,7 @@ spec:
description: |-
RabbitMQ instance name
Needed to request a transportURL that is created and used in Watcher
Deprecated: Use MessagingBus.Cluster instead
type: string
secret:
default: osp-secret
Expand Down
14 changes: 6 additions & 8 deletions api/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ go 1.24.4
toolchain go1.24.6

require (
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20251110170511-c2d4a351a7c3
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20251103072528-9eb684fef4ef
k8s.io/api v0.31.13
k8s.io/apimachinery v0.31.13
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20251217131115-0f117a938d4e
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20251122131503-b76943960b6c
k8s.io/api v0.31.14
k8s.io/apimachinery v0.31.14
k8s.io/utils v0.0.0-20250820121507-0af2bda4dd1d
sigs.k8s.io/controller-runtime v0.19.7
)
Expand All @@ -18,7 +18,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 All @@ -45,10 +44,9 @@ 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/rogpeppe/go-internal v1.13.1 // indirect
github.com/rabbitmq/cluster-operator/v2 v2.16.0 // indirect
github.com/spf13/pflag v1.0.7 // indirect
github.com/x448/float16 v0.8.4 // indirect
go.uber.org/zap v1.27.1 // indirect
go.yaml.in/yaml/v2 v2.4.2 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/exp v0.0.0-20241217172543-b2144cdd0a67 // indirect
Expand All @@ -63,7 +61,7 @@ require (
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiextensions-apiserver v0.33.2 // indirect
k8s.io/client-go v0.31.13 // indirect
k8s.io/client-go v0.31.14 // indirect
k8s.io/klog/v2 v2.130.1 // indirect
k8s.io/kube-openapi v0.0.0-20250902184714-7fc278399c7f // indirect
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 // indirect
Expand Down
11 changes: 7 additions & 4 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 @@ -78,10 +79,12 @@ github.com/onsi/ginkgo/v2 v2.27.2 h1:LzwLj0b89qtIy6SSASkzlNvX6WktqurSHwkk2ipF/Ns
github.com/onsi/ginkgo/v2 v2.27.2/go.mod h1:ArE1D/XhNXBXCBkKOLkbsb2c81dQHCRcF5zwn/ykDRo=
github.com/onsi/gomega v1.38.2 h1:eZCjf2xjZAqe+LeWvKb5weQ+NcPwX84kqJ0cZNxok2A=
github.com/onsi/gomega v1.38.2/go.mod h1:W2MJcYxRGV63b418Ai34Ud0hEdTVXq9NW9+Sx6uXf3k=
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20251110170511-c2d4a351a7c3 h1:gKazSLpq0Ytn4OLzNtSKQpLswAdki8u8mXZgpJy83bE=
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20251110170511-c2d4a351a7c3/go.mod h1:Y9LqOS1wYhn7RT4jFknINdWa+ziYEIOU1jLNxkxiCsw=
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20251103072528-9eb684fef4ef h1:1j7kk+D4ZdIXm6C/IwEjuTzIuvWUytxO39E/x94JY7k=
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20251103072528-9eb684fef4ef/go.mod h1:kUT/SyuxZiOcX8ZuvpFN3PaQa2V8uQon8YwY+1RoQWM=
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20251217131115-0f117a938d4e h1:PIjcXzMMwfvBRFgFpaq/W9tqy0t2cYvcWX+kq6uNtTM=
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20251217131115-0f117a938d4e/go.mod h1:ex8ou6/3ms6ovR+CMXD6XhTlNakm1GhB6UZgagVRNW8=
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20251122131503-b76943960b6c h1:wM8qXCB5mQwSosCvtaydzuXitWVVKBHTzH0A2znQ+Jg=
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20251122131503-b76943960b6c/go.mod h1:+Me0raWPPdz8gRi9D4z1khmvUgS9vIKAVC8ckg1yJZU=
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
14 changes: 12 additions & 2 deletions api/v1beta1/common_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ limitations under the License.
package v1beta1

import (
"github.com/openstack-k8s-operators/lib-common/modules/common/util"

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/util"

corev1 "k8s.io/api/core/v1"
)
Expand Down Expand Up @@ -83,10 +83,19 @@ type WatcherSpecCore struct {
// Important: Run "make" to regenerate code after modifying this file
WatcherCommon `json:",inline"`

// +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=rabbitmq
// RabbitMQ instance name
// Needed to request a transportURL that is created and used in Watcher
// Deprecated: Use MessagingBus.Cluster instead
RabbitMqClusterName *string `json:"rabbitMqClusterName"`

// +kubebuilder:validation:Optional
Expand Down Expand Up @@ -136,6 +145,7 @@ type WatcherSpecCore struct {
// If undefined, the value will be inherited from OpenStackControlPlane.
// An empty value "" leaves the notification drivers unconfigured and emitting no notifications at all.
// Avoid colocating it with RabbitMqClusterName or other message bus instances used for RPC.
// Deprecated: Use NotificationsBus.Cluster instead
NotificationsBusInstance *string `json:"notificationsBusInstance,omitempty"`
}

Expand Down
51 changes: 46 additions & 5 deletions api/v1beta1/watcher_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package v1beta1
import (
"fmt"

rabbitmqv1 "github.com/openstack-k8s-operators/infra-operator/apis/rabbitmq/v1beta1"
topologyv1 "github.com/openstack-k8s-operators/infra-operator/apis/topology/v1beta1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime"
Expand Down Expand Up @@ -59,12 +60,36 @@ func (r *Watcher) Default() {

// Default - set defaults for this WatcherCore spec.
func (spec *WatcherSpec) Default() {
spec.WatcherSpecCore.Default()
spec.WatcherImages.Default(watcherDefaults)
}

// Default - set defaults for this WatcherSpecCore spec.
func (spec *WatcherSpecCore) Default() {
// no validations . Placeholder for defaulting webhook integrated in the OpenStackControlPlane
// Apply kubebuilder default for RabbitMqClusterName if not set
if spec.RabbitMqClusterName == nil {
spec.RabbitMqClusterName = ptr.To("rabbitmq")
}

// Default MessagingBus.Cluster from RabbitMqClusterName if not already set
if spec.MessagingBus.Cluster == "" {
rabbitmqv1.DefaultRabbitMqConfig(&spec.MessagingBus, *spec.RabbitMqClusterName)
}

// Default NotificationsBus if NotificationsBusInstance is specified
if spec.NotificationsBusInstance != nil && *spec.NotificationsBusInstance != "" {
if spec.NotificationsBus == nil {
// Initialize NotificationsBus with MessagingBus values to inherit user/vhost
spec.NotificationsBus = &rabbitmqv1.RabbitMqConfig{
User: spec.MessagingBus.User,
Vhost: spec.MessagingBus.Vhost,
}
}
// Always default the Cluster field from NotificationsBusInstance if it's empty
if spec.NotificationsBus.Cluster == "" {
rabbitmqv1.DefaultRabbitMqConfig(spec.NotificationsBus, *spec.NotificationsBusInstance)
}
}
}

var _ webhook.Validator = &Watcher{}
Expand Down Expand Up @@ -95,15 +120,15 @@ func (spec *WatcherSpec) ValidateCreate(basePath *field.Path, namespace string)
func (spec *WatcherSpecCore) ValidateCreate(basePath *field.Path, namespace string) field.ErrorList {
var allErrs field.ErrorList

if *spec.DatabaseInstance == "" || spec.DatabaseInstance == nil {
if spec.DatabaseInstance == nil || *spec.DatabaseInstance == "" {
allErrs = append(
allErrs,
field.Invalid(
basePath.Child("databaseInstance"), "", "databaseInstance field should not be empty"),
)
}

if *spec.RabbitMqClusterName == "" || spec.RabbitMqClusterName == nil {
if spec.RabbitMqClusterName == nil || *spec.RabbitMqClusterName == "" {
allErrs = append(
allErrs,
field.Invalid(
Expand Down Expand Up @@ -148,22 +173,38 @@ func (spec *WatcherSpec) ValidateUpdate(old WatcherSpec, basePath *field.Path, n
func (spec *WatcherSpecCore) ValidateUpdate(old WatcherSpecCore, basePath *field.Path, namespace string) field.ErrorList {
var allErrs field.ErrorList

if *spec.DatabaseInstance == "" || spec.DatabaseInstance == nil {
if spec.DatabaseInstance == nil || *spec.DatabaseInstance == "" {
allErrs = append(
allErrs,
field.Invalid(
basePath.Child("databaseInstance"), "", "databaseInstance field should not be empty"),
)
}

if *spec.RabbitMqClusterName == "" || spec.RabbitMqClusterName == nil {
if spec.RabbitMqClusterName == nil || *spec.RabbitMqClusterName == "" {
allErrs = append(
allErrs,
field.Invalid(
basePath.Child("rabbitMqClusterName"), "", "rabbitMqClusterName field should not be empty"),
)
}

// Reject changes to deprecated RabbitMqClusterName field
if spec.RabbitMqClusterName != nil && old.RabbitMqClusterName != nil &&
*spec.RabbitMqClusterName != *old.RabbitMqClusterName {
allErrs = append(allErrs, field.Forbidden(
basePath.Child("rabbitMqClusterName"),
"rabbitMqClusterName is deprecated and cannot be changed. Please use messagingBus.cluster instead"))
}

// Reject changes to deprecated NotificationsBusInstance field
if spec.NotificationsBusInstance != nil && old.NotificationsBusInstance != nil &&
*spec.NotificationsBusInstance != *old.NotificationsBusInstance {
allErrs = append(allErrs, field.Forbidden(
basePath.Child("notificationsBusInstance"),
"notificationsBusInstance is deprecated and cannot be changed. Please use notificationsBus.cluster instead"))
}

allErrs = append(allErrs, spec.ValidateWatcherTopology(basePath, namespace)...)

return allErrs
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.

35 changes: 35 additions & 0 deletions config/crd/bases/watcher.openstack.org_watchers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -608,13 +608,46 @@ spec:
description: MemcachedInstance is the name of the Memcached CR that
all watcher service will use.
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
description: |-
NodeSelector to target subset of worker nodes running this component. Setting here overrides
any global NodeSelector settings within the Watcher CR.
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: |-
NotificationsBusInstance is the name of the RabbitMqCluster CR to select
Expand All @@ -623,6 +656,7 @@ spec:
If undefined, the value will be inherited from OpenStackControlPlane.
An empty value "" leaves the notification drivers unconfigured and emitting no notifications at all.
Avoid colocating it with RabbitMqClusterName or other message bus instances used for RPC.
Deprecated: Use NotificationsBus.Cluster instead
type: string
passwordSelectors:
default:
Expand Down Expand Up @@ -650,6 +684,7 @@ spec:
description: |-
RabbitMQ instance name
Needed to request a transportURL that is created and used in Watcher
Deprecated: Use MessagingBus.Cluster instead
type: string
secret:
default: osp-secret
Expand Down
10 changes: 5 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ require (
github.com/onsi/ginkgo/v2 v2.27.2
github.com/onsi/gomega v1.38.2
github.com/openshift/api v3.9.0+incompatible
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20251110170511-c2d4a351a7c3
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20251217131115-0f117a938d4e
github.com/openstack-k8s-operators/keystone-operator/api v0.6.1-0.20251027074845-ed8154b20ad1
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20251103072528-9eb684fef4ef
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20251122131503-b76943960b6c
github.com/openstack-k8s-operators/lib-common/modules/test v0.6.1-0.20251103072528-9eb684fef4ef
github.com/openstack-k8s-operators/mariadb-operator/api v0.6.1-0.20251110170510-e669472c745c
github.com/openstack-k8s-operators/watcher-operator/api v0.0.0-00010101000000-000000000000
go.uber.org/zap v1.27.1
gopkg.in/yaml.v3 v3.0.1
k8s.io/api v0.31.13
k8s.io/apimachinery v0.31.13
k8s.io/client-go v0.31.13
k8s.io/api v0.31.14
k8s.io/apimachinery v0.31.14
k8s.io/client-go v0.31.14
k8s.io/utils v0.0.0-20250820121507-0af2bda4dd1d
sigs.k8s.io/controller-runtime v0.19.7
)
Expand Down
Loading