Skip to content

Commit 5085d03

Browse files
authored
Pool concurrency controls and ResourceHandle status (#102)
* Update CRDs to support providers and status in ResourceHandles - Add spec.provider for ResourceHandles - Add status.summary for ResourceHandles - Add spec.provider for ResourcePools - Code refactor
1 parent 38cef56 commit 5085d03

33 files changed

+2056
-615
lines changed

Development.adoc

+2
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ odo push
5555
+
5656
----
5757
ansible-playbook \
58+
-e ansible_python_interpreter='{{ ansible_playbook_python }}' \
5859
-e poolboy_domain=poolboy.dev.local \
5960
-e poolboy_namespace=poolboy-dev \
6061
-e poolboy_service_account=default \
@@ -123,6 +124,7 @@ helm template helm \
123124
+
124125
----
125126
ansible-playbook \
127+
-e ansible_python_interpreter='{{ ansible_playbook_python }}' \
126128
-e poolboy_domain=poolboy.dev.local \
127129
-e poolboy_namespace=poolboy-dev \
128130
-e poolboy_service_account=poolboy-dev \

README.adoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ image::docs/diagram.png[Poolboy Diagram,500,400]
2323

2424
. User updates an existing ResourceClaim
2525
. Each resource template in the ResourceClaim is checked for validity against the OpenAPIv3 schema in the ResourceProvider.
26-
. A JSON Patch for each resource template in the ResourceHandle is generated and then the JSON Patch is filtered according to each ResourceProvider's `spec.updateFilters`.
26+
. A JSON Patch for each resource template in the ResourceHandle is generated and then the JSON Patch is filtered according to each ResourceProvider's `spec.updateFilters`.
2727
. Updates are applied to the ResourceHandle.
2828

2929
=== ResourceHandle Creation or Update

helm/crds/resourceclaims.yaml

+32-3
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ spec:
8989
provider:
9090
description: >-
9191
ResourceProvider specification used to manage this claim.
92-
Mutually exclusive with provider.
92+
Mutually exclusive with resources.
9393
type: object
9494
required:
9595
- name
@@ -100,7 +100,7 @@ spec:
100100
type: string
101101
parameterValues:
102102
description: >-
103-
Parameter values used with this ResourcProvider.
103+
Parameter values used with the ResourceProvider.
104104
type: object
105105
x-kubernetes-preserve-unknown-fields: true
106106
resources:
@@ -163,6 +163,9 @@ spec:
163163
diffBase:
164164
description: Kopf diffbase
165165
type: string
166+
healthy:
167+
description: Health state as determined by check from ResourceProviders of resources.
168+
type: boolean
166169
kopf:
167170
description: Kopf status
168171
type: object
@@ -234,11 +237,14 @@ spec:
234237
namespace:
235238
type: string
236239
resources:
237-
description: Status of resources managed for this claim
240+
description: Status of resources managed for this ResourceClaim
238241
type: array
239242
items:
240243
type: object
241244
properties:
245+
healthy:
246+
description: Health state as determined by check from ResourceProvider.
247+
type: boolean
242248
name:
243249
description: >-
244250
A name used to identify the resource.
@@ -255,6 +261,26 @@ spec:
255261
type: string
256262
namespace:
257263
type: string
264+
ready:
265+
description: Readiness state as determined by check from ResourceProvider.
266+
type: boolean
267+
reference:
268+
description: >-
269+
Reference to managed resource.
270+
type: object
271+
required:
272+
- apiVersion
273+
- kind
274+
- name
275+
properties:
276+
apiVersion:
277+
type: string
278+
kind:
279+
type: string
280+
name:
281+
type: string
282+
namespace:
283+
type: string
258284
state:
259285
description: Resource state synchronized from managed resource
260286
type: object
@@ -270,6 +296,9 @@ spec:
270296
- Linked ResourceProvider
271297
- Resource Definition
272298
type: string
299+
ready:
300+
description: Readiness state as determined by check from ResourceProviders of resources.
301+
type: boolean
273302
summary:
274303
description: >-
275304
Status summary from current resources state, generated from ResourceProvider configuration.

helm/crds/resourcehandles.yaml

+81-11
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,18 @@ spec:
1616
subresources:
1717
status: {}
1818
additionalPrinterColumns:
19+
- name: Provider
20+
type: string
21+
jsonPath: .spec.provider.name
1922
- name: Pool
2023
type: string
2124
jsonPath: .spec.resourcePool.name
25+
- name: Healthy
26+
type: boolean
27+
jsonPath: .status.healthy
28+
- name: Ready
29+
type: boolean
30+
jsonPath: .status.ready
2231
- name: Claim Namespace
2332
type: string
2433
jsonPath: .spec.resourceClaim.namespace
@@ -56,8 +65,6 @@ spec:
5665
spec:
5766
description: ResourceHandle specification
5867
type: object
59-
required:
60-
- resources
6168
properties:
6269
lifespan:
6370
description: >-
@@ -90,6 +97,24 @@ spec:
9097
Ex: "3d" for 3 days.
9198
This value may be a template string.
9299
type: string
100+
provider:
101+
description: >-
102+
ResourceProvider specification used to generate resources rather than
103+
explicitly list spec.
104+
Mutually exclusive with resources.
105+
type: object
106+
required:
107+
- name
108+
properties:
109+
name:
110+
description: >-
111+
ResourceProvider name.
112+
type: string
113+
parameterValues:
114+
description: >-
115+
Parameter values used with the ResourceProvider to generate resources list.
116+
type: object
117+
x-kubernetes-preserve-unknown-fields: true
93118
resourceClaim:
94119
description: >-
95120
ResourceClaim reference for claim matched to this ResourceHandle when the handle has been claimed.
@@ -159,7 +184,8 @@ spec:
159184
type: string
160185
reference:
161186
description: >-
162-
Reference to managed resource
187+
Reference to managed resource.
188+
(Deprecated in spec in favor of status).
163189
type: object
164190
required:
165191
- apiVersion
@@ -180,14 +206,6 @@ spec:
180206
claim's template is used to manage the handle template.
181207
type: object
182208
x-kubernetes-preserve-unknown-fields: true
183-
waitingFor:
184-
description: >-
185-
Indication indicating that resource creation is blocked waiting on a condition.
186-
enum:
187-
- ResourceClaim
188-
- Linked ResourceProvider
189-
- Resource Definition
190-
type: string
191209
vars:
192210
description: >-
193211
Variables to use when evaluating validation checks and templates.
@@ -202,7 +220,59 @@ spec:
202220
diffBase:
203221
description: Kopf diffbase
204222
type: string
223+
healthy:
224+
description: Health state as determined by check from ResourceProviders of resources.
225+
type: boolean
205226
kopf:
206227
description: Kopf status
207228
type: object
208229
x-kubernetes-preserve-unknown-fields: true
230+
ready:
231+
description: Readiness state as determined by check from ResourceProviders of resources.
232+
type: boolean
233+
resources:
234+
description: Status of resources managed by this ResourceHandle
235+
type: array
236+
items:
237+
type: object
238+
properties:
239+
healthy:
240+
description: Health state as determined by check from ResourceProvider.
241+
type: boolean
242+
name:
243+
description: >-
244+
A name used to identify the resource.
245+
type: string
246+
ready:
247+
description: Readiness state as determined by check from ResourceProvider.
248+
type: boolean
249+
reference:
250+
description: >-
251+
Reference to managed resource.
252+
type: object
253+
required:
254+
- apiVersion
255+
- kind
256+
- name
257+
properties:
258+
apiVersion:
259+
type: string
260+
kind:
261+
type: string
262+
name:
263+
type: string
264+
namespace:
265+
type: string
266+
waitingFor:
267+
description: >-
268+
Indication indicating that resource creation is blocked waiting on a condition.
269+
enum:
270+
- ResourceClaim
271+
- Linked ResourceProvider
272+
- Resource Definition
273+
type: string
274+
summary:
275+
description: >-
276+
Status summary from current resources state, generated from ResourceProvider configuration.
277+
type: object
278+
x-kubernetes-preserve-unknown-fields: true

helm/crds/resourcepools.yaml

+54-2
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,18 @@ spec:
1616
subresources:
1717
status: {}
1818
additionalPrinterColumns:
19+
- name: ResourceProvider
20+
jsonPath: .spec.provider.name
21+
type: string
1922
- name: Min
2023
type: integer
2124
jsonPath: .spec.minAvailable
25+
- name: Available
26+
type: integer
27+
jsonPath: .status.resourceHandleCount.available
28+
- name: Ready
29+
type: integer
30+
jsonPath: .status.resourceHandleCount.ready
2231
- name: Age
2332
type: date
2433
jsonPath: .metadata.creationTimestamp
@@ -47,9 +56,11 @@ spec:
4756
spec:
4857
description: ResourcePool specification
4958
type: object
50-
required:
51-
- resources
5259
properties:
60+
deleteUnhealthyResourceHandles:
61+
description: >-
62+
If set then any unbound ResourceHandle that fails health check will be automatically deleted.
63+
type: boolean
5364
lifespan:
5465
description: >-
5566
Lifespan configuration for ResourceHandle provisioned by the ResourcePool.
@@ -83,12 +94,35 @@ spec:
8394
Ex: "3d" for 3 days.
8495
type: string
8596
pattern: ^[0-9]+[smhd]$
97+
maxUnready:
98+
description: >-
99+
Maximum number of resource handles that do not pass readiness check.
100+
type: integer
101+
minimum: 0
86102
minAvailable:
87103
description: >-
88104
Minimum number of unclaimed resource handles to maintain for the
89105
ResourcePool.
90106
type: integer
91107
minimum: 0
108+
provider:
109+
description: >-
110+
ResourceProvider specification used to generate resources rather than
111+
explicitly list spec.
112+
Mutually exclusive with resources.
113+
type: object
114+
required:
115+
- name
116+
properties:
117+
name:
118+
description: >-
119+
ResourceProvider name.
120+
type: string
121+
parameterValues:
122+
description: >-
123+
Parameter values used with the ResourceProvider to generate resources list.
124+
type: object
125+
x-kubernetes-preserve-unknown-fields: true
92126
resources:
93127
description: >-
94128
Resources description to apply to ResourceHandles for the pool.
@@ -141,3 +175,21 @@ spec:
141175
description: Kopf status
142176
type: object
143177
x-kubernetes-preserve-unknown-fields: true
178+
resourceHandleCount:
179+
type: object
180+
properties:
181+
available:
182+
type: integer
183+
ready:
184+
type: integer
185+
resourceHandles:
186+
type: array
187+
items:
188+
type: object
189+
properties:
190+
healthy:
191+
type: boolean
192+
name:
193+
type: string
194+
ready:
195+
type: boolean

helm/crds/resourceproviders.yaml

+18
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ spec:
7676
If set to true, then ResourceHandle creation is disabled for any ResourceClaim using
7777
this ResourceProvider.
7878
type: boolean
79+
healthCheck:
80+
description: >-
81+
Check to determine if provisioned resources are healthy.
82+
Any pooled ResourceHandle that fails its health check will not be assigned to a ResourceClaim.
83+
Syntax is a template that should return a boolean.
84+
type: string
7985
lifespan:
8086
description: >-
8187
Used to generate lifespan configuration for ResourceHandles using the ResourceProvider.
@@ -102,6 +108,13 @@ spec:
102108
Ex: "3d" for 3 days.
103109
This value may be a template string.
104110
type: string
111+
unclaimed:
112+
description: >-
113+
Lifespan applied to ResourceHandles in the pool to allow for replacement of unused resources.
114+
Configured as a whole number followed by units "s", "m", "h", or "d" for seconds, minutes, hours, or days.
115+
Ex: "3d" for 3 days.
116+
type: string
117+
pattern: ^[0-9]+[smhd]$
105118
linkedResourceProviders:
106119
description: >-
107120
List of ResourceProviders this one depends upon.
@@ -236,6 +249,11 @@ spec:
236249
fields to specific numeric ranges.
237250
type: object
238251
x-kubernetes-preserve-unknown-fields: true
252+
readinessCheck:
253+
description: >-
254+
Check to determine when provisioned resources are ready.
255+
Syntax is a template that should return a boolean.
256+
type: string
239257
resourceClaimAnnotations:
240258
description: >-
241259
Annotations to apply to ResourceClaim.

0 commit comments

Comments
 (0)