Skip to content

Commit a18e89e

Browse files
committed
Integrate WatcherAPI creation and update on the main Watcher reconcile
This patch integrates the creation/update/delete of WatcherAPI in the main Watcher reconcile loop. It: - Adds the relevant WatcherAPI CRD atributes into the Watcher CRD. - Adds the logic to create/update/delete WatcherAPI from the Watcher CR. - Modifty existing envtest functional tests to validate the WatcherAPI creation from the Watcher objects.
1 parent a22488f commit a18e89e

14 files changed

+462
-51
lines changed

api/bases/watcher.openstack.org_watcherappliers.yaml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,6 @@ spec:
4343
description: The service specific Container Image URL (will be set
4444
to environmental default if empty)
4545
type: string
46-
nodeSelector:
47-
additionalProperties:
48-
type: string
49-
description: |-
50-
NodeSelector to target subset of worker nodes running this component. Setting here overrides
51-
any global NodeSelector settings within the Watcher CR.
52-
type: object
5346
replicas:
5447
default: 1
5548
description: Replicas of Watcher service to run

api/bases/watcher.openstack.org_watcherdecisionengines.yaml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,6 @@ spec:
4444
description: The service specific Container Image URL (will be set
4545
to environmental default if empty)
4646
type: string
47-
nodeSelector:
48-
additionalProperties:
49-
type: string
50-
description: |-
51-
NodeSelector to target subset of worker nodes running this component. Setting here overrides
52-
any global NodeSelector settings within the Watcher CR.
53-
type: object
5447
replicas:
5548
default: 1
5649
description: Replicas of Watcher service to run

api/bases/watcher.openstack.org_watchers.yaml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,83 @@ spec:
4242
apiContainerImageURL:
4343
description: APIContainerImageURL
4444
type: string
45+
apiServiceTemplate:
46+
default:
47+
replicas: 1
48+
description: APIServiceTemplate - define the watcher-api service
49+
properties:
50+
nodeSelector:
51+
additionalProperties:
52+
type: string
53+
description: |-
54+
NodeSelector to target subset of worker nodes running this component. Setting here overrides
55+
any global NodeSelector settings within the Watcher CR.
56+
type: object
57+
replicas:
58+
default: 1
59+
description: Replicas of Watcher service to run
60+
format: int32
61+
maximum: 32
62+
minimum: 0
63+
type: integer
64+
resources:
65+
description: |-
66+
Resources - Compute Resources required by this service (Limits/Requests).
67+
https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
68+
properties:
69+
claims:
70+
description: |-
71+
Claims lists the names of resources, defined in spec.resourceClaims,
72+
that are used by this container.
73+
74+
75+
This is an alpha field and requires enabling the
76+
DynamicResourceAllocation feature gate.
77+
78+
79+
This field is immutable. It can only be set for containers.
80+
items:
81+
description: ResourceClaim references one entry in PodSpec.ResourceClaims.
82+
properties:
83+
name:
84+
description: |-
85+
Name must match the name of one entry in pod.spec.resourceClaims of
86+
the Pod where this field is used. It makes that resource available
87+
inside a container.
88+
type: string
89+
required:
90+
- name
91+
type: object
92+
type: array
93+
x-kubernetes-list-map-keys:
94+
- name
95+
x-kubernetes-list-type: map
96+
limits:
97+
additionalProperties:
98+
anyOf:
99+
- type: integer
100+
- type: string
101+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
102+
x-kubernetes-int-or-string: true
103+
description: |-
104+
Limits describes the maximum amount of compute resources allowed.
105+
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
106+
type: object
107+
requests:
108+
additionalProperties:
109+
anyOf:
110+
- type: integer
111+
- type: string
112+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
113+
x-kubernetes-int-or-string: true
114+
description: |-
115+
Requests describes the minimum amount of compute resources required.
116+
If Requests is omitted for a container, it defaults to Limits if that is explicitly specified,
117+
otherwise to an implementation-defined value. Requests cannot exceed Limits.
118+
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
119+
type: object
120+
type: object
121+
type: object
45122
applierContainerImageURL:
46123
description: ApplierContainerImageURL
47124
type: string
@@ -63,6 +140,13 @@ spec:
63140
description: MemcachedInstance is the name of the Memcached CR that
64141
all watcher service will use.
65142
type: string
143+
nodeSelector:
144+
additionalProperties:
145+
type: string
146+
description: |-
147+
NodeSelector to target subset of worker nodes running this component. Setting here overrides
148+
any global NodeSelector settings within the Watcher CR.
149+
type: object
66150
passwordSelectors:
67151
default:
68152
service: WatcherPassword
@@ -97,6 +181,7 @@ spec:
97181
type: string
98182
required:
99183
- apiContainerImageURL
184+
- apiServiceTemplate
100185
- applierContainerImageURL
101186
- databaseInstance
102187
- decisionengineContainerImageURL
@@ -105,6 +190,11 @@ spec:
105190
status:
106191
description: WatcherStatus defines the observed state of Watcher
107192
properties:
193+
apiServiceReadyCount:
194+
description: APIServiceReadyCount defines the number or replicas ready
195+
from watcher-api
196+
format: int32
197+
type: integer
108198
conditions:
109199
description: Conditions
110200
items:

api/v1beta1/common_types.go

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ type WatcherCommon struct {
5050
// +kubebuilder:default=false
5151
// PreserveJobs - do not delete jobs after they finished e.g. to check logs
5252
PreserveJobs bool `json:"preserveJobs"`
53+
54+
// +kubebuilder:validation:Optional
55+
// NodeSelector to target subset of worker nodes running this component. Setting here overrides
56+
// any global NodeSelector settings within the Watcher CR.
57+
NodeSelector *map[string]string `json:"nodeSelector,omitempty"`
5358
}
5459

5560
// WatcherTemplate defines the fields used in the top level CR
@@ -78,6 +83,11 @@ type WatcherTemplate struct {
7883
// +kubebuilder:default=watcher
7984
// DatabaseAccount - MariaDBAccount CR name used for watcher DB, defaults to watcher
8085
DatabaseAccount string `json:"databaseAccount"`
86+
87+
// +kubebuilder:validation:Required
88+
// +kubebuilder:default={replicas:1}
89+
// APIServiceTemplate - define the watcher-api service
90+
APIServiceTemplate WatcherAPITemplate `json:"apiServiceTemplate"`
8191
}
8292

8393
// PasswordSelector to identify the DB and AdminUser password from the Secret
@@ -94,11 +104,6 @@ type WatcherSubCrsCommon struct {
94104
// The service specific Container Image URL (will be set to environmental default if empty)
95105
ContainerImage string `json:"containerImage"`
96106

97-
// +kubebuilder:validation:Optional
98-
// NodeSelector to target subset of worker nodes running this component. Setting here overrides
99-
// any global NodeSelector settings within the Watcher CR.
100-
NodeSelector *map[string]string `json:"nodeSelector,omitempty"`
101-
102107
// +kubebuilder:validation:Optional
103108
// +kubebuilder:default=1
104109
// +kubebuilder:validation:Maximum=32
@@ -117,6 +122,27 @@ type WatcherSubCrsCommon struct {
117122
ServiceAccount string `json:"serviceAccount"`
118123
}
119124

125+
// WatcherSubCrsTemplate define de common part of the input parameters specified by the user to
126+
// create a 2nd CR via higher level CRDs.
127+
type WatcherSubCrsTemplate struct {
128+
// +kubebuilder:validation:Optional
129+
// +kubebuilder:default=1
130+
// +kubebuilder:validation:Maximum=32
131+
// +kubebuilder:validation:Minimum=0
132+
// Replicas of Watcher service to run
133+
Replicas *int32 `json:"replicas"`
134+
135+
// +kubebuilder:validation:Optional
136+
// Resources - Compute Resources required by this service (Limits/Requests).
137+
// https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
138+
Resources corev1.ResourceRequirements `json:"resources,omitempty"`
139+
140+
// +kubebuilder:validation:Optional
141+
// NodeSelector to target subset of worker nodes running this component. Setting here overrides
142+
// any global NodeSelector settings within the Watcher CR.
143+
NodeSelector *map[string]string `json:"nodeSelector,omitempty"`
144+
}
145+
120146
type WatcherImages struct {
121147
// +kubebuilder:validation:Required
122148
// APIContainerImageURL

api/v1beta1/conditions.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import "github.com/openstack-k8s-operators/lib-common/modules/common/condition"
55
const (
66
// WatcherRabbitMQTransportURLReadyCondition -
77
WatcherRabbitMQTransportURLReadyCondition condition.Type = "WatcherRabbitMQTransportURLReady"
8+
// WatcherAPIReadyCondition -
9+
WatcherAPIReadyCondition condition.Type = "WatcherAPIReady"
810
)
911

1012
const (
@@ -14,4 +16,12 @@ const (
1416
WatcherRabbitMQTransportURLReadyMessage = "WatcherRabbitMQTransportURL successfully created"
1517
// WatcherRabbitMQTransportURLReadyErrorMessage -
1618
WatcherRabbitMQTransportURLReadyErrorMessage = "WatcherRabbitMQTransportURL error occured %s"
19+
// WatcherAPIReadyInitMessage -
20+
WatcherAPIReadyInitMessage = "WatcherAPI creation not started"
21+
// WatcherAPIReadyRunningMessage -
22+
WatcherAPIReadyRunningMessage = "WatcherAPI creation in progress"
23+
// WatcherAPIReadyMessage -
24+
WatcherAPIReadyMessage = "WatcherAPI successfully created"
25+
// WatcherAPIReadyErrorMessage -
26+
WatcherAPIReadyErrorMessage = "WatcherAPI error occured %s"
1727
)

api/v1beta1/watcher_types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ type WatcherStatus struct {
5252
// then the controller has not processed the latest changes injected by
5353
// the opentack-operator in the top-level CR (e.g. the ContainerImage)
5454
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
55+
56+
// APIServiceReadyCount defines the number or replicas ready from watcher-api
57+
APIServiceReadyCount int32 `json:"apiServiceReadyCount,omitempty"`
5558
}
5659

5760
//+kubebuilder:object:root=true

api/v1beta1/watcherapi_types.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ type WatcherAPIStatus struct {
5353
Hash map[string]string `json:"hash,omitempty"`
5454
}
5555

56+
// WatcherAPITemplate defines the input parameters specified by the user to
57+
// create a WatcherAPI via higher level CRDs.
58+
type WatcherAPITemplate struct {
59+
WatcherSubCrsTemplate `json:",inline"`
60+
}
61+
5662
//+kubebuilder:object:root=true
5763
//+kubebuilder:subresource:status
5864

api/v1beta1/zz_generated.deepcopy.go

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

0 commit comments

Comments
 (0)