Skip to content

Commit cc7db5a

Browse files
committed
fix: wrong provided or checked conditions
Signed-off-by: Chris Laprun <claprun@redhat.com>
1 parent 7aaf729 commit cc7db5a

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/workflow/DependentResourceNode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ void setReconcilePrecondition(Condition<R, P> reconcilePrecondition) {
9898
: new ConditionWithType<>(reconcilePrecondition, Condition.Type.RECONCILE);
9999
}
100100

101-
void setDeletePostcondition(Condition<R, P> cleanupCondition) {
101+
void setDeletePostcondition(Condition<R, P> deletePostcondition) {
102102
this.deletePostcondition = deletePostcondition == null ? null
103103
: new ConditionWithType<>(deletePostcondition, Condition.Type.DELETE);
104104
}

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/workflow/WorkflowReconcileExecutor.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ protected Logger logger() {
4242
}
4343

4444
private synchronized <R> void handleReconcile(DependentResourceNode<R, P> dependentResourceNode) {
45-
log.debug("Submitting for reconcile: {} primaryID: {}", dependentResourceNode, primaryID);
45+
log.debug("Considering for reconcile: {} primaryID: {}", dependentResourceNode, primaryID);
4646

4747
final var alreadyVisited = alreadyVisited(dependentResourceNode);
4848
final var executingNow = isExecutingNow(dependentResourceNode);
4949
final var isWaitingOnParents = !allParentsReconciledAndReady(dependentResourceNode);
5050
final var isMarkedForDelete = markedForDelete.contains(dependentResourceNode);
5151
final var hasErroredParent = hasErroredParent(dependentResourceNode);
52-
if (alreadyVisited || executingNow || isMarkedForDelete || isWaitingOnParents
52+
if (isWaitingOnParents || alreadyVisited || executingNow || isMarkedForDelete
5353
|| hasErroredParent) {
5454
if (log.isDebugEnabled()) {
5555
final var causes = new ArrayList<String>();
@@ -68,7 +68,7 @@ private synchronized <R> void handleReconcile(DependentResourceNode<R, P> depend
6868
if (hasErroredParent) {
6969
causes.add("errored parent");
7070
}
71-
log.debug("Skipping submit of: {} primaryID: {} causes: {}", dependentResourceNode,
71+
log.debug("Skipping: {} primaryID: {} causes: {}", dependentResourceNode,
7272
primaryID, String.join(", ", causes));
7373
}
7474
return;
@@ -97,7 +97,7 @@ private synchronized void handleDelete(DependentResourceNode dependentResourceNo
9797
final var executingNow = isExecutingNow(dependentResourceNode);
9898
final var isNotMarkedForDelete = !markedForDelete.contains(dependentResourceNode);
9999
final var isWaitingOnDependents = !allDependentsDeletedAlready(dependentResourceNode);
100-
if (alreadyVisited || executingNow || isNotMarkedForDelete || isWaitingOnDependents) {
100+
if (isNotMarkedForDelete || alreadyVisited || executingNow || isWaitingOnDependents) {
101101
if (log.isDebugEnabled()) {
102102
final var causes = new ArrayList<String>();
103103
if (alreadyVisited) {
@@ -142,12 +142,11 @@ protected void doRun(DependentResourceNode<R, P> dependentResourceNode) {
142142
"Reconciling for primary: {} node: {} ", primaryID, dependentResourceNode);
143143
ReconcileResult reconcileResult = dependentResource.reconcile(primary, context);
144144
final var detailBuilder = createOrGetResultFor(dependentResourceNode);
145-
detailBuilder.withReconcileResult(reconcileResult);
145+
detailBuilder.withReconcileResult(reconcileResult).markAsVisited();
146146

147147
if (isConditionMet(dependentResourceNode.getReadyPostcondition(), dependentResourceNode)) {
148148
log.debug("Setting already reconciled for: {} primaryID: {}",
149149
dependentResourceNode, primaryID);
150-
detailBuilder.markAsVisited();
151150
handleDependentsReconcile(dependentResourceNode);
152151
} else {
153152
log.debug("Setting already reconciled but not ready for: {}", dependentResourceNode);
@@ -164,21 +163,21 @@ private NodeDeleteExecutor(DependentResourceNode<R, P> dependentResourceNode) {
164163
@Override
165164
@SuppressWarnings("unchecked")
166165
protected void doRun(DependentResourceNode<R, P> dependentResourceNode) {
167-
final var dependentResource = dependentResourceNode.getDependentResource();
168166
boolean deletePostConditionMet = true;
169167
if (isConditionMet(dependentResourceNode.getActivationCondition(), dependentResourceNode)) {
170168
// GarbageCollected status is irrelevant here, as this method is only called when a
171169
// precondition does not hold,
172170
// a deleter should be deleted even if it is otherwise garbage collected
171+
final var dependentResource = dependentResourceNode.getDependentResource();
173172
if (dependentResource instanceof Deleter) {
174173
((Deleter<P>) dependentResource).delete(primary, context);
175174
}
176175
deletePostConditionMet =
177176
isConditionMet(dependentResourceNode.getDeletePostcondition(), dependentResourceNode);
178177
}
179178

179+
createOrGetResultFor(dependentResourceNode).markAsVisited();
180180
if (deletePostConditionMet) {
181-
createOrGetResultFor(dependentResourceNode).markAsVisited();
182181
handleDependentDeleted(dependentResourceNode);
183182
}
184183
}

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/workflow/WorkflowResult.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ public void throwAggregateExceptionIfErrorsPresent() {
5757
}
5858
}
5959

60+
@SuppressWarnings("UnusedReturnValue")
6061
static class DetailBuilder<R> {
6162
private Exception error;
6263
private ReconcileResult<R> reconcileResult;
@@ -103,7 +104,7 @@ public boolean hasError() {
103104
}
104105

105106
public boolean hasPostDeleteConditionNotMet() {
106-
return deletePostconditionResult != null && !readyPostconditionResult.isSuccess();
107+
return deletePostconditionResult != null && !deletePostconditionResult.isSuccess();
107108
}
108109

109110
public boolean isNotReady() {

0 commit comments

Comments
 (0)