Skip to content

Commit 875fdd2

Browse files
committed
wip
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
1 parent d6ad852 commit 875fdd2

File tree

1 file changed

+138
-33
lines changed

1 file changed

+138
-33
lines changed

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/ResourceOperations.java

Lines changed: 138 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,9 @@ public ResourceOperations(Context<P> context) {
4848

4949
/**
5050
* Updates the resource and caches the response if needed, thus making sure that next
51-
* reconciliation will contain to updated resource. Or more recent one if someone did an update
52-
* after our update.
53-
*
54-
* <p>Optionally also can filter out the event, what is the result of this update.
51+
* reconciliation will see to updated resource - or more recent one if additional update happened
52+
* after this update; In addition to that it filters out the event from the update, so
53+
* reconciliation is not triggered by own update.
5554
*
5655
* <p>You are free to control the optimistic locking by setting the resource version in resource
5756
* metadata. In case of SSA we advise not to do updates with optimistic locking.
@@ -77,8 +76,15 @@ public <R extends HasMetadata> R serverSideApply(R resource) {
7776
}
7877

7978
/**
80-
* Server-Side Apply the resource status subresource. Updates the resource status and caches the
81-
* response if needed, ensuring the next reconciliation will contain the updated resource.
79+
* Server-Side Apply the resource status subresource.
80+
*
81+
* <p>Updates the resource and caches the response if needed, thus making sure that next
82+
* reconciliation will see to updated resource - or more recent one if additional update happened
83+
* after this update; In addition to that it filters out the event from this update, so
84+
* reconciliation is not triggered by own update.
85+
*
86+
* <p>You are free to control the optimistic locking by setting the resource version in resource
87+
* metadata. In case of SSA we advise not to do updates with optimistic locking.
8288
*
8389
* @param resource fresh resource for server side apply
8490
* @return updated resource
@@ -102,9 +108,15 @@ public <R extends HasMetadata> R serverSideApplyStatus(R resource) {
102108
}
103109

104110
/**
105-
* Server-Side Apply the primary resource. Updates the primary resource and caches the response
106-
* using the controller's event source, ensuring the next reconciliation will contain the updated
107-
* resource.
111+
* Server-Side Apply the primary resource.
112+
*
113+
* <p>Updates the resource and caches the response if needed, thus making sure that next
114+
* reconciliation will see to updated resource - or more recent one if additional update happened
115+
* after this update; In addition to that it filters out the event from this update, so
116+
* reconciliation is not triggered by own update.
117+
*
118+
* <p>You are free to control the optimistic locking by setting the resource version in resource
119+
* metadata. In case of SSA we advise not to do updates with optimistic locking.
108120
*
109121
* @param resource primary resource for server side apply
110122
* @return updated resource
@@ -127,8 +139,15 @@ public <P extends HasMetadata> P serverSideApplyPrimary(P resource) {
127139
}
128140

129141
/**
130-
* Server-Side Apply the primary resource status subresource. Updates the primary resource status
131-
* and caches the response using the controller's event source.
142+
* Server-Side Apply the primary resource status subresource.
143+
*
144+
* <p>Updates the resource and caches the response if needed, thus making sure that next
145+
* reconciliation will see to updated resource - or more recent one if additional update happened
146+
* after this update; In addition to that it filters out the event from this update, so
147+
* reconciliation is not triggered by own update.
148+
*
149+
* <p>You are free to control the optimistic locking by setting the resource version in resource
150+
* metadata. In case of SSA we advise not to do updates with optimistic locking.
132151
*
133152
* @param resource primary resource for server side apply
134153
* @return updated resource
@@ -152,8 +171,13 @@ public <P extends HasMetadata> P serverSideApplyPrimaryStatus(P resource) {
152171
}
153172

154173
/**
155-
* Updates the resource with optimistic locking based on the resource version. Caches the response
156-
* if needed, ensuring the next reconciliation will contain the updated resource.
174+
* Updates the resource and caches the response if needed, thus making sure that next
175+
* reconciliation will see to updated resource - or more recent one if additional update happened
176+
* after this update; In addition to that it filters out the event from this update, so
177+
* reconciliation is not triggered by own update.
178+
*
179+
* <p>You are free to control the optimistic locking by setting the resource version in resource
180+
* metadata.
157181
*
158182
* @param resource resource to update
159183
* @return updated resource
@@ -164,7 +188,15 @@ public <R extends HasMetadata> R update(R resource) {
164188
}
165189

166190
/**
167-
* Updates the resource status subresource with optimistic locking. Caches the response if needed.
191+
* Updates the resource status subresource.
192+
*
193+
* <p>Updates the resource and caches the response if needed, thus making sure that next
194+
* reconciliation will see to updated resource - or more recent one if additional update happened
195+
* after this update; In addition to that it filters out the event from this update, so
196+
* reconciliation is not triggered by own update.
197+
*
198+
* <p>You are free to control the optimistic locking by setting the resource version in resource
199+
* metadata.
168200
*
169201
* @param resource resource to update
170202
* @return updated resource
@@ -175,8 +207,15 @@ public <R extends HasMetadata> R updateStatus(R resource) {
175207
}
176208

177209
/**
178-
* Updates the primary resource with optimistic locking. Caches the response using the
179-
* controller's event source.
210+
* Updates the primary resource.
211+
*
212+
* <p>Updates the resource and caches the response if needed, thus making sure that next
213+
* reconciliation will see to updated resource - or more recent one if additional update happened
214+
* after this update; In addition to that it filters out the event from this update, so
215+
* reconciliation is not triggered by own update.
216+
*
217+
* <p>You are free to control the optimistic locking by setting the resource version in resource
218+
* metadata.
180219
*
181220
* @param resource primary resource to update
182221
* @return updated resource
@@ -190,8 +229,15 @@ public <R extends HasMetadata> R updatePrimary(R resource) {
190229
}
191230

192231
/**
193-
* Updates the primary resource status subresource with optimistic locking. Caches the response
194-
* using the controller's event source.
232+
* Updates the primary resource status subresource.
233+
*
234+
* <p>Updates the resource and caches the response if needed, thus making sure that next
235+
* reconciliation will see to updated resource - or more recent one if additional update happened
236+
* after this update; In addition to that it filters out the event from this update, so
237+
* reconciliation is not triggered by own update.
238+
*
239+
* <p>You are free to control the optimistic locking by setting the resource version in resource
240+
* metadata.
195241
*
196242
* @param resource primary resource to update
197243
* @return updated resource
@@ -208,6 +254,14 @@ public <R extends HasMetadata> R updatePrimaryStatus(R resource) {
208254
* Applies a JSON Patch to the resource. The unaryOperator function is used to modify the
209255
* resource, and the differences are sent as a JSON Patch to the Kubernetes API server.
210256
*
257+
* <p>Updates the resource and caches the response if needed, thus making sure that next
258+
* reconciliation will see to updated resource - or more recent one if additional update happened
259+
* after this update; In addition to that it filters out the event from this update, so
260+
* reconciliation is not triggered by own update.
261+
*
262+
* <p>You are free to control the optimistic locking by setting the resource version in resource
263+
* metadata.
264+
*
211265
* @param resource resource to patch
212266
* @param unaryOperator function to modify the resource
213267
* @return updated resource
@@ -222,6 +276,14 @@ public <R extends HasMetadata> R jsonPatch(R resource, UnaryOperator<R> unaryOpe
222276
* Applies a JSON Patch to the resource status subresource. The unaryOperator function is used to
223277
* modify the resource status, and the differences are sent as a JSON Patch.
224278
*
279+
* <p>Updates the resource and caches the response if needed, thus making sure that next
280+
* reconciliation will see to updated resource - or more recent one if additional update happened
281+
* after this update; In addition to that it filters out the event from this update, so
282+
* reconciliation is not triggered by own update.
283+
*
284+
* <p>You are free to control the optimistic locking by setting the resource version in resource
285+
* metadata.
286+
*
225287
* @param resource resource to patch
226288
* @param unaryOperator function to modify the resource
227289
* @return updated resource
@@ -233,8 +295,15 @@ public <R extends HasMetadata> R jsonPatchStatus(R resource, UnaryOperator<R> un
233295
}
234296

235297
/**
236-
* Applies a JSON Patch to the primary resource. Caches the response using the controller's event
237-
* source.
298+
* Applies a JSON Patch to the primary resource.
299+
*
300+
* <p>Updates the resource and caches the response if needed, thus making sure that next
301+
* reconciliation will see to updated resource - or more recent one if additional update happened
302+
* after this update; In addition to that it filters out the event from this update, so
303+
* reconciliation is not triggered by own update.
304+
*
305+
* <p>You are free to control the optimistic locking by setting the resource version in resource
306+
* metadata.
238307
*
239308
* @param resource primary resource to patch
240309
* @param unaryOperator function to modify the resource
@@ -249,8 +318,15 @@ public <R extends HasMetadata> R jsonPatchPrimary(R resource, UnaryOperator<R> u
249318
}
250319

251320
/**
252-
* Applies a JSON Patch to the primary resource status subresource. Caches the response using the
253-
* controller's event source.
321+
* Applies a JSON Patch to the primary resource status subresource.
322+
*
323+
* <p>Updates the resource and caches the response if needed, thus making sure that next
324+
* reconciliation will see to updated resource - or more recent one if additional update happened
325+
* after this update; In addition to that it filters out the event from this update, so
326+
* reconciliation is not triggered by own update.
327+
*
328+
* <p>You are free to control the optimistic locking by setting the resource version in resource
329+
* metadata.
254330
*
255331
* @param resource primary resource to patch
256332
* @param unaryOperator function to modify the resource
@@ -269,6 +345,14 @@ public <R extends HasMetadata> R jsonPatchPrimaryStatus(
269345
* Applies a JSON Merge Patch to the resource. JSON Merge Patch (RFC 7386) is a simpler patching
270346
* strategy that merges the provided resource with the existing resource on the server.
271347
*
348+
* <p>Updates the resource and caches the response if needed, thus making sure that next
349+
* reconciliation will see to updated resource - or more recent one if additional update happened
350+
* after this update; In addition to that it filters out the event from this update, so
351+
* reconciliation is not triggered by own update.
352+
*
353+
* <p>You are free to control the optimistic locking by setting the resource version in resource
354+
* metadata.
355+
*
272356
* @param resource resource to patch
273357
* @return updated resource
274358
* @param <R> resource type
@@ -278,8 +362,15 @@ public <R extends HasMetadata> R jsonMergePatch(R resource) {
278362
}
279363

280364
/**
281-
* Applies a JSON Merge Patch to the resource status subresource. Merges the provided resource
282-
* status with the existing resource status on the server.
365+
* Applies a JSON Merge Patch to the resource status subresource.
366+
*
367+
* <p>Updates the resource and caches the response if needed, thus making sure that next
368+
* reconciliation will see to updated resource - or more recent one if additional update happened
369+
* after this update; In addition to that it filters out the event from this update, so
370+
* reconciliation is not triggered by own update.
371+
*
372+
* <p>You are free to control the optimistic locking by setting the resource version in resource
373+
* metadata.
283374
*
284375
* @param resource resource to patch
285376
* @return updated resource
@@ -293,6 +384,14 @@ public <R extends HasMetadata> R jsonMergePatchStatus(R resource) {
293384
* Applies a JSON Merge Patch to the primary resource. Caches the response using the controller's
294385
* event source.
295386
*
387+
* <p>Updates the resource and caches the response if needed, thus making sure that next
388+
* reconciliation will see to updated resource - or more recent one if additional update happened
389+
* after this update; In addition to that it filters out the event from this update, so
390+
* reconciliation is not triggered by own update.
391+
*
392+
* <p>You are free to control the optimistic locking by setting the resource version in resource
393+
* metadata.
394+
*
296395
* @param resource primary resource to patch reconciliation
297396
* @return updated resource
298397
* @param <R> resource type
@@ -305,9 +404,15 @@ public <R extends HasMetadata> R jsonMergePatchPrimary(R resource) {
305404
}
306405

307406
/**
308-
* Applies a JSON Merge Patch to the primary resource status subresource and filters out the
309-
* resulting event. This is a convenience method that calls {@link
310-
* #jsonMergePatchPrimaryStatus(HasMetadata)} with filterEvent set to true.
407+
* Applies a JSON Merge Patch to the primary resource.
408+
*
409+
* <p>Updates the resource and caches the response if needed, thus making sure that next
410+
* reconciliation will see to updated resource - or more recent one if additional update happened
411+
* after this update; In addition to that it filters out the event from this update, so
412+
* reconciliation is not triggered by own update.
413+
*
414+
* <p>You are free to control the optimistic locking by setting the resource version in resource
415+
* metadata.
311416
*
312417
* @param resource primary resource to patch
313418
* @return updated resource
@@ -322,9 +427,9 @@ public <R extends HasMetadata> R jsonMergePatchPrimaryStatus(R resource) {
322427
}
323428

324429
/**
325-
* Internal utility method to patch a resource and cache the result. Automatically discovers the
326-
* event source for the resource type and delegates to {@link #resourcePatch(HasMetadata,
327-
* UnaryOperator, ManagedInformerEventSource)}.
430+
* Utility method to patch a resource and cache the result. Automatically discovers the event
431+
* source for the resource type and delegates to {@link #resourcePatch(HasMetadata, UnaryOperator,
432+
* ManagedInformerEventSource)}.
328433
*
329434
* @param context of reconciler
330435
* @param resource resource to patch
@@ -357,9 +462,9 @@ public <R extends HasMetadata> R resourcePatch(
357462
}
358463

359464
/**
360-
* Internal utility method to patch a resource and cache the result using the specified event
361-
* source. This method either filters out the resulting event or allows it to trigger
362-
* reconciliation based on the filterEvent parameter.
465+
* Utility method to patch a resource and cache the result using the specified event source. This
466+
* method either filters out the resulting event or allows it to trigger reconciliation based on
467+
* the filterEvent parameter.
363468
*
364469
* @param resource resource to patch
365470
* @param updateOperation operation to perform (update, patch, edit, etc.)

0 commit comments

Comments
 (0)