Skip to content

Commit ffc6154

Browse files
committed
Add watcher deployment to openstackcontrolplane
This patch is adding Watcher deployment to the OpenStackControlPlane. It includes: - CRD modification to OpenStackControlPlane - New conditions - pkg/watcher.go to implement the reconcile loop for Watcher - functional tests - Watcher deployment is added to one of the existing kuttl tests Jira: OSPRH-16241
1 parent 08d9499 commit ffc6154

22 files changed

Lines changed: 2200 additions & 4 deletions

apis/bases/core.openstack.org_openstackcontrolplanes.yaml

Lines changed: 428 additions & 0 deletions
Large diffs are not rendered by default.

apis/core/v1beta1/conditions.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,12 @@ const (
155155

156156
// OpenStackControlPlaneOpenStackVersionInitializationReadyCondition Status=True condition which indicates if OpenStackVersion is initialized
157157
OpenStackControlPlaneOpenStackVersionInitializationReadyCondition condition.Type = "OpenStackControlPlaneOpenStackVersionInitializationReadyCondition"
158+
159+
// OpenStackControlPlaneWatcherReadyCondition Status=True condition which indicates if Watcher is configured and operational
160+
OpenStackControlPlaneWatcherReadyCondition condition.Type = "OpenStackControlPlaneWatcherReady"
161+
162+
// OpenStackControlPlaneExposeWatcherReadyCondition Status=True condition which indicates if Watcher is exposed via a route
163+
OpenStackControlPlaneExposeWatcherReadyCondition condition.Type = "OpenStackControlPlaneExposeWatcherReady"
158164
)
159165

160166
// Common Messages used by API objects.
@@ -486,6 +492,18 @@ const (
486492

487493
// OpenStackControlPlaneOpenStackVersionInitializationReadyErrorMessage
488494
OpenStackControlPlaneOpenStackVersionInitializationReadyErrorMessage = "OpenStackControlPlane OpenStackVersion initialization error occured %s"
495+
496+
// OpenStackControlPlaneWatcherReadyInitMessage
497+
OpenStackControlPlaneWatcherReadyInitMessage = "OpenStackControlPlane Watcher not started"
498+
499+
// OpenStackControlPlaneWatcherReadyMessage
500+
OpenStackControlPlaneWatcherReadyMessage = "OpenStackControlPlane Watcher completed"
501+
502+
// OpenStackControlPlaneWatcherReadyRunningMessage
503+
OpenStackControlPlaneWatcherReadyRunningMessage = "OpenStackControlPlane Watcher in progress"
504+
505+
// OpenStackControlPlaneWatcherReadyErrorMessage
506+
OpenStackControlPlaneWatcherReadyErrorMessage = "OpenStackControlPlane Watcher error occured %s"
489507
)
490508

491509
// Version Conditions used by to drive minor updates

apis/core/v1beta1/openstackcontrolplane_types.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ import (
4747
placementv1 "github.com/openstack-k8s-operators/placement-operator/api/v1beta1"
4848
swiftv1 "github.com/openstack-k8s-operators/swift-operator/api/v1beta1"
4949
telemetryv1 "github.com/openstack-k8s-operators/telemetry-operator/api/v1beta1"
50+
watcherv1 "github.com/openstack-k8s-operators/watcher-operator/api/v1beta1"
5051

5152
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
5253
)
@@ -212,6 +213,11 @@ type OpenStackControlPlaneSpec struct {
212213
// TopologyRef to apply the Topology defined by the associated CR referenced
213214
// by name
214215
TopologyRef *topologyv1.TopoRef `json:"topologyRef,omitempty"`
216+
217+
// +kubebuilder:validation:Optional
218+
// +operator-sdk:csv:customresourcedefinitions:type=spec
219+
// Watcher - Parameters related to the Watcher service
220+
Watcher WatcherSection `json:"watcher,omitempty"`
215221
}
216222

217223
// TLSSection defines the desired state of TLS configuration
@@ -798,6 +804,25 @@ type OpenStackClientSection struct {
798804
Template v1beta1.OpenStackClientSpecCore `json:"template,omitempty"`
799805
}
800806

807+
// WatcherSection defines the desired state of Watcher service
808+
type WatcherSection struct {
809+
// +kubebuilder:validation:Optional
810+
// +kubebuilder:default=false
811+
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:booleanSwitch"}
812+
// Enabled - Whether Watcher service should be deployed and managed
813+
Enabled bool `json:"enabled"`
814+
815+
// +kubebuilder:validation:Optional
816+
// +operator-sdk:csv:customresourcedefinitions:type=spec
817+
// Template - Overrides to use when creating the Watcher service
818+
Template *watcherv1.WatcherSpecCore `json:"template,omitempty"`
819+
820+
// +kubebuilder:validation:Optional
821+
// +operator-sdk:csv:customresourcedefinitions:type=spec
822+
// APIOverride, provides the ability to override the generated manifest of several child resources.
823+
APIOverride Override `json:"apiOverride,omitempty"`
824+
}
825+
801826
// OpenStackControlPlaneStatus defines the observed state of OpenStackControlPlane
802827
type OpenStackControlPlaneStatus struct {
803828
// +operator-sdk:csv:customresourcedefinitions:type=status,xDescriptors={"urn:alm:descriptor:io.kubernetes.conditions"}
@@ -913,6 +938,7 @@ func (instance *OpenStackControlPlane) InitConditions() {
913938
condition.UnknownCondition(OpenStackControlPlaneRedisReadyCondition, condition.InitReason, OpenStackControlPlaneRedisReadyInitMessage),
914939
condition.UnknownCondition(OpenStackControlPlaneCAReadyCondition, condition.InitReason, OpenStackControlPlaneCAReadyInitMessage),
915940
condition.UnknownCondition(OpenStackControlPlaneOpenStackVersionInitializationReadyCondition, condition.InitReason, OpenStackControlPlaneOpenStackVersionInitializationReadyInitMessage),
941+
condition.UnknownCondition(OpenStackControlPlaneWatcherReadyCondition, condition.InitReason, OpenStackControlPlaneWatcherReadyInitMessage),
916942

917943
// Also add the overall status condition as Unknown
918944
condition.UnknownCondition(condition.ReadyCondition, condition.InitReason, condition.ReadyInitMessage),

apis/core/v1beta1/openstackcontrolplane_webhook.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
common_webhook "github.com/openstack-k8s-operators/lib-common/modules/common/webhook"
2727
mariadbv1 "github.com/openstack-k8s-operators/mariadb-operator/api/v1beta1"
2828
placementv1 "github.com/openstack-k8s-operators/placement-operator/api/v1beta1"
29+
watcherv1 "github.com/openstack-k8s-operators/watcher-operator/api/v1beta1"
2930
"golang.org/x/exp/maps"
3031
"golang.org/x/exp/slices"
3132
apierrors "k8s.io/apimachinery/pkg/api/errors"
@@ -243,6 +244,12 @@ func (r *OpenStackControlPlane) checkDepsEnabled(name string) string {
243244
if !(r.Spec.Rabbitmq.Enabled && r.Spec.Keystone.Enabled) {
244245
reqs = "RabbitMQ, Keystone"
245246
}
247+
case "Watcher":
248+
if !(r.Spec.Galera.Enabled && r.Spec.Memcached.Enabled && r.Spec.Rabbitmq.Enabled &&
249+
r.Spec.Keystone.Enabled && r.Spec.Telemetry.Enabled && *r.Spec.Telemetry.Template.Ceilometer.Enabled &&
250+
*r.Spec.Telemetry.Template.MetricStorage.Enabled) {
251+
reqs = "Galera, Memcached, RabbitMQ, Keystone, Telemetry, Telemetry.Ceilometer, Telemetry.MetricStorage"
252+
}
246253
}
247254

248255
// If "reqs" is not the empty string, we have missing requirements
@@ -344,6 +351,11 @@ func (r *OpenStackControlPlane) ValidateCreateServices(basePath *field.Path) (ad
344351
errors = append(errors, validateTLSOverrideSpec(&r.Spec.Designate.APIOverride.Route, basePath.Child("designate").Child("apiOverride").Child("route"))...)
345352
}
346353

354+
if r.Spec.Watcher.Enabled {
355+
errors = append(errors, r.Spec.Watcher.Template.ValidateCreate(basePath.Child("watcher").Child("template"), r.Namespace)...)
356+
errors = append(errors, validateTLSOverrideSpec(&r.Spec.Watcher.APIOverride.Route, basePath.Child("watcher").Child("apiOverride").Child("route"))...)
357+
}
358+
347359
// Validation for remaining services...
348360
if r.Spec.Galera.Enabled {
349361
for key, s := range *r.Spec.Galera.Templates {
@@ -529,6 +541,14 @@ func (r *OpenStackControlPlane) ValidateUpdateServices(old OpenStackControlPlane
529541
errors = append(errors, validateTLSOverrideSpec(&r.Spec.Designate.APIOverride.Route, basePath.Child("designate").Child("apiOverride").Child("route"))...)
530542
}
531543

544+
if r.Spec.Watcher.Enabled {
545+
if old.Watcher.Template == nil {
546+
old.Watcher.Template = &watcherv1.WatcherSpecCore{}
547+
}
548+
errors = append(errors, r.Spec.Watcher.Template.ValidateUpdate(*old.Watcher.Template, basePath.Child("watcher").Child("template"), r.Namespace)...)
549+
errors = append(errors, validateTLSOverrideSpec(&r.Spec.Watcher.APIOverride.Route, basePath.Child("watcher").Child("apiOverride").Child("route"))...)
550+
}
551+
532552
if r.Spec.Memcached.Enabled {
533553
if r.Spec.Memcached.Templates != nil {
534554
err := common_webhook.ValidateDNS1123Label(
@@ -675,6 +695,12 @@ func (r *OpenStackControlPlane) ValidateServiceDependencies(basePath *field.Path
675695
allErrs = append(allErrs, err)
676696
}
677697
}
698+
if r.Spec.Watcher.Enabled {
699+
if depErrorMsg := r.checkDepsEnabled("Watcher"); depErrorMsg != "" {
700+
err := field.Invalid(basePath.Child("watcher").Child("enabled"), r.Spec.Watcher.Enabled, depErrorMsg)
701+
allErrs = append(allErrs, err)
702+
}
703+
}
678704

679705
return allErrs
680706
}
@@ -1026,6 +1052,20 @@ func (r *OpenStackControlPlane) DefaultServices() {
10261052
}
10271053
}
10281054

1055+
// Watcher
1056+
if r.Spec.Watcher.Enabled || r.Spec.Watcher.Template != nil {
1057+
if r.Spec.Watcher.Template == nil {
1058+
r.Spec.Watcher.Template = &watcherv1.WatcherSpecCore{}
1059+
}
1060+
r.Spec.Watcher.Template.Default()
1061+
initializeOverrideSpec(&r.Spec.Watcher.APIOverride.Route, true)
1062+
1063+
// Default DatabaseInstance
1064+
if r.Spec.Watcher.Template.DatabaseInstance == nil || *r.Spec.Watcher.Template.DatabaseInstance == "" {
1065+
r.Spec.Watcher.Template.DatabaseInstance = ptr.To("openstack")
1066+
}
1067+
}
1068+
10291069
}
10301070

10311071
// DefaultLabel - adding default label to the OpenStackControlPlane

apis/core/v1beta1/zz_generated.deepcopy.go

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

apis/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ require (
2828
github.com/openstack-k8s-operators/placement-operator/api v0.6.1-0.20250707171111-ffcacac27d6e
2929
github.com/openstack-k8s-operators/swift-operator/api v0.6.1-0.20250707082032-7d602d482e23
3030
github.com/openstack-k8s-operators/telemetry-operator/api v0.6.1-0.20250711160256-599b396b8cc4
31+
github.com/openstack-k8s-operators/watcher-operator/api v0.6.1-0.20250714075808-69a28caef8a3
3132
github.com/rhobs/obo-prometheus-operator/pkg/apis/monitoring v0.71.0-rhobs1 // indirect
3233
github.com/rhobs/observability-operator v0.3.1 // indirect
3334
go.uber.org/multierr v1.11.0 // indirect

apis/go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ github.com/openstack-k8s-operators/swift-operator/api v0.6.1-0.20250707082032-7d
140140
github.com/openstack-k8s-operators/swift-operator/api v0.6.1-0.20250707082032-7d602d482e23/go.mod h1:AWJZ0UOiQKNJMyAzDw3bRcRihRXe4z3lekofG5/BWds=
141141
github.com/openstack-k8s-operators/telemetry-operator/api v0.6.1-0.20250711160256-599b396b8cc4 h1:TJ0tI5E4S3HAlpVQMot2e0M+mcJqUSQakdEgX2AC6Xg=
142142
github.com/openstack-k8s-operators/telemetry-operator/api v0.6.1-0.20250711160256-599b396b8cc4/go.mod h1:0jfQR21/yBCXVFMqnxEnsdtraV4I49cAr6qwe8wIe6E=
143+
github.com/openstack-k8s-operators/watcher-operator/api v0.6.1-0.20250714075808-69a28caef8a3 h1:fLGQo4f1BYb7QyrxP6cTwC1oM/P3VOZY+3TXj0brU2I=
144+
github.com/openstack-k8s-operators/watcher-operator/api v0.6.1-0.20250714075808-69a28caef8a3/go.mod h1:h/dLtKUg2Uc1R4UuFM/xN3POX9+0p2YCiBdzs4UHCqw=
143145
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
144146
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
145147
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=

0 commit comments

Comments
 (0)