From f1db10ced0d307aac8840971e457e36bc9575d08 Mon Sep 17 00:00:00 2001 From: csviri Date: Tue, 7 Feb 2023 14:54:51 +0100 Subject: [PATCH 1/7] feat: UpdateControl and ErrorStatusUpdateControl refinement --- .../api/reconciler/UpdateControl.java | 34 ++++++++++------ .../event/PostExecutionControl.java | 18 +++++---- .../event/ReconciliationDispatcher.java | 39 ++++++++++++------- 3 files changed, 58 insertions(+), 33 deletions(-) diff --git a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/UpdateControl.java b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/UpdateControl.java index 12f392901d..dccc2b0167 100644 --- a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/UpdateControl.java +++ b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/UpdateControl.java @@ -8,17 +8,20 @@ public class UpdateControl

extends BaseControl UpdateControl updateResource(T customResource) { - return new UpdateControl<>(customResource, false, true, false); + return new UpdateControl<>(customResource, false, true, false, false); } /** @@ -50,7 +53,7 @@ public static UpdateControl updateResource(T customRe * @return UpdateControl instance */ public static UpdateControl patchStatus(T customResource) { - return new UpdateControl<>(customResource, true, false, true); + return new UpdateControl<>(customResource, true, false, true, false); } /** @@ -66,7 +69,7 @@ public static UpdateControl patchStatus(T customResou * @return UpdateControl instance */ public static UpdateControl updateStatus(T customResource) { - return new UpdateControl<>(customResource, true, false, false); + return new UpdateControl<>(customResource, true, false, false, false); } /** @@ -79,17 +82,22 @@ public static UpdateControl updateStatus(T customReso */ public static UpdateControl updateResourceAndStatus( T customResource) { - return new UpdateControl<>(customResource, true, true, false); + return new UpdateControl<>(customResource, true, true, false, false); + } + + public static UpdateControl updateResourceAndPatchStatus( + T customResource) { + return new UpdateControl<>(customResource, true, true, true, false); } public static UpdateControl patchResourceAndStatus( T customResource) { - return new UpdateControl<>(customResource, true, true, true); + return new UpdateControl<>(customResource, true, true, true, false); } public static UpdateControl noUpdate() { - return new UpdateControl<>(null, false, false, false); + return new UpdateControl<>(null, false, false, false, false); } public P getResource() { @@ -104,8 +112,12 @@ public boolean isUpdateResource() { return updateResource; } - public boolean isPatch() { - return patch; + public boolean isPatchStatus() { + return patchStatus; + } + + public boolean isPatchResource() { + return patchResource; } public boolean isNoUpdate() { diff --git a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/PostExecutionControl.java b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/PostExecutionControl.java index 6fddd5ad93..e357bf66bb 100644 --- a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/PostExecutionControl.java +++ b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/PostExecutionControl.java @@ -9,6 +9,7 @@ final class PostExecutionControl { private final boolean finalizerRemoved; private final R updatedCustomResource; private final boolean updateIsStatusPatch; + private final boolean updateIsResourcePatch; private final Exception runtimeException; private Long reScheduleDelay = null; @@ -16,40 +17,41 @@ final class PostExecutionControl { private PostExecutionControl( boolean finalizerRemoved, R updatedCustomResource, - boolean updateIsStatusPatch, Exception runtimeException) { + boolean updateIsStatusPatch, boolean updateIsResourcePatch, Exception runtimeException) { this.finalizerRemoved = finalizerRemoved; this.updatedCustomResource = updatedCustomResource; this.updateIsStatusPatch = updateIsStatusPatch; + this.updateIsResourcePatch = updateIsResourcePatch; this.runtimeException = runtimeException; } public static PostExecutionControl onlyFinalizerAdded( R updatedCustomResource) { - return new PostExecutionControl<>(false, updatedCustomResource, false, null); + return new PostExecutionControl<>(false, updatedCustomResource, false, false, null); } public static PostExecutionControl defaultDispatch() { - return new PostExecutionControl<>(false, null, false, null); + return new PostExecutionControl<>(false, null, false, false, null); } public static PostExecutionControl customResourceStatusPatched( R updatedCustomResource) { - return new PostExecutionControl<>(false, updatedCustomResource, true, null); + return new PostExecutionControl<>(false, updatedCustomResource, true, false, null); } public static PostExecutionControl customResourceUpdated( - R updatedCustomResource) { - return new PostExecutionControl<>(false, updatedCustomResource, false, null); + R updatedCustomResource, boolean patched) { + return new PostExecutionControl<>(false, updatedCustomResource, false, patched, null); } public static PostExecutionControl customResourceFinalizerRemoved( R updatedCustomResource) { - return new PostExecutionControl<>(true, updatedCustomResource, false, null); + return new PostExecutionControl<>(true, updatedCustomResource, false, false, null); } public static PostExecutionControl exceptionDuringExecution( Exception exception) { - return new PostExecutionControl<>(false, null, false, exception); + return new PostExecutionControl<>(false, null, false, false, exception); } public Optional getUpdatedCustomResource() { diff --git a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/ReconciliationDispatcher.java b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/ReconciliationDispatcher.java index 3018ed30f1..d2220904ab 100644 --- a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/ReconciliationDispatcher.java +++ b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/ReconciliationDispatcher.java @@ -84,7 +84,7 @@ private PostExecutionControl

handleDispatch(ExecutionScope

executionScope) Context

context = new DefaultContext<>(executionScope.getRetryInfo(), controller, originalResource); if (markedForDeletion) { - return handleCleanup(originalResource, resourceForExecution, context); + return handleCleanup(resourceForExecution, context); } else { return handleReconcile(executionScope, resourceForExecution, originalResource, context); } @@ -140,30 +140,31 @@ private PostExecutionControl

reconcileExecution(ExecutionScope

executionSc P updatedCustomResource = null; if (updateControl.isUpdateResourceAndStatus()) { updatedCustomResource = - updateCustomResource(updateControl.getResource()); + updateCustomResource(updateControl.getResource(), updateControl.isPatchResource()); updateControl .getResource() .getMetadata() .setResourceVersion(updatedCustomResource.getMetadata().getResourceVersion()); updatedCustomResource = updateStatusGenerationAware(updateControl.getResource(), originalResource, - updateControl.isPatch()); + updateControl.isPatchStatus()); } else if (updateControl.isUpdateStatus()) { updatedCustomResource = updateStatusGenerationAware(updateControl.getResource(), originalResource, - updateControl.isPatch()); + updateControl.isPatchStatus()); } else if (updateControl.isUpdateResource()) { updatedCustomResource = - updateCustomResource(updateControl.getResource()); + updateCustomResource(updateControl.getResource(), updateControl.isPatchResource()); if (shouldUpdateObservedGenerationAutomatically(updatedCustomResource)) { updatedCustomResource = updateStatusGenerationAware(updateControl.getResource(), originalResource, - updateControl.isPatch()); + updateControl.isPatchStatus()); } } else if (updateControl.isNoUpdate() && shouldUpdateObservedGenerationAutomatically(resourceForExecution)) { updatedCustomResource = - updateStatusGenerationAware(originalResource, originalResource, updateControl.isPatch()); + updateStatusGenerationAware(originalResource, originalResource, + updateControl.isPatchStatus()); } return createPostExecutionControl(updatedCustomResource, updateControl); } @@ -202,7 +203,8 @@ public boolean isLastAttempt() { if (updatedResource != null) { return errorStatusUpdateControl.isPatch() ? PostExecutionControl.customResourceStatusPatched(updatedResource) - : PostExecutionControl.customResourceUpdated(updatedResource); + // todo review if this is ok + : PostExecutionControl.customResourceUpdated(updatedResource, false); } else { return PostExecutionControl.defaultDispatch(); } @@ -259,11 +261,12 @@ private PostExecutionControl

createPostExecutionControl(P updatedCustomResour UpdateControl

updateControl) { PostExecutionControl

postExecutionControl; if (updatedCustomResource != null) { - if (updateControl.isUpdateStatus() && updateControl.isPatch()) { + if (updateControl.isUpdateStatus() && updateControl.isPatchStatus()) { postExecutionControl = PostExecutionControl.customResourceStatusPatched(updatedCustomResource); } else { - postExecutionControl = PostExecutionControl.customResourceUpdated(updatedCustomResource); + postExecutionControl = PostExecutionControl.customResourceUpdated(updatedCustomResource, + updateControl.isPatchResource()); } } else { postExecutionControl = PostExecutionControl.defaultDispatch(); @@ -279,7 +282,7 @@ private void updatePostExecutionControlWithReschedule( } - private PostExecutionControl

handleCleanup(P originalResource, P resource, + private PostExecutionControl

handleCleanup(P resource, Context

context) { log.debug( "Executing delete for resource: {} with version: {}", @@ -316,10 +319,13 @@ private P updateCustomResourceWithFinalizer(P resourceForExecution, P originalRe r -> r.addFinalizer(configuration().getFinalizerName())); } - private P updateCustomResource(P resource) { - log.debug("Updating resource: {} with version: {}", getUID(resource), getVersion(resource)); + private P updateCustomResource(P resource, boolean isPatch) { + log.debug("Updating resource: {} with version: {} patch: {}", getUID(resource), + getVersion(resource), isPatch); log.trace("Resource before update: {}", resource); - return customResourceFacade.updateResource(resource); + + return isPatch ? customResourceFacade.patchResource(resource) + : customResourceFacade.updateResource(resource); } ControllerConfiguration

configuration() { @@ -375,6 +381,11 @@ public R getResource(String namespace, String name) { } } + public R patchResource(R resource) { + // todo + return null; + } + public R updateResource(R resource) { log.debug( "Trying to replace resource {}, version: {}", From f51b3961ebc9171641786870f9340c5bbb355a09 Mon Sep 17 00:00:00 2001 From: csviri Date: Wed, 8 Feb 2023 14:15:08 +0100 Subject: [PATCH 2/7] fix: deprecating UpdateControl method with confusing name --- .../api/reconciler/UpdateControl.java | 48 ++++++++++++------- .../event/PostExecutionControl.java | 18 ++++--- .../event/ReconciliationDispatcher.java | 24 ++++------ 3 files changed, 46 insertions(+), 44 deletions(-) diff --git a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/UpdateControl.java b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/UpdateControl.java index dccc2b0167..132def605b 100644 --- a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/UpdateControl.java +++ b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/UpdateControl.java @@ -9,11 +9,9 @@ public class UpdateControl

extends BaseControl custom resource type * @param customResource customResource to use for update * @return initialized update control */ public static UpdateControl updateResource(T customResource) { - return new UpdateControl<>(customResource, false, true, false, false); + return new UpdateControl<>(customResource, false, true, false); } /** @@ -53,7 +53,7 @@ public static UpdateControl updateResource(T customRe * @return UpdateControl instance */ public static UpdateControl patchStatus(T customResource) { - return new UpdateControl<>(customResource, true, false, true, false); + return new UpdateControl<>(customResource, true, false, true); } /** @@ -69,7 +69,7 @@ public static UpdateControl patchStatus(T customResou * @return UpdateControl instance */ public static UpdateControl updateStatus(T customResource) { - return new UpdateControl<>(customResource, true, false, false, false); + return new UpdateControl<>(customResource, true, false, false); } /** @@ -82,22 +82,37 @@ public static UpdateControl updateStatus(T customReso */ public static UpdateControl updateResourceAndStatus( T customResource) { - return new UpdateControl<>(customResource, true, true, false, false); + return new UpdateControl<>(customResource, true, true, false); } + /** + * Updates the resource - with optimistic locking - and patched the status without optimistic + * locking in place. + * + * @param customResource + * @return + * @param + */ public static UpdateControl updateResourceAndPatchStatus( T customResource) { - return new UpdateControl<>(customResource, true, true, true, false); + return new UpdateControl<>(customResource, true, true, true); } - public static UpdateControl patchResourceAndStatus( - T customResource) { - return new UpdateControl<>(customResource, true, true, true, false); + /** + * Market for removal, because of confusing name. It does not patch the resource just updates it. + * This method is same as updateResourceAndPatchStatus. + * + * @param customResource to update + * @return UpdateControl instance + * @param resource type + */ + @Deprecated(forRemoval = true) + public static UpdateControl patchResourceAndStatus(T customResource) { + return updateResourceAndStatus(customResource); } - public static UpdateControl noUpdate() { - return new UpdateControl<>(null, false, false, false, false); + return new UpdateControl<>(null, false, false, false); } public P getResource() { @@ -116,10 +131,6 @@ public boolean isPatchStatus() { return patchStatus; } - public boolean isPatchResource() { - return patchResource; - } - public boolean isNoUpdate() { return !updateResource && !updateStatus; } @@ -127,4 +138,5 @@ public boolean isNoUpdate() { public boolean isUpdateResourceAndStatus() { return updateResource && updateStatus; } + } diff --git a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/PostExecutionControl.java b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/PostExecutionControl.java index e357bf66bb..6fddd5ad93 100644 --- a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/PostExecutionControl.java +++ b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/PostExecutionControl.java @@ -9,7 +9,6 @@ final class PostExecutionControl { private final boolean finalizerRemoved; private final R updatedCustomResource; private final boolean updateIsStatusPatch; - private final boolean updateIsResourcePatch; private final Exception runtimeException; private Long reScheduleDelay = null; @@ -17,41 +16,40 @@ final class PostExecutionControl { private PostExecutionControl( boolean finalizerRemoved, R updatedCustomResource, - boolean updateIsStatusPatch, boolean updateIsResourcePatch, Exception runtimeException) { + boolean updateIsStatusPatch, Exception runtimeException) { this.finalizerRemoved = finalizerRemoved; this.updatedCustomResource = updatedCustomResource; this.updateIsStatusPatch = updateIsStatusPatch; - this.updateIsResourcePatch = updateIsResourcePatch; this.runtimeException = runtimeException; } public static PostExecutionControl onlyFinalizerAdded( R updatedCustomResource) { - return new PostExecutionControl<>(false, updatedCustomResource, false, false, null); + return new PostExecutionControl<>(false, updatedCustomResource, false, null); } public static PostExecutionControl defaultDispatch() { - return new PostExecutionControl<>(false, null, false, false, null); + return new PostExecutionControl<>(false, null, false, null); } public static PostExecutionControl customResourceStatusPatched( R updatedCustomResource) { - return new PostExecutionControl<>(false, updatedCustomResource, true, false, null); + return new PostExecutionControl<>(false, updatedCustomResource, true, null); } public static PostExecutionControl customResourceUpdated( - R updatedCustomResource, boolean patched) { - return new PostExecutionControl<>(false, updatedCustomResource, false, patched, null); + R updatedCustomResource) { + return new PostExecutionControl<>(false, updatedCustomResource, false, null); } public static PostExecutionControl customResourceFinalizerRemoved( R updatedCustomResource) { - return new PostExecutionControl<>(true, updatedCustomResource, false, false, null); + return new PostExecutionControl<>(true, updatedCustomResource, false, null); } public static PostExecutionControl exceptionDuringExecution( Exception exception) { - return new PostExecutionControl<>(false, null, false, false, exception); + return new PostExecutionControl<>(false, null, false, exception); } public Optional getUpdatedCustomResource() { diff --git a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/ReconciliationDispatcher.java b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/ReconciliationDispatcher.java index d2220904ab..6c7e7bc9e7 100644 --- a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/ReconciliationDispatcher.java +++ b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/ReconciliationDispatcher.java @@ -140,7 +140,7 @@ private PostExecutionControl

reconcileExecution(ExecutionScope

executionSc P updatedCustomResource = null; if (updateControl.isUpdateResourceAndStatus()) { updatedCustomResource = - updateCustomResource(updateControl.getResource(), updateControl.isPatchResource()); + updateCustomResource(updateControl.getResource()); updateControl .getResource() .getMetadata() @@ -154,7 +154,7 @@ private PostExecutionControl

reconcileExecution(ExecutionScope

executionSc updateControl.isPatchStatus()); } else if (updateControl.isUpdateResource()) { updatedCustomResource = - updateCustomResource(updateControl.getResource(), updateControl.isPatchResource()); + updateCustomResource(updateControl.getResource()); if (shouldUpdateObservedGenerationAutomatically(updatedCustomResource)) { updatedCustomResource = updateStatusGenerationAware(updateControl.getResource(), originalResource, @@ -203,8 +203,7 @@ public boolean isLastAttempt() { if (updatedResource != null) { return errorStatusUpdateControl.isPatch() ? PostExecutionControl.customResourceStatusPatched(updatedResource) - // todo review if this is ok - : PostExecutionControl.customResourceUpdated(updatedResource, false); + : PostExecutionControl.customResourceUpdated(updatedResource); } else { return PostExecutionControl.defaultDispatch(); } @@ -265,8 +264,7 @@ private PostExecutionControl

createPostExecutionControl(P updatedCustomResour postExecutionControl = PostExecutionControl.customResourceStatusPatched(updatedCustomResource); } else { - postExecutionControl = PostExecutionControl.customResourceUpdated(updatedCustomResource, - updateControl.isPatchResource()); + postExecutionControl = PostExecutionControl.customResourceUpdated(updatedCustomResource); } } else { postExecutionControl = PostExecutionControl.defaultDispatch(); @@ -319,13 +317,12 @@ private P updateCustomResourceWithFinalizer(P resourceForExecution, P originalRe r -> r.addFinalizer(configuration().getFinalizerName())); } - private P updateCustomResource(P resource, boolean isPatch) { - log.debug("Updating resource: {} with version: {} patch: {}", getUID(resource), - getVersion(resource), isPatch); + private P updateCustomResource(P resource) { + log.debug("Updating resource: {} with version: {}", getUID(resource), + getVersion(resource)); log.trace("Resource before update: {}", resource); - return isPatch ? customResourceFacade.patchResource(resource) - : customResourceFacade.updateResource(resource); + return customResourceFacade.updateResource(resource); } ControllerConfiguration

configuration() { @@ -381,11 +378,6 @@ public R getResource(String namespace, String name) { } } - public R patchResource(R resource) { - // todo - return null; - } - public R updateResource(R resource) { log.debug( "Trying to replace resource {}, version: {}", From e7e742a8d1cbaf043995d6e59506565c7c74bc69 Mon Sep 17 00:00:00 2001 From: Chris Laprun Date: Wed, 8 Feb 2023 14:28:59 +0100 Subject: [PATCH 3/7] fix: typos --- .../operator/api/reconciler/UpdateControl.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/UpdateControl.java b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/UpdateControl.java index 132def605b..fd7ddba8bc 100644 --- a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/UpdateControl.java +++ b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/UpdateControl.java @@ -26,7 +26,7 @@ private UpdateControl( * itself, not on the status. Note that usually as a results of a reconciliation should be a * status update not an update to the resource itself. * - * Using this update makes sure, that the resource in the next reconciliation is the updated one - + * Using this update makes sure that the resource in the next reconciliation is the updated one - * this is not guaranteed by default if you do an update on a resource by the Kubernetes client. * * @param custom resource type @@ -86,7 +86,7 @@ public static UpdateControl updateResourceAndStatus( } /** - * Updates the resource - with optimistic locking - and patched the status without optimistic + * Updates the resource - with optimistic locking - and patches the status without optimistic * locking in place. * * @param customResource @@ -99,7 +99,7 @@ public static UpdateControl updateResourceAndPatchSta } /** - * Market for removal, because of confusing name. It does not patch the resource just updates it. + * Marked for removal, because of confusing name. It does not patch the resource but rather updates it. * This method is same as updateResourceAndPatchStatus. * * @param customResource to update From e5d8409eb3f19b8df1c7a4415bd8753e86b98765 Mon Sep 17 00:00:00 2001 From: csviri Date: Wed, 8 Feb 2023 14:43:30 +0100 Subject: [PATCH 4/7] fix formatting --- .../operator/api/reconciler/UpdateControl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/UpdateControl.java b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/UpdateControl.java index fd7ddba8bc..38ef740b78 100644 --- a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/UpdateControl.java +++ b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/UpdateControl.java @@ -99,8 +99,8 @@ public static UpdateControl updateResourceAndPatchSta } /** - * Marked for removal, because of confusing name. It does not patch the resource but rather updates it. - * This method is same as updateResourceAndPatchStatus. + * Marked for removal, because of confusing name. It does not patch the resource but rather + * updates it. This method is same as updateResourceAndPatchStatus. * * @param customResource to update * @return UpdateControl instance From 0142b4dbef7ef0e988e1b425b10140a3c8f11945 Mon Sep 17 00:00:00 2001 From: csviri Date: Wed, 8 Feb 2023 14:46:31 +0100 Subject: [PATCH 5/7] fixes --- .../operator/api/reconciler/UpdateControl.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/UpdateControl.java b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/UpdateControl.java index 38ef740b78..c8535c61b9 100644 --- a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/UpdateControl.java +++ b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/UpdateControl.java @@ -100,7 +100,9 @@ public static UpdateControl updateResourceAndPatchSta /** * Marked for removal, because of confusing name. It does not patch the resource but rather - * updates it. This method is same as updateResourceAndPatchStatus. + * updates it. + * + * @deprecated use {@link UpdateControl#updateResourceAndPatchStatus(HasMetadata)} * * @param customResource to update * @return UpdateControl instance From dda3a10b63cbe083f1a14af1e8d896e915eff5f7 Mon Sep 17 00:00:00 2001 From: csviri Date: Wed, 8 Feb 2023 14:47:59 +0100 Subject: [PATCH 6/7] javadoc fix --- .../operator/api/reconciler/UpdateControl.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/UpdateControl.java b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/UpdateControl.java index c8535c61b9..87e0b0ce2d 100644 --- a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/UpdateControl.java +++ b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/UpdateControl.java @@ -89,9 +89,9 @@ public static UpdateControl updateResourceAndStatus( * Updates the resource - with optimistic locking - and patches the status without optimistic * locking in place. * - * @param customResource - * @return - * @param + * @param customResource to update + * @return UpdateControl instance + * @param resource type */ public static UpdateControl updateResourceAndPatchStatus( T customResource) { From d10a8b66a231097183fac77cf6158b60cf640347 Mon Sep 17 00:00:00 2001 From: csviri Date: Wed, 8 Feb 2023 15:05:32 +0100 Subject: [PATCH 7/7] javadoc --- .../operator/api/reconciler/UpdateControl.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/UpdateControl.java b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/UpdateControl.java index 87e0b0ce2d..7eb7d2ae84 100644 --- a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/UpdateControl.java +++ b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/UpdateControl.java @@ -76,6 +76,9 @@ public static UpdateControl updateStatus(T customReso * As a results of this there will be two call to K8S API. First the custom resource will be * updates then the status sub-resource. * + * Using this update makes sure that the resource in the next reconciliation is the updated one - + * this is not guaranteed by default if you do an update on a resource by the Kubernetes client. + * * @param resource type * @param customResource - custom resource to use in both API calls * @return UpdateControl instance @@ -89,6 +92,9 @@ public static UpdateControl updateResourceAndStatus( * Updates the resource - with optimistic locking - and patches the status without optimistic * locking in place. * + * Note that using this method, it is not guaranteed that the most recent updated resource will be + * in case for next reconciliation. + * * @param customResource to update * @return UpdateControl instance * @param resource type