Skip to content

Commit b24083b

Browse files
Merge pull request openstack-k8s-operators#1535 from amoralej/add-watcher
Integrate Watcher into OpenStack Operator
2 parents 93d695e + 430156f commit b24083b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+11779
-4970
lines changed

apis/bases/core.openstack.org_openstackcontrolplanes.yaml

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

apis/bases/core.openstack.org_openstackversions.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,12 @@ spec:
227227
type: string
228228
testTobikoImage:
229229
type: string
230+
watcherAPIImage:
231+
type: string
232+
watcherApplierImage:
233+
type: string
234+
watcherDecisionEngineImage:
235+
type: string
230236
type: object
231237
targetVersion:
232238
type: string
@@ -451,6 +457,12 @@ spec:
451457
type: string
452458
testTobikoImage:
453459
type: string
460+
watcherAPIImage:
461+
type: string
462+
watcherApplierImage:
463+
type: string
464+
watcherDecisionEngineImage:
465+
type: string
454466
type: object
455467
type: object
456468
containerImages:
@@ -645,6 +657,12 @@ spec:
645657
type: string
646658
testTobikoImage:
647659
type: string
660+
watcherAPIImage:
661+
type: string
662+
watcherApplierImage:
663+
type: string
664+
watcherDecisionEngineImage:
665+
type: string
648666
type: object
649667
deployedVersion:
650668
type: string

apis/bases/operator.openstack.org_openstacks.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ spec:
9595
- swift
9696
- telemetry
9797
- test
98+
- watcher
9899
minLength: 1
99100
type: string
100101
replicas:

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: 44 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"
@@ -244,6 +245,12 @@ func (r *OpenStackControlPlane) checkDepsEnabled(name string) string {
244245
if !(r.Spec.Rabbitmq.Enabled && r.Spec.Keystone.Enabled) {
245246
reqs = "RabbitMQ, Keystone"
246247
}
248+
case "Watcher":
249+
if !(r.Spec.Galera.Enabled && r.Spec.Memcached.Enabled && r.Spec.Rabbitmq.Enabled &&
250+
r.Spec.Keystone.Enabled && r.Spec.Telemetry.Enabled && *r.Spec.Telemetry.Template.Ceilometer.Enabled &&
251+
*r.Spec.Telemetry.Template.MetricStorage.Enabled) {
252+
reqs = "Galera, Memcached, RabbitMQ, Keystone, Telemetry, Telemetry.Ceilometer, Telemetry.MetricStorage"
253+
}
247254
}
248255

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

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

548+
if r.Spec.Watcher.Enabled {
549+
if old.Watcher.Template == nil {
550+
old.Watcher.Template = &watcherv1.WatcherSpecCore{}
551+
}
552+
errors = append(errors, r.Spec.Watcher.Template.ValidateUpdate(*old.Watcher.Template, basePath.Child("watcher").Child("template"), r.Namespace)...)
553+
errors = append(errors, validateTLSOverrideSpec(&r.Spec.Watcher.APIOverride.Route, basePath.Child("watcher").Child("apiOverride").Child("route"))...)
554+
}
555+
536556
if r.Spec.Memcached.Enabled {
537557
if r.Spec.Memcached.Templates != nil {
538558
err := common_webhook.ValidateDNS1123Label(
@@ -680,6 +700,12 @@ func (r *OpenStackControlPlane) ValidateServiceDependencies(basePath *field.Path
680700
allErrs = append(allErrs, err)
681701
}
682702
}
703+
if r.Spec.Watcher.Enabled {
704+
if depErrorMsg := r.checkDepsEnabled("Watcher"); depErrorMsg != "" {
705+
err := field.Invalid(basePath.Child("watcher").Child("enabled"), r.Spec.Watcher.Enabled, depErrorMsg)
706+
allErrs = append(allErrs, err)
707+
}
708+
}
683709

684710
return allErrs
685711
}
@@ -1031,6 +1057,24 @@ func (r *OpenStackControlPlane) DefaultServices() {
10311057
}
10321058
}
10331059

1060+
// Watcher
1061+
if r.Spec.Watcher.Enabled || r.Spec.Watcher.Template != nil {
1062+
if r.Spec.Watcher.Template == nil {
1063+
r.Spec.Watcher.Template = &watcherv1.WatcherSpecCore{}
1064+
}
1065+
r.Spec.Watcher.Template.Default()
1066+
1067+
if r.Spec.Watcher.Enabled {
1068+
initializeOverrideSpec(&r.Spec.Watcher.APIOverride.Route, true)
1069+
r.Spec.Watcher.Template.SetDefaultRouteAnnotations(r.Spec.Watcher.APIOverride.Route.Annotations)
1070+
}
1071+
1072+
// Default DatabaseInstance
1073+
if r.Spec.Watcher.Template.DatabaseInstance == nil || *r.Spec.Watcher.Template.DatabaseInstance == "" {
1074+
r.Spec.Watcher.Template.DatabaseInstance = ptr.To("openstack")
1075+
}
1076+
}
1077+
10341078
}
10351079

10361080
// DefaultLabel - adding default label to the OpenStackControlPlane

apis/core/v1beta1/openstackversion_types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,9 @@ type ContainerTemplate struct {
166166
TestTobikoImage *string `json:"testTobikoImage,omitempty"`
167167
TestHorizontestImage *string `json:"testHorizontestImage,omitempty"`
168168
TestAnsibletestImage *string `json:"testAnsibletestImage,omitempty"`
169+
WatcherAPIImage *string `json:"watcherAPIImage,omitempty"`
170+
WatcherApplierImage *string `json:"watcherApplierImage,omitempty"`
171+
WatcherDecisionEngineImage *string `json:"watcherDecisionEngineImage,omitempty"`
169172
}
170173

171174
// ServiceDefaults - struct that contains defaults for OSP services that can change over time

apis/core/v1beta1/zz_generated.deepcopy.go

Lines changed: 38 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.20250728155507-d9002b5278c5
2929
github.com/openstack-k8s-operators/swift-operator/api v0.6.1-0.20250731125612-06e01ca6844a
3030
github.com/openstack-k8s-operators/telemetry-operator/api v0.6.1-0.20250731100510-eb1934ea2786
31+
github.com/openstack-k8s-operators/watcher-operator/api v0.6.1-0.20250730131205-1720b37fea7f
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.20250731125612-06
140140
github.com/openstack-k8s-operators/swift-operator/api v0.6.1-0.20250731125612-06e01ca6844a/go.mod h1:KqMMH8J0UW6oqFa0viWmITCKdWNNboQL7xupnPnvkDg=
141141
github.com/openstack-k8s-operators/telemetry-operator/api v0.6.1-0.20250731100510-eb1934ea2786 h1:JqHIKGHUe02LkyIi3MKgvoa/e8F//7AVnZ5/sIZSI0o=
142142
github.com/openstack-k8s-operators/telemetry-operator/api v0.6.1-0.20250731100510-eb1934ea2786/go.mod h1:462IbW/UydmvLhQNfZPmDafav23FxibUiA34yGxtR9k=
143+
github.com/openstack-k8s-operators/watcher-operator/api v0.6.1-0.20250730131205-1720b37fea7f h1:6I2FFzRAws3Udu0QSer/bZq0xluKBXdJ0E7bFrxDtcQ=
144+
github.com/openstack-k8s-operators/watcher-operator/api v0.6.1-0.20250730131205-1720b37fea7f/go.mod h1:XTKoOjXqybRkS7gwi02VxkQmDWud4OUKivWi9TJ+8Uk=
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)