@@ -237,13 +237,26 @@ private static <P extends HasMetadata> P pollLocalCache(
237237 }
238238 }
239239
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+ */
241248 @ SuppressWarnings ("unchecked" )
242249 public static <P extends HasMetadata > P addFinalizer (Context <P > context , String finalizer ) {
243250 return addFinalizer (context .getClient (), context .getPrimaryResource (), finalizer );
244251 }
245252
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+ */
247260 @ SuppressWarnings ("unchecked" )
248261 public static <P extends HasMetadata > P addFinalizer (
249262 KubernetesClient client , P resource , String finalizerName ) {
@@ -257,6 +270,14 @@ public static <P extends HasMetadata> P addFinalizer(
257270 r -> !r .hasFinalizer (finalizerName ));
258271 }
259272
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+ */
260281 public static <P extends HasMetadata > P removeFinalizer (
261282 Context <P > context , String finalizerName ) {
262283 return removeFinalizer (context .getClient (), context .getPrimaryResource (), finalizerName );
@@ -275,12 +296,16 @@ public static <P extends HasMetadata> P removeFinalizer(
275296 }
276297
277298 /**
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+ *
278303 * @param client KubernetesClient
279304 * @param resource to update
280305 * @param resourceChangesOperator changes to be done on the resource before update
281306 * @param preCondition condition to check if the patch operation still needs to be performed or
282307 * 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.
284309 * @param <P> resource type
285310 */
286311 @ SuppressWarnings ("unchecked" )
@@ -338,7 +363,13 @@ public static <P extends HasMetadata> P conflictRetryingPatch(
338363 }
339364 }
340365
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+ */
342373 public static <P extends HasMetadata > P addFinalizerWithSSA (
343374 Context <P > context , P originalResource , String finalizerName ) {
344375 return addFinalizerWithSSA (
@@ -348,7 +379,13 @@ public static <P extends HasMetadata> P addFinalizerWithSSA(
348379 context .getControllerConfiguration ().fieldManager ());
349380 }
350381
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+ */
352389 @ SuppressWarnings ("unchecked" )
353390 public static <P extends HasMetadata > P addFinalizerWithSSA (
354391 KubernetesClient client , P originalResource , String finalizerName , String fieldManager ) {
0 commit comments