diff --git a/docs/documentation/v5-0-migration.md b/docs/documentation/v5-0-migration.md index b34a7a6b21..c08312d01c 100644 --- a/docs/documentation/v5-0-migration.md +++ b/docs/documentation/v5-0-migration.md @@ -26,3 +26,5 @@ permalink: /docs/v5-0-migration Also, the related part of a [workaround](https://github.com/operator-framework/java-operator-sdk/blob/main/operator-framework/src/test/java/io/javaoperatorsdk/operator/StatusPatchSSAMigrationIT.java#L110-L116). 4. `ManagedDependentResourceContext` has been renamed to `ManagedWorkflowAndDependentResourceContext` and is accessed via the accordingly renamed `managedWorkflowAndDependentResourceContext` method. +5. Reconcile pre-condition is renamed simply to `Condition` in ( @Dependent annotation, and related builders) + just rename related attributes diff --git a/docs/documentation/workflows.md b/docs/documentation/workflows.md index ea83016430..d5ff4a4514 100644 --- a/docs/documentation/workflows.md +++ b/docs/documentation/workflows.md @@ -28,7 +28,7 @@ reconciliation process. - **Dependent resource** (DR) - are the resources being managed in a given reconciliation logic. - **Depends-on relation** - a `B` DR depends on another `A` DR if `B` needs to be reconciled after `A`. -- **Reconcile precondition** - is a condition on a given DR that needs to be become true before the +- **Condition** - is a condition on a given DR that needs to be become true before the DR is reconciled. This also allows to define optional resources that would, for example, only be created if a flag in a custom resource `.spec` has some specific value. - **Ready postcondition** - is a condition on a given DR to prevent the workflow from @@ -76,7 +76,7 @@ will only consider the `ConfigMap` deleted until that post-condition becomes `tr @Dependent(name = DEPLOYMENT_NAME, type = DeploymentDependentResource.class, readyPostcondition = DeploymentReadyCondition.class), @Dependent(type = ConfigMapDependentResource.class, - reconcilePrecondition = ConfigMapReconcileCondition.class, + condition = ConfigMapCondition.class, deletePostcondition = ConfigMapDeletePostCondition.class, activationCondition = ConfigMapActivationCondition.class, dependsOn = DEPLOYMENT_NAME) @@ -252,7 +252,7 @@ stateDiagram-v2 - If `2`'s reconciliation resulted in an error, `4` would not be reconciled, but `3` would be (and `1` as well, of course). -#### Sample with Reconcile Precondition +#### Sample with Condition <div class="mermaid" markdown="0"> diff --git a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/BaseConfigurationService.java b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/BaseConfigurationService.java index af9930d00c..242282787f 100644 --- a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/BaseConfigurationService.java +++ b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/BaseConfigurationService.java @@ -215,7 +215,7 @@ private static List<DependentResourceSpec> dependentResources( spec = new DependentResourceSpec(dependentType, dependentName, Set.of(dependent.dependsOn()), Utils.instantiate(dependent.readyPostcondition(), Condition.class, context), - Utils.instantiate(dependent.reconcilePrecondition(), Condition.class, context), + Utils.instantiate(dependent.condition(), Condition.class, context), Utils.instantiate(dependent.deletePostcondition(), Condition.class, context), Utils.instantiate(dependent.activationCondition(), Condition.class, context), eventSourceName); diff --git a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/dependent/DependentResourceSpec.java b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/dependent/DependentResourceSpec.java index 1fcd0709fb..9ae5d4240f 100644 --- a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/dependent/DependentResourceSpec.java +++ b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/dependent/DependentResourceSpec.java @@ -18,7 +18,7 @@ public class DependentResourceSpec<R, P extends HasMetadata> { private final Condition<?, ?> readyCondition; - private final Condition<?, ?> reconcileCondition; + private final Condition<?, ?> condition; private final Condition<?, ?> deletePostCondition; @@ -28,13 +28,13 @@ public class DependentResourceSpec<R, P extends HasMetadata> { public DependentResourceSpec(Class<? extends DependentResource<R, P>> dependentResourceClass, String name, Set<String> dependsOn, Condition<?, ?> readyCondition, - Condition<?, ?> reconcileCondition, Condition<?, ?> deletePostCondition, + Condition<?, ?> condition, Condition<?, ?> deletePostCondition, Condition<?, ?> activationCondition, String useEventSourceWithName) { this.dependentResourceClass = dependentResourceClass; this.name = name; this.dependsOn = dependsOn; this.readyCondition = readyCondition; - this.reconcileCondition = reconcileCondition; + this.condition = condition; this.deletePostCondition = deletePostCondition; this.activationCondition = activationCondition; this.useEventSourceWithName = useEventSourceWithName; @@ -81,8 +81,8 @@ public Condition getReadyCondition() { } @SuppressWarnings("rawtypes") - public Condition getReconcileCondition() { - return reconcileCondition; + public Condition getCondition() { + return condition; } @SuppressWarnings("rawtypes") diff --git a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/dependent/Dependent.java b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/dependent/Dependent.java index 754e2c85be..892b0ee4e7 100644 --- a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/dependent/Dependent.java +++ b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/dependent/Dependent.java @@ -33,12 +33,12 @@ /** * The condition (if it exists) that needs to become true before the associated * {@link DependentResource} is reconciled. Note that if this condition is set and the condition - * doesn't hold true, the associated secondary will be deleted. + * doesn't hold true, the associated secondary will be deleted (if exists). * * @return a {@link Condition} implementation, defaulting to the interface itself if no value is * set */ - Class<? extends Condition> reconcilePrecondition() default Condition.class; + Class<? extends Condition> condition() default Condition.class; /** * The condition (if it exists) that needs to become true before further reconciliation of @@ -54,12 +54,11 @@ * <p> * A condition that needs to become true for the dependent to even be considered as part of the * workflow. This is useful for dependents that represent optional resources on the cluster and - * might not be present. In this case, a reconcile pre-condition is not enough because in that - * situation, the associated informer will still be registered. With this activation condition, - * the associated event source will only be registered if the condition is met. Otherwise, this - * behaves like a reconcile pre-condition in the sense that dependents, that depend on this one, - * will only get created if the condition is met and will get deleted if the condition becomes - * false. + * might not be present. In this case, a condition is not enough because in that situation, the + * associated informer will still be registered. With this activation condition, the associated + * event source will only be registered if the condition is met. Otherwise, this behaves like a + * reconcile pre-condition in the sense that dependents, that depend on this one, will only get + * created if the condition is met and will get deleted if the condition becomes false. * </p> * <p> * As other conditions, this gets evaluated at the beginning of every reconciliation, which means diff --git a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/dependent/GarbageCollected.java b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/dependent/GarbageCollected.java index 91afbf5e5c..e3e711d3cb 100644 --- a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/dependent/GarbageCollected.java +++ b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/dependent/GarbageCollected.java @@ -9,10 +9,10 @@ * {@link io.javaoperatorsdk.operator.processing.dependent.kubernetes.KubernetesDependentResource} * to express that the resource deletion is handled by the controller during * {@link DependentResource#reconcile(HasMetadata, Context)}. This takes effect during a - * reconciliation workflow, but not during a cleanup workflow, when a {@code reconcilePrecondition} - * is not met for the resource. In this case, {@link #delete(HasMetadata, Context)} is called. - * During a cleanup workflow, however, {@link #delete(HasMetadata, Context)} is not called, letting - * the Kubernetes garbage collector do its work instead (using owner references). + * reconciliation workflow, but not during a cleanup workflow, when a {@code condition} is not met + * for the resource. In this case, {@link #delete(HasMetadata, Context)} is called. During a cleanup + * workflow, however, {@link #delete(HasMetadata, Context)} is not called, letting the Kubernetes + * garbage collector do its work instead (using owner references). * </p> * <p> * If a dependent resource implement this interface, an owner reference pointing to the associated diff --git a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/workflow/DefaultManagedWorkflow.java b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/workflow/DefaultManagedWorkflow.java index fb0b733c32..8031a0b02b 100644 --- a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/workflow/DefaultManagedWorkflow.java +++ b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/workflow/DefaultManagedWorkflow.java @@ -81,7 +81,7 @@ public Workflow<P> resolve(KubernetesClient client, for (DependentResourceSpec spec : orderedSpecs) { final var dependentResource = resolve(spec, client, configuration); final var node = new DependentResourceNode( - spec.getReconcileCondition(), + spec.getCondition(), spec.getDeletePostCondition(), spec.getReadyCondition(), spec.getActivationCondition(), diff --git a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/workflow/DependentResourceNode.java b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/workflow/DependentResourceNode.java index 3e8a762c5e..c7dd91fdca 100644 --- a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/workflow/DependentResourceNode.java +++ b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/workflow/DependentResourceNode.java @@ -13,7 +13,7 @@ class DependentResourceNode<R, P extends HasMetadata> { private final List<DependentResourceNode> dependsOn = new LinkedList<>(); private final List<DependentResourceNode> parents = new LinkedList<>(); - private Condition<R, P> reconcilePrecondition; + private Condition<R, P> condition; private Condition<R, P> deletePostcondition; private Condition<R, P> readyPostcondition; private Condition<R, P> activationCondition; @@ -23,10 +23,10 @@ class DependentResourceNode<R, P extends HasMetadata> { this(null, null, null, null, dependentResource); } - public DependentResourceNode(Condition<R, P> reconcilePrecondition, + public DependentResourceNode(Condition<R, P> condition, Condition<R, P> deletePostcondition, Condition<R, P> readyPostcondition, Condition<R, P> activationCondition, DependentResource<R, P> dependentResource) { - this.reconcilePrecondition = reconcilePrecondition; + this.condition = condition; this.deletePostcondition = deletePostcondition; this.readyPostcondition = readyPostcondition; this.activationCondition = activationCondition; @@ -50,8 +50,8 @@ public List<DependentResourceNode> getParents() { return parents; } - public Optional<Condition<R, P>> getReconcilePrecondition() { - return Optional.ofNullable(reconcilePrecondition); + public Optional<Condition<R, P>> getCondition() { + return Optional.ofNullable(condition); } public Optional<Condition<R, P>> getDeletePostcondition() { @@ -62,8 +62,8 @@ public Optional<Condition<R, P>> getActivationCondition() { return Optional.ofNullable(activationCondition); } - void setReconcilePrecondition(Condition<R, P> reconcilePrecondition) { - this.reconcilePrecondition = reconcilePrecondition; + void setCondition(Condition<R, P> condition) { + this.condition = condition; } void setDeletePostcondition(Condition<R, P> cleanupCondition) { diff --git a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/workflow/WorkflowBuilder.java b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/workflow/WorkflowBuilder.java index 90ece70d26..5ca422669f 100644 --- a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/workflow/WorkflowBuilder.java +++ b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/workflow/WorkflowBuilder.java @@ -43,8 +43,8 @@ public WorkflowBuilder<P> dependsOn(DependentResource... dependentResources) { return this; } - public WorkflowBuilder<P> withReconcilePrecondition(Condition reconcilePrecondition) { - currentNode.setReconcilePrecondition(reconcilePrecondition); + public WorkflowBuilder<P> withCondition(Condition condition) { + currentNode.setCondition(condition); return this; } diff --git a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/workflow/WorkflowReconcileExecutor.java b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/workflow/WorkflowReconcileExecutor.java index 2da0bd7525..de9a0e582c 100644 --- a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/workflow/WorkflowReconcileExecutor.java +++ b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/workflow/WorkflowReconcileExecutor.java @@ -66,12 +66,12 @@ private synchronized <R> void handleReconcile(DependentResourceNode<R, P> depend dependentResourceNode.getDependentResource()); registerOrDeregisterEventSourceBasedOnActivation(activationConditionMet, dependentResourceNode); - boolean reconcileConditionMet = true; + boolean condition = true; if (activationConditionMet) { - reconcileConditionMet = isConditionMet(dependentResourceNode.getReconcilePrecondition(), + condition = isConditionMet(dependentResourceNode.getCondition(), dependentResourceNode.getDependentResource()); } - if (!reconcileConditionMet || !activationConditionMet) { + if (!condition || !activationConditionMet) { handleReconcileOrActivationConditionNotMet(dependentResourceNode, activationConditionMet); } else { submit(dependentResourceNode, new NodeReconcileExecutor<>(dependentResourceNode), RECONCILE); diff --git a/operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/dependent/workflow/WorkflowReconcileExecutorTest.java b/operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/dependent/workflow/WorkflowReconcileExecutorTest.java index c66fcb02d6..bf4e0d03e1 100644 --- a/operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/dependent/workflow/WorkflowReconcileExecutorTest.java +++ b/operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/dependent/workflow/WorkflowReconcileExecutorTest.java @@ -181,11 +181,11 @@ void onlyOneDependsOnErroredResourceNotReconciled() { } @Test - void simpleReconcileCondition() { + void simpleCondition() { var workflow = new WorkflowBuilder<TestCustomResource>() - .addDependentResource(dr1).withReconcilePrecondition(notMetCondition) - .addDependentResource(dr2).withReconcilePrecondition(metCondition) - .addDependentResource(drDeleter).withReconcilePrecondition(notMetCondition) + .addDependentResource(dr1).withCondition(notMetCondition) + .addDependentResource(dr2).withCondition(metCondition) + .addDependentResource(drDeleter).withCondition(notMetCondition) .build(); var res = workflow.reconcile(new TestCustomResource(), mockContext); @@ -202,7 +202,7 @@ void triangleOnceConditionNotMet() { var workflow = new WorkflowBuilder<TestCustomResource>() .addDependentResource(dr1) .addDependentResource(dr2).dependsOn(dr1) - .addDependentResource(drDeleter).withReconcilePrecondition(notMetCondition) + .addDependentResource(drDeleter).withCondition(notMetCondition) .dependsOn(dr1) .build(); @@ -215,17 +215,17 @@ void triangleOnceConditionNotMet() { } @Test - void reconcileConditionTransitiveDelete() { + void conditionTransitiveDelete() { TestDeleterDependent drDeleter2 = new TestDeleterDependent("DR_DELETER_2"); var workflow = new WorkflowBuilder<TestCustomResource>() .addDependentResource(dr1) .addDependentResource(dr2).dependsOn(dr1) - .withReconcilePrecondition(notMetCondition) + .withCondition(notMetCondition) .addDependentResource(drDeleter).dependsOn(dr2) - .withReconcilePrecondition(metCondition) + .withCondition(metCondition) .addDependentResource(drDeleter2).dependsOn(drDeleter) - .withReconcilePrecondition(metCondition) + .withCondition(metCondition) .build(); var res = workflow.reconcile(new TestCustomResource(), mockContext); @@ -241,14 +241,14 @@ void reconcileConditionTransitiveDelete() { } @Test - void reconcileConditionAlsoErrorDependsOn() { + void conditionAlsoErrorDependsOn() { TestDeleterDependent drDeleter2 = new TestDeleterDependent("DR_DELETER_2"); var workflow = new WorkflowBuilder<TestCustomResource>() .addDependentResource(drError) - .addDependentResource(drDeleter).withReconcilePrecondition(notMetCondition) + .addDependentResource(drDeleter).withCondition(notMetCondition) .addDependentResource(drDeleter2).dependsOn(drError, drDeleter) - .withReconcilePrecondition(metCondition) + .withCondition(metCondition) .withThrowExceptionFurther(false) .build(); @@ -269,7 +269,7 @@ void reconcileConditionAlsoErrorDependsOn() { void oneDependsOnConditionNotMet() { var workflow = new WorkflowBuilder<TestCustomResource>() .addDependentResource(dr1) - .addDependentResource(dr2).withReconcilePrecondition(notMetCondition) + .addDependentResource(dr2).withCondition(notMetCondition) .addDependentResource(drDeleter).dependsOn(dr1, dr2) .build(); @@ -284,12 +284,12 @@ void oneDependsOnConditionNotMet() { } @Test - void deletedIfReconcileConditionNotMet() { + void deletedIfConditionNotMet() { TestDeleterDependent drDeleter2 = new TestDeleterDependent("DR_DELETER_2"); var workflow = new WorkflowBuilder<TestCustomResource>() .addDependentResource(dr1) .addDependentResource(drDeleter).dependsOn(dr1) - .withReconcilePrecondition(notMetCondition) + .withCondition(notMetCondition) .addDependentResource(drDeleter2).dependsOn(dr1, drDeleter) .build(); @@ -312,7 +312,7 @@ void deleteDoneInReverseOrder() { var workflow = new WorkflowBuilder<TestCustomResource>() .addDependentResource(dr1) - .addDependentResource(drDeleter).withReconcilePrecondition(notMetCondition) + .addDependentResource(drDeleter).withCondition(notMetCondition) .dependsOn(dr1) .addDependentResource(drDeleter2).dependsOn(drDeleter) .addDependentResource(drDeleter3).dependsOn(drDeleter) @@ -338,7 +338,7 @@ void diamondDeleteWithPostConditionInMiddle() { TestDeleterDependent drDeleter4 = new TestDeleterDependent("DR_DELETER_4"); var workflow = new WorkflowBuilder<TestCustomResource>() - .addDependentResource(drDeleter).withReconcilePrecondition(notMetCondition) + .addDependentResource(drDeleter).withCondition(notMetCondition) .addDependentResource(drDeleter2).dependsOn(drDeleter) .addDependentResource(drDeleter3).dependsOn(drDeleter) .withDeletePostcondition(this.notMetCondition) @@ -362,7 +362,7 @@ void diamondDeleteErrorInMiddle() { TestDeleterDependent drDeleter3 = new TestDeleterDependent("DR_DELETER_3"); var workflow = new WorkflowBuilder<TestCustomResource>() - .addDependentResource(drDeleter).withReconcilePrecondition(notMetCondition) + .addDependentResource(drDeleter).withCondition(notMetCondition) .addDependentResource(drDeleter2).dependsOn(drDeleter) .addDependentResource(errorDD).dependsOn(drDeleter) .addDependentResource(drDeleter3).dependsOn(errorDD, drDeleter2) @@ -452,9 +452,9 @@ void diamondShareWithReadyCondition() { } @Test - void garbageCollectedResourceIsDeletedIfReconcilePreconditionDoesNotHold() { + void garbageCollectedResourceIsDeletedIfConditionDoesNotHold() { var workflow = new WorkflowBuilder<TestCustomResource>() - .addDependentResource(gcDeleter).withReconcilePrecondition(notMetCondition) + .addDependentResource(gcDeleter).withCondition(notMetCondition) .build(); var res = workflow.reconcile(new TestCustomResource(), mockContext); @@ -464,9 +464,9 @@ void garbageCollectedResourceIsDeletedIfReconcilePreconditionDoesNotHold() { } @Test - void garbageCollectedDeepResourceIsDeletedIfReconcilePreconditionDoesNotHold() { + void garbageCollectedDeepResourceIsDeletedIfConditionDoesNotHold() { var workflow = new WorkflowBuilder<TestCustomResource>() - .addDependentResource(dr1).withReconcilePrecondition(notMetCondition) + .addDependentResource(dr1).withCondition(notMetCondition) .addDependentResource(gcDeleter).dependsOn(dr1) .build(); @@ -521,18 +521,18 @@ void readyConditionNotCheckedOnNonActiveDependent() { } @Test - void reconcilePreconditionNotCheckedOnNonActiveDependent() { - var precondition = mock(Condition.class); + void conditionNotCheckedOnNonActiveDependent() { + var condition = mock(Condition.class); var workflow = new WorkflowBuilder<TestCustomResource>() .addDependentResource(dr1) .withActivationCondition(notMetCondition) - .withReconcilePrecondition(precondition) + .withCondition(condition) .build(); workflow.reconcile(new TestCustomResource(), mockContext); - verify(precondition, never()).isMet(any(), any(), any()); + verify(condition, never()).isMet(any(), any(), any()); } @Test diff --git a/operator-framework/src/test/java/io/javaoperatorsdk/operator/PrimaryToSecondaryDependentIT.java b/operator-framework/src/test/java/io/javaoperatorsdk/operator/PrimaryToSecondaryDependentIT.java index 0e48b726e9..d92fd68a4c 100644 --- a/operator-framework/src/test/java/io/javaoperatorsdk/operator/PrimaryToSecondaryDependentIT.java +++ b/operator-framework/src/test/java/io/javaoperatorsdk/operator/PrimaryToSecondaryDependentIT.java @@ -14,8 +14,8 @@ import io.javaoperatorsdk.operator.sample.primarytosecondaydependent.PrimaryToSecondaryDependentReconciler; import io.javaoperatorsdk.operator.sample.primarytosecondaydependent.PrimaryToSecondaryDependentSpec; +import static io.javaoperatorsdk.operator.sample.primarytosecondaydependent.ConfigMapCondition.DO_NOT_RECONCILE; import static io.javaoperatorsdk.operator.sample.primarytosecondaydependent.ConfigMapDependent.TEST_CONFIG_MAP_NAME; -import static io.javaoperatorsdk.operator.sample.primarytosecondaydependent.ConfigMapReconcilePrecondition.DO_NOT_RECONCILE; import static io.javaoperatorsdk.operator.sample.primarytosecondaydependent.PrimaryToSecondaryDependentReconciler.DATA_KEY; import static org.assertj.core.api.Assertions.assertThat; import static org.awaitility.Awaitility.await; diff --git a/operator-framework/src/test/java/io/javaoperatorsdk/operator/WorkflowAllFeatureIT.java b/operator-framework/src/test/java/io/javaoperatorsdk/operator/WorkflowAllFeatureIT.java index f60f2b6fde..fbaec190a8 100644 --- a/operator-framework/src/test/java/io/javaoperatorsdk/operator/WorkflowAllFeatureIT.java +++ b/operator-framework/src/test/java/io/javaoperatorsdk/operator/WorkflowAllFeatureIT.java @@ -56,7 +56,7 @@ void configMapNotReconciledUntilDeploymentReady() { @Test - void configMapNotReconciledIfReconcileConditionNotMet() { + void configMapNotReconciledIfConditionNotMet() { var resource = operator.create(customResource(false)); await().atMost(ONE_MINUTE).untilAsserted(() -> { diff --git a/operator-framework/src/test/java/io/javaoperatorsdk/operator/bulkdependent/BulkDependentWithConditionIT.java b/operator-framework/src/test/java/io/javaoperatorsdk/operator/bulkdependent/BulkDependentWithConditionIT.java index b922bb73b4..01fc6705dc 100644 --- a/operator-framework/src/test/java/io/javaoperatorsdk/operator/bulkdependent/BulkDependentWithConditionIT.java +++ b/operator-framework/src/test/java/io/javaoperatorsdk/operator/bulkdependent/BulkDependentWithConditionIT.java @@ -23,7 +23,7 @@ class BulkDependentWithConditionIT { .build(); @Test - void handlesBulkDependentWithPrecondition() { + void handlesBulkDependentWithCondition() { var resource = testResource(); extension.create(resource); diff --git a/operator-framework/src/test/java/io/javaoperatorsdk/operator/sample/primarytosecondaydependent/ConfigMapReconcilePrecondition.java b/operator-framework/src/test/java/io/javaoperatorsdk/operator/sample/primarytosecondaydependent/ConfigMapCondition.java similarity index 96% rename from operator-framework/src/test/java/io/javaoperatorsdk/operator/sample/primarytosecondaydependent/ConfigMapReconcilePrecondition.java rename to operator-framework/src/test/java/io/javaoperatorsdk/operator/sample/primarytosecondaydependent/ConfigMapCondition.java index b8aa65585d..3bb10d1f6e 100644 --- a/operator-framework/src/test/java/io/javaoperatorsdk/operator/sample/primarytosecondaydependent/ConfigMapReconcilePrecondition.java +++ b/operator-framework/src/test/java/io/javaoperatorsdk/operator/sample/primarytosecondaydependent/ConfigMapCondition.java @@ -7,7 +7,7 @@ import static io.javaoperatorsdk.operator.sample.primarytosecondaydependent.PrimaryToSecondaryDependentReconciler.DATA_KEY; -public class ConfigMapReconcilePrecondition +public class ConfigMapCondition implements Condition<ConfigMap, PrimaryToSecondaryDependentCustomResource> { public static final String DO_NOT_RECONCILE = "doNotReconcile"; diff --git a/operator-framework/src/test/java/io/javaoperatorsdk/operator/sample/primarytosecondaydependent/PrimaryToSecondaryDependentReconciler.java b/operator-framework/src/test/java/io/javaoperatorsdk/operator/sample/primarytosecondaydependent/PrimaryToSecondaryDependentReconciler.java index 3283c76a93..c3fa17e393 100644 --- a/operator-framework/src/test/java/io/javaoperatorsdk/operator/sample/primarytosecondaydependent/PrimaryToSecondaryDependentReconciler.java +++ b/operator-framework/src/test/java/io/javaoperatorsdk/operator/sample/primarytosecondaydependent/PrimaryToSecondaryDependentReconciler.java @@ -26,7 +26,7 @@ */ @Workflow(dependents = {@Dependent(type = ConfigMapDependent.class, name = CONFIG_MAP, - reconcilePrecondition = ConfigMapReconcilePrecondition.class, + condition = ConfigMapCondition.class, useEventSourceWithName = CONFIG_MAP_EVENT_SOURCE), @Dependent(type = SecretDependent.class, dependsOn = CONFIG_MAP)}) @ControllerConfiguration() diff --git a/operator-framework/src/test/java/io/javaoperatorsdk/operator/sample/workflowallfeature/ConfigMapReconcileCondition.java b/operator-framework/src/test/java/io/javaoperatorsdk/operator/sample/workflowallfeature/ConfigMapCondition.java similarity index 94% rename from operator-framework/src/test/java/io/javaoperatorsdk/operator/sample/workflowallfeature/ConfigMapReconcileCondition.java rename to operator-framework/src/test/java/io/javaoperatorsdk/operator/sample/workflowallfeature/ConfigMapCondition.java index b3d9d7a541..237faf38ca 100644 --- a/operator-framework/src/test/java/io/javaoperatorsdk/operator/sample/workflowallfeature/ConfigMapReconcileCondition.java +++ b/operator-framework/src/test/java/io/javaoperatorsdk/operator/sample/workflowallfeature/ConfigMapCondition.java @@ -5,7 +5,7 @@ import io.javaoperatorsdk.operator.api.reconciler.dependent.DependentResource; import io.javaoperatorsdk.operator.processing.dependent.workflow.Condition; -public class ConfigMapReconcileCondition +public class ConfigMapCondition implements Condition<ConfigMap, WorkflowAllFeatureCustomResource> { @Override diff --git a/operator-framework/src/test/java/io/javaoperatorsdk/operator/sample/workflowallfeature/WorkflowAllFeatureReconciler.java b/operator-framework/src/test/java/io/javaoperatorsdk/operator/sample/workflowallfeature/WorkflowAllFeatureReconciler.java index f5c14d6f96..453dbd89a0 100644 --- a/operator-framework/src/test/java/io/javaoperatorsdk/operator/sample/workflowallfeature/WorkflowAllFeatureReconciler.java +++ b/operator-framework/src/test/java/io/javaoperatorsdk/operator/sample/workflowallfeature/WorkflowAllFeatureReconciler.java @@ -11,7 +11,7 @@ @Dependent(name = DEPLOYMENT_NAME, type = DeploymentDependentResource.class, readyPostcondition = DeploymentReadyCondition.class), @Dependent(type = ConfigMapDependentResource.class, - reconcilePrecondition = ConfigMapReconcileCondition.class, + condition = ConfigMapCondition.class, deletePostcondition = ConfigMapDeletePostCondition.class, dependsOn = DEPLOYMENT_NAME) }) diff --git a/sample-operators/webpage/src/main/java/io/javaoperatorsdk/operator/sample/WebPageDependentsWorkflowReconciler.java b/sample-operators/webpage/src/main/java/io/javaoperatorsdk/operator/sample/WebPageDependentsWorkflowReconciler.java index 3d3b583659..d0f1caa8c6 100644 --- a/sample-operators/webpage/src/main/java/io/javaoperatorsdk/operator/sample/WebPageDependentsWorkflowReconciler.java +++ b/sample-operators/webpage/src/main/java/io/javaoperatorsdk/operator/sample/WebPageDependentsWorkflowReconciler.java @@ -43,7 +43,7 @@ public WebPageDependentsWorkflowReconciler(KubernetesClient kubernetesClient) { .addDependentResource(configMapDR) .addDependentResource(deploymentDR) .addDependentResource(serviceDR) - .addDependentResource(ingressDR).withReconcilePrecondition(new ExposedIngressCondition()) + .addDependentResource(ingressDR).withCondition(new ExposedIngressCondition()) .build(); } diff --git a/sample-operators/webpage/src/main/java/io/javaoperatorsdk/operator/sample/WebPageManagedDependentsReconciler.java b/sample-operators/webpage/src/main/java/io/javaoperatorsdk/operator/sample/WebPageManagedDependentsReconciler.java index 44149aed4d..6a4bf75768 100644 --- a/sample-operators/webpage/src/main/java/io/javaoperatorsdk/operator/sample/WebPageManagedDependentsReconciler.java +++ b/sample-operators/webpage/src/main/java/io/javaoperatorsdk/operator/sample/WebPageManagedDependentsReconciler.java @@ -18,7 +18,7 @@ @Dependent(type = DeploymentDependentResource.class), @Dependent(type = ServiceDependentResource.class), @Dependent(type = IngressDependentResource.class, - reconcilePrecondition = ExposedIngressCondition.class) + condition = ExposedIngressCondition.class) }) @ControllerConfiguration public class WebPageManagedDependentsReconciler diff --git a/sample-operators/webpage/src/main/java/io/javaoperatorsdk/operator/sample/WebPageStandaloneDependentsReconciler.java b/sample-operators/webpage/src/main/java/io/javaoperatorsdk/operator/sample/WebPageStandaloneDependentsReconciler.java index 4e4fa22b6b..5bc9b7554b 100644 --- a/sample-operators/webpage/src/main/java/io/javaoperatorsdk/operator/sample/WebPageStandaloneDependentsReconciler.java +++ b/sample-operators/webpage/src/main/java/io/javaoperatorsdk/operator/sample/WebPageStandaloneDependentsReconciler.java @@ -109,7 +109,7 @@ private Workflow<WebPage> createDependentResourcesAndWorkflow() { // prevent the Ingress from being created based on the linked condition (here: only if the // `exposed` flag is set in the primary resource), delete the Ingress if it already exists // and the condition becomes false - .withReconcilePrecondition(new ExposedIngressCondition()) + .withCondition(new ExposedIngressCondition()) .build(); } }