@@ -237,13 +237,26 @@ private static <P extends HasMetadata> P pollLocalCache(
237
237
}
238
238
}
239
239
240
- /** Adds finalizer using JSON Patch. Retries conflicts and unprocessable content (HTTP 422) */
240
+ /**
241
+ * Adds finalizer to the primary resource from the context using JSON Patch. Retries conflicts and
242
+ * unprocessable content (HTTP 422), see {@link
243
+ * PrimaryUpdateAndCacheUtils#conflictRetryingPatch(KubernetesClient, HasMetadata, UnaryOperator,
244
+ * Predicate)} for details on retry.
245
+ *
246
+ * @return updated resource from the server response
247
+ */
241
248
@ SuppressWarnings ("unchecked" )
242
249
public static <P extends HasMetadata > P addFinalizer (Context <P > context , String finalizer ) {
243
250
return addFinalizer (context .getClient (), context .getPrimaryResource (), finalizer );
244
251
}
245
252
246
- /** Adds finalizer using JSON Patch. Retries conflicts and unprocessable content (HTTP 422) */
253
+ /**
254
+ * Adds finalizer to the resource using JSON Patch. Retries conflicts and unprocessable content
255
+ * (HTTP 422), see {@link PrimaryUpdateAndCacheUtils#conflictRetryingPatch(KubernetesClient,
256
+ * HasMetadata, UnaryOperator, Predicate)} for details on retry.
257
+ *
258
+ * @return updated resource from the server response
259
+ */
247
260
@ SuppressWarnings ("unchecked" )
248
261
public static <P extends HasMetadata > P addFinalizer (
249
262
KubernetesClient client , P resource , String finalizerName ) {
@@ -257,6 +270,14 @@ public static <P extends HasMetadata> P addFinalizer(
257
270
r -> !r .hasFinalizer (finalizerName ));
258
271
}
259
272
273
+ /**
274
+ * Removes the target finalizer from the primary resource from the Context. Uses JSON Patch and
275
+ * reties the operation if failed, see {@link
276
+ * PrimaryUpdateAndCacheUtils#conflictRetryingPatch(KubernetesClient, HasMetadata, UnaryOperator,
277
+ * Predicate)} for details.
278
+ *
279
+ * @return updated resource from the response from the server
280
+ */
260
281
public static <P extends HasMetadata > P removeFinalizer (
261
282
Context <P > context , String finalizerName ) {
262
283
return removeFinalizer (context .getClient (), context .getPrimaryResource (), finalizerName );
@@ -275,12 +296,16 @@ public static <P extends HasMetadata> P removeFinalizer(
275
296
}
276
297
277
298
/**
299
+ * Parches the resource using JSON Patch. In case the server responds with conflict (HTTP 409) or
300
+ * unprocessable content (HTTP 422) it retries the operation up to the maximum number defined in
301
+ * {@link PrimaryUpdateAndCacheUtils#DEFAULT_MAX_RETRY}.
302
+ *
278
303
* @param client KubernetesClient
279
304
* @param resource to update
280
305
* @param resourceChangesOperator changes to be done on the resource before update
281
306
* @param preCondition condition to check if the patch operation still needs to be performed or
282
307
* not.
283
- * @return updated resource or unchanged if the precondition does not hold.
308
+ * @return updated resource from the server or unchanged if the precondition does not hold.
284
309
* @param <P> resource type
285
310
*/
286
311
@ SuppressWarnings ("unchecked" )
@@ -338,7 +363,13 @@ public static <P extends HasMetadata> P conflictRetryingPatch(
338
363
}
339
364
}
340
365
341
- /** Adds finalizer using Server-Side Apply. */
366
+ /**
367
+ * Adds finalizer using Server-Side Apply. In the background this method creates a fresh copy of
368
+ * the target resource, setting only name, namespace and finalizer. Does not use optimistic
369
+ * locking for the patch.
370
+ *
371
+ * @return the patched resource from the server response
372
+ */
342
373
public static <P extends HasMetadata > P addFinalizerWithSSA (
343
374
Context <P > context , P originalResource , String finalizerName ) {
344
375
return addFinalizerWithSSA (
@@ -348,7 +379,13 @@ public static <P extends HasMetadata> P addFinalizerWithSSA(
348
379
context .getControllerConfiguration ().fieldManager ());
349
380
}
350
381
351
- /** Adds finalizer using Server-Side Apply. */
382
+ /**
383
+ * Adds finalizer using Server-Side Apply. In the background this method creates a fresh copy of
384
+ * the target resource, setting only name, namespace and finalizer. Does not use optimistic
385
+ * locking for the patch.
386
+ *
387
+ * @return the patched resource from the server response
388
+ */
352
389
@ SuppressWarnings ("unchecked" )
353
390
public static <P extends HasMetadata > P addFinalizerWithSSA (
354
391
KubernetesClient client , P originalResource , String finalizerName , String fieldManager ) {
0 commit comments